373

I've encountered an strange issue after installing RestKit with cocoapods. after resolving RestKit dependency for my project with cocoapods and trying to build it, I face this error:

The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

I tried running pod install, but no change.

Here are some shots: enter image description here

enter image description here

  PODS:
  - AFNetworking (1.3.3)
  - RestKit (0.20.3):
    - RestKit/Core
  - RestKit/Core (0.20.3):
    - RestKit/CoreData
    - RestKit/Network
    - RestKit/ObjectMapping
  - RestKit/CoreData (0.20.3)
  - RestKit/Network (0.20.3):
    - AFNetworking (~> 1.3.0)
    - RestKit/ObjectMapping
    - RestKit/Support
    - SOCKit
  - RestKit/ObjectMapping (0.20.3)
  - RestKit/Search (0.20.3):
    - RestKit/CoreData
  - RestKit/Support (0.20.3):
    - TransitionKit (= 1.1.1)
  - RestKit/Testing (0.20.3)
  - SOCKit (1.1)
  - TransitionKit (1.1.1)

DEPENDENCIES:
  - RestKit (~> 0.20.0)
  - RestKit/Search (~> 0.20.0)
  - RestKit/Testing (~> 0.20.0)

SPEC CHECKSUMS:
  AFNetworking: 61fdd49e2ffe6380378df37b3b6e70630bb9dd66
  RestKit: 1f181c180105a92f11ec4f6cd7de37625e516d83
  SOCKit: 2f3bc4d07910de12dcc202815e07db68a3802581
  TransitionKit: d0e3344aac92991395d4c2e72d9c5a8ceeb12910

COCOAPODS: 0.29.0
10
  • 3
    Did you try Run 'pod install' or update your CocoaPods installation. as suggested by the error?
    – Wain
    Commented Jan 26, 2014 at 17:13
  • 5
    absolutely, I did that, but no success Commented Jan 26, 2014 at 17:26
  • 1
    Can you post the version of Restkit in the Podfile.lock and in Pods/Manifest.lock? That error occurs when these are not the same.
    – MishieMoo
    Commented Jan 27, 2014 at 2:22
  • 2
    yeah, I compared them, they are exactly identical. Commented Jan 27, 2014 at 14:54
  • The error above the "sandbox" error is "diff: command not found" I don't know if reinstalling diff could fix the problem, but it may be a hint as to what's happening. Commented Feb 9, 2014 at 2:28

63 Answers 63

423

I was able to fix that by updating CocoaPods.

I. Project Cleanup

  1. In the project navigator, select your project
  2. Select your target
  3. Remove all libPods*.a in Build Phases > Link Binary With Libraries

II. Update CocoaPods

  1. Launch Terminal and go to your project directory.
  2. Update CocoaPods using the command pod install
13
  • 1
    When I run the pod install command in the project directory I received below warning: The use of implicit sources has been deprecated. To continue using all of the sources currently on your machine, add the following to the top of your Podfile: source 'github.com/CocoaPods/Specs.git' I also added this link in the pod file but same thing happened. please suggest. Commented Oct 22, 2014 at 6:09
  • In addition to this I had to remove all CocoaPod related build phases such as 'Check Pods Manifest.lock' and 'Copy Pods Resources'.
    – JVillella
    Commented Dec 19, 2014 at 19:52
  • Usually the issue happens because of this: github.com/CocoaPods/CocoaPods/issues/1822
    – KarenAnne
    Commented Apr 14, 2015 at 7:08
  • 21
    @ Valery Pavlov These steps worked but after a successful project clean, the build fails immediately with the same 3 errors I cant seem to get rid of below. I tried fully removing all cocoapods, reinstalling, updating, doing all of this with xcode restarts and etc. All of these in terminal perform successfully but the build continues to fail. Any further thoughts? Errors: diff: /../Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
    – natur3
    Commented Aug 25, 2015 at 6:58
  • 1
    I tried Pod install..But i got error like this You have either: * out-of-date source repos which you can update with pod repo update. * mistyped the name or version. * not added the source repo that hosts the Podspec to your Podfile. Note: as of CocoaPods 1.0, pod repo update does not happen on pod install by default.
    – JAK
    Commented Jun 7, 2016 at 12:37
137

After many attemps I managed to fix this problem. Variable ${PODS_ROOT} was not set and I do below trick. Go to Build Phases -> Check Pods Manifest.lock and replace

diff "${PODS_ROOT}/../Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null

to

diff "${SRCROOT}/Podfile.lock" "${SRCROOT}/Pods/Manifest.lock" > /dev/null

It helps me.

5
  • Why $PODS_ROOT is not setted up? Do I need to reinstall pods for my project?
    – Petr Syrov
    Commented Nov 3, 2015 at 13:33
  • 2
    The reason why $PODS_ROOT was not set is mainly because the .xcconfig file generated by cocoapods is not applied to the build target.
    – Fujia
    Commented Jul 26, 2016 at 5:37
  • @Fujia how do I apply a .xcconfig file? Commented Sep 15, 2017 at 22:52
  • In my case I set PODS_ROOT = ${SRC_ROOT}/Pods in my xcconfig for the same effect.
    – grego
    Commented May 6, 2020 at 20:33
  • that solved my problem for ionic Cordova project. Commented Oct 31, 2021 at 8:48
92

I had been searching for hours and I found solutions as follow:

In my case, method 1 works.

Method 1:

  1. choose the target > go to Build Phases > click Link Binary With Libraries > remove all libPods.a files

  2. open Terminal > direct to your project > run:

      pod install
    
  3. clean and build project

ref.1

Method 2:

  1. open Terminal > direct to your project > run:

     pod deintegrate --verbose    
     pod install --verbose
    

ref.2

Method 3:

  1. choose the target > go to Build Settings > click "+" sign

  2. add 2 User-Defined Settings: [to the left = to the right]

     PODS_ROOT = ${SRCROOT}/Pods
    

and

    PODS_PODFILE_DIR_PATH = ${SRCROOT}/

ref.3

6
  • 2
    I tried all other solutions but nothing worked. Method 3 worked for me.
    – Vinner
    Commented Dec 19, 2019 at 7:22
  • However... after resolving the problem byMethod 1 I came across with another error... Showing Recent Errors Only Command PhaseScriptExecution failed with a nonzero exit code
    – Amir Aslam
    Commented Nov 28, 2020 at 7:48
  • 3
    Method 2 worked for me. Thank you very much. Commented Jan 26, 2021 at 7:35
  • Method 1 worked for me, thanks ! Commented Feb 10, 2022 at 23:15
  • None of them working for me. It's a very old project and many coworkers have it up and running, and I had it working before it suddenly stopped. I don't believe it's something related to pod, despite the name Commented Feb 22, 2023 at 15:11
47

If you remove all pods from your target in the Podfile, e.g.

target 'myTarget' do
pod 'great-stuff', '~> 4.0'  // you deleted this last pod
end

you'll need to manually delete these builds steps from your Xcode target Build Phases:

  • Check Pods Manifest.lock
  • Copy Pod resources

Cocoapods (current stable version 0.37.2) does not perform this cleanup when you run pod install.

2
  • This worked for me. Id been migrating to swift 2 and had commented out all pods - i just turned one of the pods back on rather than messing with deleting build phases. Commented Sep 30, 2015 at 17:23
  • bingo! i spent hours removing my workspace, reinstalling pods, etc and nothing else worked.
    – Oren
    Commented Oct 29, 2015 at 4:04
41

Removing pods from the project and re-installing worked for me.

There is nice GitHub repository that can completely remove the pods from the project.

Just keep the backup of your PodFile and run below commands.

  • gem install cocoapods-deintegrate
  • gem install cocoapods-clean
  • Go to the project directory and run pod deintegrate
  • Again run pod clean
  • Run pod install

Clean and run.

8
  • 1
    You are great, only yours worked for me, thanks a lot
    – albert sh
    Commented Jul 26, 2017 at 19:34
  • After running these commands I get a successful build message, but now, nothing appears to run on the simulator nor the console. Do you know why this happened? Commented Aug 21, 2017 at 2:39
  • BE AWARE: Build works, but the pod clean dissapeared the project target. No archives were generated nor app builded.
    – Ruben
    Commented Feb 7, 2019 at 19:32
  • @Ruben the disappeared content will regenerate on "pod install" again Commented Feb 8, 2019 at 9:25
  • Despite that, after doing the steps you mentioned my app icon don't appear anymore as the main project... Only the cordova logo appears, and no build or archive is being generated.
    – Ruben
    Commented Feb 11, 2019 at 23:25
18

If you are seeing an error like the following:

diff: /../Podfile.lock: No such file or directory diff: /Manifest.lock: No such file or directory error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.

Then there's a problem with Cocoapods in your project. Sometimes cocoapods can get out of sync and you need to re-initiate cocoapods. You should be able to resolve this error by:

  1. Deleting the Podfile.lock file in your project folder
  2. Deleting the Pods folder in your project folder
  3. Execute 'pod install' in your project folder
  4. Do a "Clean" in Xcode
  5. Rebuild your project
6
  • 3
    Thank you so much. You made my day. Nothing else worked in my Flutter project.
    – nbloqs
    Commented Sep 25, 2019 at 11:41
  • This is the only solution that worked for me as well. Deleting Podfile.lock. Be warned that you might get some unexpected version upgrades when doing this.
    – santamanno
    Commented Mar 3, 2020 at 22:15
  • for flutter: run pod install in your flutter_project/ios Commented Apr 18, 2020 at 11:09
  • @santamanno you should not remove delete the lock file as mentioned. To explain what's happening. See here .
    – mfaani
    Commented Jan 18, 2021 at 23:22
  • Thanks @Honey, I did not know it at the time. Killing/overwriting the Manifest.lock would do the trick I guess =)
    – santamanno
    Commented Jan 20, 2021 at 21:55
14

After changing target name

My problem was xcconfig with old target names.

  • Went to project file -> info -> configuration
  • Removed old xcconfig (both Debug & Release)
  • pod install

It would update to new ones.

Also if you had missing .h files that's the reason (pods header search path is in these xcconfig)

1
  • Choosing None worked for me as well. I was struggling with this for a day trying to integrate the Gimbal2 SDK into an Ionic4 project.
    – Russ
    Commented Oct 25, 2018 at 17:47
13

I found my solution: Run:pod update instead of pod install. The error was fixed!

1
  • 1
    Well. This will update outdated pods, so be sure that that is what you want.
    – ff10
    Commented Sep 30, 2019 at 13:08
13

First you have to understand what the Podfile.lock is then understand what the Manifest.lock is and where it's used.

The Podfile holds either the (optimistic or exact) versions of every dependency you have. The lock file holds only exact versions.

Once you do pod install all the pods get downloaded/installed into the /pods directory. You may want to commit them Or maybe not. That's up to your team. What's NOT up to your team is decide if they should commit the the Podfile.lock or not. That needs to be committed so every dev in the team can be sure they've got the exact same version.

  • So let's say you downloaded your team’s code. In your project's root directory you only have Podfile and Podfile.lock and the Pods directory wasn’t committed.
  • Then you do pod install to creat the Pods directory. Your snapshot of every pods’ version should match with the versions of all pods from the Podfile.lock.
  • CocoaPods has a safety check in place, to ensure matching versions

This is where the Manifest.lock comes into play. Manifest.lock is your local machine's lock created. It has to match with Podfile.lock that is generated by the last commit (that caused changes in for your pods) in your repo. If it doesn't match then something is messed up.

Docs on what the Manifest.lock file is:

  #     Manifest.lock: A file contained in the Pods folder that keeps track of
  #     the pods installed in the local machine. This files is used once the
  #     exact versions of the Pods has been computed to detect if that version
  #     is already installed. This file is not intended to be kept under source
  #     control and is a copy of the Podfile.lock.

I honestly can only think of one scenario in which the Manifest.lock and Podfile.lock would be out of sync:

I mean if you pull from main branch, then you get main's Podfile and lock file. If you then make a change to the Podfile and then run pod install, then you would be updating the Podfile.lock and Manifest.lock and will keep them in sync. No issues with this

Is this just so that if:

  1. You and your team don’t commit the /Pods directory
  2. You have merge conflicts in your Podfile or Podfile.lock but don’t realize it. Or you haven't committed both Podfile and Podfile.lock
  3. Then given that Xcode doesn’t process the Podfile and Podfile.lock, then naturally your project can build successfully.
  4. However if you go in an inspect your Build Phases of your targets you'd see the following

enter image description here

That script is documented here

#     Adds a shell script build phase responsible for checking if the Pods
#     locked in the Pods/Manifest.lock file are in sync with the Pods defined
#     in the Podfile.lock.
#     
#     @note   The build phase is appended to the front because to fail fast.
#     
#     @return [void]

What those lines do are: perform a diff and ensure that sure your Manifest.lock i.e. your local snapshot of all installed pod versions are equal to Podfile.lock i.e. your repo's current snapshot of all installed pod versions.

The fix is likely super simple, just make sure you Podfile is what you want. Then just run pod install. You have also somehow accidentally made changes to your Manifest.lock inside your /Pods directory (or as mentioned earlier maybe only committed the lock file but not the Podfile or vice versa). Deleting /Pods directory causes no harm. Just do a pod install after. Do not do pod update unless that's what you want.

Just make sure you never delete the Podfile.lock otherwise if you do pod install then it would update all dependencies to the latest version it can.


Also helpful to see and this video on lock files, CocoaPods docs on how the lock file is put to use differently for pod install vs. pod update and last see how all that logic is used in more detail this artsy blog on checksums. It's worth noting that a single space will create a new checksum and can make things out of sync.

2
  • Did all of that didn't help. Pretty sure the test itself is buggy and produces a false failure. Not the first time I came across a sanity check which fails unnecessarily. There is a reason why I program sanity checks as WARNINGS and not as errors.
    – Martin
    Commented Mar 3, 2021 at 10:31
  • @Martin I'm skeptical if you're correct. However if you're 100% sure, you can remove the check from your project's build phase
    – mfaani
    Commented Apr 3, 2022 at 14:30
11
  • Go to Build Phases -> Check Pods Manifest.lock
  • Replace
${PODS_ROOT}/Manifest.lock

with:

${SRCROOT}/Podfile.lock" "${SRCROOT}/Pods/Manifest.lock

Check in image :

enter image description here

2
  • This worked for me in a Cordova iOS build, while the accepted answer did not work. Commented Nov 8, 2019 at 10:14
  • Thank you for pointing out the origin of the error, but this also didn't solve my issue. Ideally Cordova do not recommend modifying their pod file, but if we delete the Podfile.lock and do a pod install again with the modified Podfile , there should not be an error. So, as a last option I commented the if condition, since I feel it is not a necessary check, and thus I came out of the issue.
    – Shihab
    Commented Mar 9, 2021 at 14:52
11

Can you try this:

  1. Delete the Pods folder
  2. Delete Podfile.lock
  3. Run pod install
  4. Clean + Build
6

In my case, I got same error after integrating WatchKit app. To solve problem I needed to add both targets of WatchKit in Podfile:

target 'MyProject WatchKit App' do
    platform :watchos, '2.0'
    shared_pods
end

target 'MyProject WatchKit App Extension' do
    platform :watchos, '2.0'
    shared_pods
end

PS: Maybe this happened for me because I mistakenly installed pods for MyProject WatchKit App target initially.

1
  • I think you hit the nail on the head ;) Commented Oct 31, 2016 at 20:57
6

Try to set up the correct target in Podfile and then run pod update or pod install

ios platform target

5

Run this, and your errors will vanish

rm -rf Pods && gem install cocoapods && pod install

4

I encountered this issue with a misconfigured xcconfig file.

The Pods-generated xcconfig was not correctly #included in the customise xcconfig that I was using. This caused $PODS_ROOT to not be set resulting in the failure of diff "/../Podfile.lock" "/Manifest.lock", for obvious reasons, which Pods misinterprets as a sync issue.

4

For me the problem was that I made a new target in my app by duplicating an existing one, but forgot to add the target to the Podfile. For some reason, the cloned target did work for days without problems, but after a while it failed to build by this error. I had to create a new target entry for my cloned project target in the Podfile then run pod install.

4

If you download the project from github or copy from other place, then the dependencies library do not exists, there will be this issue.

You just need to cd to the project/project_name directory in terminal , use ls to check whether there is a Podfile file.

if there exists the Podfile, you just need to install the dependencyies:

pod install
2
  • Thanks - this really helped me a lot when I was running the flutter examples downloaded from their github website and I had received the same error. I navigated to the ios folder for each flutter example folder and did the pod install and then the flutter app worked.
    – Simon
    Commented Apr 13, 2018 at 9:12
  • glad to help you.
    – aircraft
    Commented Apr 13, 2018 at 9:45
4

My working answer is:

  1. Install update your cocoapods by this command: pod update
  2. Install your new pods by this command. pod install
  3. Last one command: sudo gem install cocoapods.
3

This made my day!

  1. Deleting the Podfile.lock file in your project folder
  2. Deleting the Pods folder in your project folder
  3. Execute pod install in your project folder
  4. Do a "Clean" in Xcode
  5. Rebuild your project
1
  • I approve this message! Also if you're on Flutter don't forget to flutter pub get Commented May 27, 2020 at 19:13
3

The steps that worked for me (XCode 8.3.3/XCode 9 beta with a Swift 3.1 project)

 - Navigate to your project directory
 - pod install //which then asks you to do the next step
 - pod repo update //takes a while to update the repo
 - pod update
 - pod install
 - Close Xcode session
 - Open and Clean the project
 - Build/Run

Also make sure you open the .xcworkspace file rather than the project file (.xcodeproj) when working with pods. That should solve any errors with linking such as "Apple Mach -O Linker command failed"

0
3

Please do the following steps:

1: Deleting the Podfile.lock file in your project folder

2: Deleting the Pods folder in your project folder

3: Execute 'pod install' in your project folder

4: Do a "Clean" in Xcode

5: Rebuild your project

3

I tried everything, but the problem persisted. After that I did this and it worked ASAP (As Smooth As Possible).

  1. Open the .xcworkspace file.
  2. Change to legacy build system if using Cordova on Xcode 10.
  3. Go to target/project of Podfile. Select Deployment traget as 11+
  4. Then Change the debug and release to Pods-.build/release. It was App.debug/release in my case.Pic attached. Hope it helps. CHange the Debug Release in Pod
3

Completely nothing worked out for me from these answers. Had to create the project again by running cordova platform add ios. What I've noticed, even freshly generated project with (in my case) Firebase pods caused the error message over and over again. In my opinion looks like a bug for some (Firebase, RestKit) pods in Xcode or CocoaPods. To have the pods included I could simply edit my config.xml and run cordova platform add iOS, which did everything for me automatically. Not sure if it will work in all scenarios though.

Edit: I had a Podfile from previous iOS/Xcode, but the newest as of today have # DO NOT MODIFY -- auto-generated by Apache Cordova in the Podfile. This turned on a light in my head to try the approach. Looks a bit trivial, but works and my Firebase features worked out.

1
  • 1
    This is the only method that worked for me. Tried all others. I deleted platforms and did a reinstall of 'cordova platform add ios'. I too think I had a previous platforms/ios which I used on a previous version of xcode.
    – Heath
    Commented Jun 23, 2020 at 21:04
3

Check Pods target and Runner target thats have to be same

1- Runner

enter image description here

2- Pods

enter image description here

2

For me, working in flutter, the configuration was not automatically added due the existing configuration.

Adding #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig" to Flutter/Release.xcconfig and Flutter/Debug.xcconfig

solved the issue.

2

Be sure the pod configuration files are set.

enter image description here

0
1

When you do

pod install --verbose

make sure:

1- you are in the correct directory. Most times, when a github project is downloaded, there will be a master folder. You need to be inside the actual project name folder(masterfolder/project folder) in the terminal before you invoke pod install --verbose

2- Delete the old pod lock folder then clean the project using xcode clean & do pod install.

3- Keep your rvm updated.

1

My problem was the cocoa pods version so I installed the latest with: sudo gem install cocoapods --pre Then pod update

That worked for me

1

If you are applying to the way Project Cleanup and your project still error.

You can go to tab Build Phases and then Find Check Pods Manifest.lock and remove the script.

Then type command to remove folder Pods like that rm -rf Pods

and then you need to remove Podfile.lock by command rm Podfile.lock

Probably, base on a situation you can remove file your_project_name.xcworkspace

Finally, you need the command to install Pod pod install --repo-update.

Hopefully, this solution comes up with you. Happy coding :)

1
  • @JVillella you should not remove that script from the build phase. See here . That script is there to make sure you're snapsho of all dependencies is in sync with the snapshot of your repo. Or perhaps after you remove it, it gets added again
    – mfaani
    Commented Jan 18, 2021 at 23:23
1

I had same error. First I update cocoapods using

sudo gem install cocoapods

then install pods using Pod install command worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.