Search code examples
ioscocoapodsmapboxkotlin-nativemapbox-ios

Build Mapbox pod iOS with Kotlin/Native Multiplatform


I'm trying to add Mapbox to Kotlin/Native project, where I use cocoapods: (already set up for Android - works fine)

    //plugin 
    kotlin("native.cocoapods")
    
    //pod
    cocoapods {
        // Configure fields required by CocoaPods.
        summary = "Some description for a Kotlin/Native module"
        homepage = "Link to a Kotlin/Native module homepage"

        pod("Mapbox-iOS-SDK", "~> 6.0.0")
    }

Pod run through the Kotlin/Native doesn't read .netrc file with credentials:

machine api.mapbox.com 
login name
password pass

In pod file I added my library:

pod 'SharedCode', :path => 'kotlin_native/SharedCode'

The error I see when I run pod install:

[!] Error installing Mapbox-iOS-SDK
[!] /usr/bin/curl -f -L -o /var/folders/vk/rb1bs6ld7wd19cmg6srw9s080000gn/T/d20200728-92875-1y3089q/file.zip https://api.mapbox.com/downloads/v2/mobile-maps/releases/ios/packages/6.0.0/mapbox-ios-sdk-dynamic.zip --create-dirs --netrc-optional --retry 2

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 401 Unauthorized

If I add pod to iOS project directly, it works ok:

#pod 'Mapbox-iOS-SDK', '~> 5.0.0'

How can I make it read credentials file? Is it possible?

Also, I tried to use podspec and put access_token in the URL but it doesn't work (with or without token), not sure if it is not supported or made syntax mistake?

ArgumentError - Illformed requirement `":podspec => https://github.com/mapbox/pod-specs/blob/master/Mapbox-iOS-SDK/5.2.0/Mapbox-iOS-SDK.podspec"`

Solution

  • this feature is not supported at the moment. Kotlin version 1.4-RC should introduce a possible workaround. One can try calling curl manually and then import local CocoaPods dependency as it is done in this sample.


    I would also recommend you to file an issue here(https://kotl.in/issue). Supporting credentials is important, and should be put on the Kotlin team's list.