Cocoapods - Error installing Mapbox-iOS-SDK
Asked Answered
R

9

23

I want to install last version of Mapbox with Cocoapods. I configure .netrc file :

machine api.mapbox.com 
login mapbox
password <MY_SECRET_TOKEN>

But when I launch pod install, I have this error :

[!] Error installing Mapbox-iOS-SDK
[!] /usr/bin/curl -f -L -o /var/folders/vq/jpt1fhxd6fx58rz9zvbdtw000000gn/T/d20200922-35020-qeu6k2/file.zip https://api.mapbox.com/downloads/v2/mobile-maps/releases/ios/packages/6.2.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    44    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 401

How to fix this error ?

Renin answered 22/9, 2020 at 10:6 Comment(0)
B
46

It took a night for me. After googling too many hours i can't find the best solution to write the secret key on .netrc file. Please follow the procedure:

  1. Go to Terminal and write cd ~
  2. Press Enter.
  3. Write vi .netrc . It will open the empty file in the terminal.
  4. Press i here to insert data here. When you enter i it will open in insert mode.
  5. Now paste
    machine api.mapbox.com
    login mapbox
    password sk.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Note: Don't put < braces in password >

  1. Press Esc Key from keyboard.
  2. Write :w to write all data on file.
  3. Now write :q to quit from file.
  4. You successfully save the file.
  5. Run Pod install
Bik answered 24/4, 2021 at 20:50 Comment(2)
why so complicated open open .netrcCapps
@KhurshidAnsari How is it complicated? vim ~/.netrc Thats it...Brickyard
A
13

Please make sure that you have saved the .netrc file in your computer's home directory (not the project's home directory) and that you have pasted your secret token (a new token with the Downloads:Read scope) into the file.

Arcuation answered 28/9, 2020 at 15:22 Comment(2)
My problem came from the hooks "<>". Thanks.Renin
In my case Downloads:Read scope was the issue!Willing
C
8

That part of the guide might be a bit confusing.

In my case, I realised that the file .netrc was already in my Home directory. I just had to open a new Terminal and do nano .netrc. Then I added those 3 lines:

machine api.mapbox.com
  login mapbox
  password PRIVATE_MAPBOX_API_TOKEN
Cliff answered 6/10, 2020 at 0:13 Comment(0)
B
7

I searched for fix it so much. but at the end I found the easiest way. You Have to just install lower version instead of 6.3.0

I fixed the issue with version : 4.11.2

and edit your Podfile Like this :

pod 'Mapbox-iOS-SDK', '~> 4.11.2'
Binghi answered 21/1, 2021 at 12:25 Comment(2)
guess using older versions is not a right option.Kaffiyeh
This wont work for M1 Macs.Athelstan
N
3

When you create your 'Create token' in https://account.mapbox.com/access-tokens, do remember to check the Downloads:Read scope. enter image description here

Neophyte answered 11/1, 2023 at 1:35 Comment(0)
M
1

This work fo me

  1. open terminal
  2. cd ~ (go to the home directory)
  3. touch .netrc (create a file)
  4. open .netrc (open file)
  5. add require data
  6. save file (cmd + s)
  1. require data must be like this

enter image description here

Morphia answered 2/11, 2022 at 18:6 Comment(0)
S
0

(MAC system) I spent hours on this error and at the end I saw that the .netrc file is actually written as a netrc file (without the dot), so even if you rename it, it doesn't work, you have to create the file from terminal, using:

  • vi .netrc
  • mode insert
  • paste
machine <name>
login <user>> 
password <token>
  • esc
  • :x

Now with pod repo-art add repoName url you can connect success

Siriasis answered 28/2, 2023 at 1:28 Comment(0)
K
0

Open the Pod file of your project and remove pod 'Mapbox-iOS-SDK' and save it and close it . And run pod install and pod clean in your terminal and go back to Pod file of your project again and re-write pod 'Mapbox-iOS-SDK' and on your terminal run pod install.

Krems answered 26/3, 2023 at 10:24 Comment(0)
A
0

A comprehensive answer that worked for me:

  1. make sure your token has DOWNLOADS:READ scope
  2. vi ~/.netrc and insert the following lines :
    machine api.mapbox.com
    login mapbox
    password whatever_token_we_have
  1. voilà
Automate answered 16/10, 2023 at 9:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.