[英]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)我正在尝试将 Mapbox 添加到 Kotlin/Native 项目,我在其中使用 cocoapods:(已经为 Android 设置 - 工作正常)
//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:通过 Kotlin/Native 运行的 Pod 不会读取带有凭据的
.netrc
文件:
machine api.mapbox.com
login name
password pass
In pod file I added my library:在 pod 文件中,我添加了我的库:
pod 'SharedCode', :path => 'kotlin_native/SharedCode'
The error I see when I run pod install
:我在运行
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 添加到 iOS 项目,它可以正常工作:
#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?另外,我尝试使用
podspec
并将access_token
放入 URL 但它不起作用(有或没有令牌),不确定它是否不受支持或语法错误?
ArgumentError - Illformed requirement `":podspec => https://github.com/mapbox/pod-specs/blob/master/Mapbox-iOS-SDK/5.2.0/Mapbox-iOS-SDK.podspec"`
this feature is not supported at the moment.目前不支持此功能。 Kotlin version 1.4-RC should introduce a possible workaround.
Kotlin 版本 1.4-RC 应该引入一种可能的解决方法。 One can try calling
curl
manually and then import local CocoaPods dependency as it is done in this sample.可以尝试手动调用
curl
,然后导入本地 CocoaPods 依赖项,就像在此示例中所做的那样。
I would also recommend you to file an issue here( https://kotl.in/issue ).我还建议您在此处提交问题( https://kotl.in/issue )。 Supporting credentials is important, and should be put on the Kotlin team's list.
支持凭证很重要,应该放在 Kotlin 团队的名单上。
The login has to be "mapbox": mapbox documentation: https://docs.mapbox.com/ios/maps/overview/#configure-credentials登录必须是“mapbox”:mapbox 文档: https://docs.mapbox.com/ios/maps/overview/#configure-credentials
machine api.mapbox.com
login mapbox
password <INSERT API TOKEN>
Bonus tips: You can add credential before pod install / pod update process and remove it after with this macos script for example:额外提示:您可以在 pod install / pod update 过程之前添加凭据,然后使用此 macOS 脚本将其删除,例如:
echo "Generate credential for mapbox"
echo "machine api.mapbox.com" > ~/.netrc
echo "login mapbox" >> ~/.netrc
echo "password <INSERT API TOKEN>" >> ~/.netrc
To delete this entry later:稍后删除此条目:
sed -i '' -e '/^machine api.mapbox.com$/{N;N;d;}' ~/.netrc
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.