5

我在安装 pod 时遇到以下问题。

[!] 安装 Mapbox-iOS-SDK 时出错 [!] /usr/bin/curl -f -L -o /var/folders/qn/l5lqh07s5sscfzbm1tklmzgr0000gn/T/d20200915-46243-1aqah9u/file.zip https://api .mapbox.com/downloads/v2/mobile-maps/releases/ios/packages/6.1.0/mapbox-ios-sdk-dynamic.zip --create-dirs --netrc-optional --retry 2 -A 'CocoaPods /1.9.3 cocoapods-downloader/1.4.0'

% Total % Received % Xferd 平均速度 时间 时间 当前 Dload 上传总花费 左速度 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 curl:(22)请求的URL返回错误:401 Unauthorized

我在主目录中添加了 .netrc 文件,但仍然面临问题。

吊舱错误1

4

3 回答 3

9

从 Mapbox 6.x 开始,您必须指明凭据才能检索最新的可用 pod 版本: https ://docs.mapbox.com/ios/maps/overview/#configure-credentials

您可以在 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

稍后删除此条目:

sed -i '' -e '/^machine api.mapbox.com$/{N;N;d;}' ~/.netrc
于 2020-10-09T09:02:29.377 回答
2

看起来在创建 .netrc 文件时存在一些问题。您可以使用以下提示在安装 Mapbox 之前创建一个 .netrc 文件:

要创建 .netrc 文件,请执行以下操作

启动终端

cd ~(进入主目录)

touch .netrc(创建文件)

打开 .netrc(打开 .netrc)

设置所需数据。

节省

.netrc 文件应该是这样的

machine api.mapbox.com 登录 mapbox 密码 <secret_key_created_from_your_mapbox_account>

如果您创建了有关此指令的 .netrc 文件,则应该安装 mapbox cocoapods。

于 2021-08-02T05:23:05.057 回答
1

https://docs.mapbox.com/ios/navigation/guides/install/

A secret access token with the Downloads:Read scope. From your account's tokens page, click the Create a token button. From the token creation page, give your token a name and make sure the box next to the Downloads:Read scope is checked. Click the Create token button at the bottom of the page to create your token. The token you've created is a secret token, which means you will only have one opportunity to copy it somewhere secure.

于 2021-03-01T12:23:58.037 回答