简体   繁体   English

使用 Kotlin/Native Multiplatform 构建 Mapbox pod 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)我正在尝试将 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.

相关问题 Kotlin Multiplatform 中的 TrustWalletCore/WalletCore pod - 几乎没有类 - TrustWalletCore/WalletCore pod in Kotlin Multiplatform - almost no classes 适用于 iOS 的 Kotlin 多平台库,带有位码 - Kotlin Multiplatform library for iOS with bitcode kotlin.native.concurrent.InvalidMutabilityException:在Kotlin Multiplatform(iOS)中使用ktor时冻结<object>的突变尝试 - kotlin.native.concurrent.InvalidMutabilityException: mutation attempt of frozen <object> when using ktor in Kotlin Multiplatform (iOS) Kotlin Multiplatform Mobile:Ktor - 如何在 Kotlin Native(iOS)中取消活动协程(网络请求,后台工作)? - Kotlin Multiplatform Mobile: Ktor - how to cancel active coroutine (network request, background work) in Kotlin Native (iOS)? 找不到Mapbox。 @ mapbox / react-native-mapbox-gl不在CircleCi上构建iOS项目 - Mapbox not found. @mapbox/react-native-mapbox-gl doesn't build iOS project on CircleCi kotlin multiplatform:如何减少构建时间? - kotlin multiplatform: how to reduce build time? 为 iOS 创建/导入 Kotlin 多平台代码 - Creating/Importing Kotlin multiplatform code for iOS Kotlin Multiplatform - iOS + Android 之间的策略共享 - Kotlin Multiplatform - Strategy sharing between iOS + Android 多平台 Kotlin 中 iOS 的 Base 64 编码解码 - Base 64 Encoding Decoding for iOS in Multiplatform Kotlin Kotlin Multiplatform 中 iOS 应用程序的不同架构 - Different Schema for iOS App in Kotlin Multiplatform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM