180

I'm unable to build a project that uses CocoaPods. I get the following 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.`

$ pod install seems to work fine and adds a Pods Project to my Workspace. I've tried $ pod update but this doesn't help.

It seems that PODS_ROOT is not being set.

Podfile:

platform :ios, '6.0'

workspace 'Example.xcworkspace'
xcodeproj 'example/Example.xcodeproj' 

pod 'TestFlightSDK', '~> 1.3.0-beta.5'
pod 'TestFlightLogger', '~> 0.0.2'
pod 'CocoaLumberjack', '~> 1.6.2'
pod 'Reachability', '~> 3.1.0'
pod 'SBJson', '~> 3.2'
pod 'MKMapViewZoom', '~> 1.0.0'
4
  • 3
    A simple "pod install" fix this :)
    – onmyway133
    Commented Oct 6, 2014 at 13:59
  • Important! [!] From now on use MyProject.xcworkspace. not te old `.xcodeproj'
    – Gelldur
    Commented Nov 30, 2016 at 11:12
  • When you test in an emulator there's just a white screen though
    – desigNerd
    Commented Sep 26, 2018 at 7:01
  • see stackoverflow.com/a/65783259/5175709
    – mfaani
    Commented Jan 18, 2021 at 23:40

30 Answers 30

172

I had a similar problem when I did major changes to my Podfile. My solution was to remove the workspace file and run pod install again:

rm -rf MyProject.xcworkspace
pod install
6
  • 17
    Means cocoapods is not installed properly. run sudo gem install cocoapods
    – asgoth
    Commented Oct 20, 2013 at 20:06
  • 4
    gem install cocoapods is even better. Most of the time sudo shouldn't be necessary with gems.
    – PatrickNLT
    Commented Jun 3, 2014 at 13:31
  • 5
    Your answer made my day. I was stuck in it for hours. hats off
    – shaikh
    Commented Jul 20, 2014 at 23:12
  • Thanks for this, it fixed the error. FWIW, I got the error after doing a gem update cocoapods
    – rounak
    Commented Nov 1, 2014 at 18:01
  • Fixed problem. Got error when performing "pod update"
    – swebal
    Commented Sep 11, 2015 at 12:17
69

TLDR: This is most likely a bug with Xcode and closing and reopening the project is usually the simplest fix. Assuming everything else is configured properly.


I occasionally get the same error when deleting the Pods directory and then running pod install.

Everything appears correct in the project info:

enter image description here

However, when I go to the target's User-Defined Build Settings, the PODS_ROOT entry is either entirely missing or is empty for one or more configurations. Which causes the following error on build:

enter image description here

The simplest fix is to close the project in Xcode and reopen it.

If you go to the target's Build Settings and filter on All, you will now see the PODS_ROOT entry with no errors:

enter image description here

It should now build with no errors.


Note: Even Cocoa Pods' official AFNetworking iOS Example has this problem, which leads me to believe that it is a bug with Xcode.

An alternative fix is to manually change the configuration to None, then back to its original value:

enter image description here

3
  • 1
    This turned out to be it for me! My $PODS_ROOT was set incorrectly
    – Alex Ryan
    Commented Aug 13, 2014 at 1:35
  • After long search for fix I was able to get it going without errors thanks to your solution. I just had to change Configurations to None and back to Pods
    – Glogo
    Commented Aug 25, 2014 at 21:13
  • This is GOOD putting NONE helped.
    – user285594
    Commented Feb 4, 2017 at 22:16
32

Go to the target's Build Settings and make sure the value of PODS_ROOT equals ${SRCROOT}/Pods in "User-Defined" section.

enter image description here

3
  • Works great. This is what was needed.
    – pr4n
    Commented Mar 9, 2016 at 10:10
  • I had to add PODS_ROOT to my target with this path and violá (I also added it to header search paths as "$(PODS_ROOT)" recursive
    – Jacksonkr
    Commented Jan 17, 2017 at 17:25
  • Did not WORKED For me.
    – user285594
    Commented Feb 4, 2017 at 22:03
30

update: a podfile.lock is necessary and should not be ignored by version control, it keeps track of the versions of libraries installed at a certain pod install. (It's similar to gemfile.lock and composer.lock for rails and php dependency management, respectively). To learn more please read the docs. Credit goes to cbowns.


In my case, what I did was that I was doing some house cleaning for my project (ie branching out the integration tests as a git submodule.. removing duplicate files etc).. and pushed the final result to a git remote repo.. all the clients who cloned my repo suffered from the above error. Inspired by Hlung's comment above, I realized that there were some dangling pod scripts that were attempting to run against some non-existent files. So I went to my target build phase, and deleted all the remaining phases that had anything to do with cocoa pods (and Hlung's comment he suggests deleting Copy Pods Manifest.lock and copy pod resources.. mine were named different maybe b/c I'm using Xcode 5.. the point being is to delete those dangling build phases)..

4
  • 1
    That's not what Podfile.lock is for: read Cocoapods' documentation on "Working with teams" for more information about it.
    – cbowns
    Commented Oct 11, 2013 at 1:37
  • @cbowns you are absolutely right, thanks for the comment. I updated my answer.
    – abbood
    Commented Oct 11, 2013 at 5:24
  • 12
    I deleted my xcworkspace file and did pod install, but I still get the same error message.
    – jowie
    Commented Dec 17, 2014 at 12:29
  • @jowie same here... can you please guide me if you had solved it out. Commented Oct 13, 2016 at 8:36
28

So it seems that CocoaPods didn't set the Configurations for my Project. They need to be based on the Pods.xcconfig which is found in the Pods/Target Support Files/Pods. To get this to work I had to do the following:

  1. Drag this file into my Xcode Project in Xcode, choosing not to copy.
  2. Now there is a reference in our project, we can set the configurations: enter image description here

I then had another build error which may or may not have been related. The path to the shell script defined in the Copy Pods Resources was incorrect.

"${SRCROOT}/Pods/Pods-resources.sh"

Resolved incorrectly. It seemed that SRCROOT was adding an extra dir that didn't exist into the path. So I hard coded the path to the Project folder.

This allowed me to build.

Why is it that so many things that are supposed to save you time end up eating it up?

Note: Please see @abood's answer for explanation.

4
  • 27
    If you see this error because you removed all pods from a target, you will no longer have any pod scripts but it will still try to run it. You'll have to go to your target Build Phase, and delete Copy Pods Manifest.lock and Copy Pods Resources phases. And also remove libPods.a in Link Binary with Libraries.
    – Hlung
    Commented Sep 18, 2013 at 4:55
  • @Hlung excellent comment.. it actually addresses the root cause of the problem, i tried the solutions above and i still ended up with a Podfile.lock (which most .gitignore files are configured to ignore.. and rightly so).. that file shouldn't stay lingering around.. If you wrote it up as an answer, i'd give you a +1!
    – abbood
    Commented Oct 8, 2013 at 6:58
  • @abbood Write it up and I'll give you the win. Commented Oct 8, 2013 at 7:28
  • Just wanted to add that this issue on CocoaPods' Github page mentions checking the build phases for probably this exact problem (even more similar since I have multiple targets). Issue caused me to scroll down here.... Commented Jan 21, 2015 at 0:36
22

I have a similar issue this is what worked:

  1. In Xcode:
    • Clean
    • Delete Derived Data in Xcode/Window/Organizer/Project/Your Project
    • Pod directory (it contains config files, delete files not just references!)
    • Removed all references to the pod config files for every target in Project/Configurations (debug/release)
    • Removed "Targets/Build Phases/Copy Pods Resources" from all Targets
    • Removed "Targets/Build Settings/User-Defined/PODS_ROOT" from all Targets
  2. Quit Xcode
  3. In your project directory:
    • rm -rf Pods
    • (Optional) rm -rf YourProject.xcworkspace
    • rm -rf Podfile.lock
  4. pod install
  5. Open YourProject.xcworkspace in Xcode
2
  • 4
    Don't just arbitrarily remove your workspace - Even if your workspace was created by Cocoapods, it is maintained by you. Commented Jul 29, 2015 at 1:11
  • This worked for me deleted every file related to pods and reinstalled pods.
    – Leena
    Commented Nov 23, 2015 at 5:25
15

I got rid of the same problem by doing following steps:

  • Xcode->Product->Clean Build Folder (hold alt key on Product to see it)
  • Open Xcode->Window->Organizer and select Projects tab. Then find your project and delete derived data of the project.
2
  • 1
    Worked for me. Was annoyed. Now happy.
    – fresidue
    Commented Jan 10, 2014 at 14:53
  • In my case I had trouble with a github project. So I had to completely remove the Project directory (rm -rf), did the above, then unzip the project, pod install and opened the xcworkspace and no errors!
    – rharvey
    Commented Jul 9, 2014 at 9:36
10

Simply resolved by doing the following:

  • (sudo) gem install cocoapods

  • pod install

  • clean and build

it seems the problem was caused by one of our team members having a more recent cocoapods gem installation.

2
  • 1
    I had to reinstall cocoapods AND restart XCode to resolve this issue. Commented Oct 16, 2014 at 2:10
  • Had to run gem install cocoapods and then pod install and just about everything else mentioned on this thread...
    – Echelon
    Commented Oct 30, 2014 at 12:24
9

  1. open .xcodeproj file in sublime text
  2. remove these two lines, if you have clean pods folders, i mean if you got the errors above after you removed pods folder
2
  • gives me a ld: library not found for -lPods-/*My Project Name*/Tests Commented Jun 17, 2015 at 22:23
  • also will this give me errors on future pod installs? Commented Jun 17, 2015 at 22:40
6

Had the same issue saying /Pods/Pods-resources.sh: No such file or directory even after files etc related to pods were removed.

Got rid of it by going to target->Build phases and then removing the build phase "Copy Pod Resources".

2
  • cool fix but I'm afraid after cleaning project and derived data you may notice why you need this :)
    – Julian
    Commented Nov 13, 2014 at 9:11
  • Then I get ".h" file not found error from fileName that uses the Pod Commented Nov 24, 2016 at 4:15
5

I had the same problem recently. I have tried every possible advice, nothing except this plugin has worked for me:

https://github.com/kylef/cocoapods-deintegrate

After the cleaning up of the current cocoapods integration, what's left to be deleted are Podfile, Podfile.lock and the .xcworkspace. Then just install all over again.

I hope I will help someone with this.

2
  • This was the only thing that fixed it for me.
    – Charlie
    Commented Sep 4, 2015 at 13:16
  • I'm glad I could help Charlie
    – Chiara
    Commented Oct 9, 2015 at 8:54
4

This issue got it solved.

  1. Select Target of your Project
  2. Select Build Settings
  3. Open User-Defined drop-down list
  4. Change value of key PODS_ROOT to ${SRCROOT}/Pods

Screenshot for above steps

3
  • 1
    I DID like yours. But i still get that same shitty error. What is this!!! nobody has a correct answer on this.
    – user285594
    Commented Feb 4, 2017 at 21:58
  • @YumYumYum : Then try to reinstall your pods. Commented Feb 6, 2017 at 10:10
  • Tried above all solutions but this one worked. In my case it remained to set path in a release. Commented Aug 17, 2017 at 17:08
3

I think it has a bug here.
For me, I delete Pods folder and Podfile.lock and do the pod install again to solve the problem.
This message is ignoring..:(

2

It wasn't very intuitive. I went to the base project settings and then I hardcoded paths to my pod.lock and pod.manifest under Check Pods Manifest.lock, because they stayed in different folders in fact, so my paths looked like this:

diff "/Users/admin/Desktop/Experimental/projectfolder/Podfile.lock" "/Users/admin/Desktop/Experimental/projectfolder/Pods/Manifest.lock" > /dev/null
if [[ $? != 0 ]] ; then
    cat << EOM
error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.
EOM
    exit 1
fi
1
  • The script seems to be generated by CocoaPod. Where did you put this script?
    – Nickolas
    Commented Jan 22, 2015 at 8:24
2

You can try the following. It fixed for me.

  1. install gem install cocoapods-deintegrate
  2. install gem install cocoapods-clean
  3. goto pod deintegrate
  4. pod clean
  5. pod install

The plugins will be remove from cocoapods for your project and will install freshly.

0
2

In my case, this was a test target that I removed all the pods from inside my podfile (because I added pods that I later realized I did not need in that target). None of the other solutions here worked for me.

  1. Go to the Build Phases tab in the project settings for the target that's causing trouble.

  2. Delete the section named "Check Pods Manifest" and "Copy Pods Resources"

  3. Inside "Link Binary With Libraries" remove libPods-YourTarget.a

  4. In your project settings in the Info tab expand "Configurations" and set the configuration for the target to None for both debug and release. (This will fix a couple of missing file warnings)

  5. Delete your project's derived data (Window > Projects > Delete [next to your project) and restart Xcode. Build / run target.

2

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
2

I had same problem with the my IONIC project, i tried above all solutions but not luck.

If you have same problem still, check weather below settings are present in Build Settings -> User-Defined settings or not

1.PODS_ROOT 2.PODS_PODFILE_DIR_PATH

If not present then add it,

PODS_ROOT = ${SRCROOT}/Pods

PODS_PODFILE_DIR_PATH = ${SRCROOT}/

It will solve problem, solution link

1

In my case the problem was in the wrong way. solution here http://guides.cocoapods.org/using/troubleshooting.html

If something doesn’t seem to work, first of all ensure that you are not completely overriding any options set from the Pods.xcconfig file in your project’s build settings. To add values to options from your project’s build settings, prepend the value list with $(inherited).

1

I had this issue.

The way I fixed it was by completely deleting the Pod implementing and re-implementing it. Make sure to delete "Copy Pods Resources" and "Check Pods Manifest.lock" from "Build Phases" on all targets as stated here: How to remove CocoaPods from a project?

1

For me to get rid of this error, I needed to delete the Pods directory and delete the Podfile.lock file.

1
  • I agree with you, I did all you did including removing workspace file and it did work for me.
    – Alok C
    Commented Apr 10, 2016 at 23:17
1

In my case I did put Podfile.lock & Manifest.lock in source control, but I forgot to add Pods-Project.debug(release).xcconfig files to source control (by mistakenly adding *.xcconfig to .gitignore), then I got the same compile errors with exactly the same reason, PODS_ROOT is not being set.

So if the goal is that after cloning the repo, the project can immediately build and run, without having CocoaPods installed on the machine, you either add entire Pods directory in source control or add Podfile.lock, Manifest.lock, project's xcconfig files and Pods xcconfig files to source control.

I didn't put the private .xcconfig that merges the build settings with the default CocoaPods configuration to source control.

1

After spending hours i found the solution go to "Build Phases" Then "Check Pods Manifest.lock" Tick "Run Script only when installing"

Thank me later ;)enter image description here

0

I have created multiple targets before I ever used pods. Later when I started to compile the other targets I had to add link_with with the list of targets in my Podfile.

0

I had the same issue. After retracing my recent steps, I found that adding a target declaration for a new target, followed by running pod install, was the cause of the problem:

enter image description here

Resetting my branch and cleaning my project did not work, since Cocoapods modified at least one file that is not under source control. I know this because once I reset the remote branch to a commit before adding the extra target, and re-cloned the repo, the problem no longer existed.

0

If you have a watchOS target: I found that suddenly, having pods in the watch extension but not in the watch target itself broke things with this same error. The solution was to add the pods to the watch target also.

0
gem install xcodeproj

may help you.

See pod install fails with abort - New Swift project.

0

if you added new target after creating Podfile, just delete Podfile, Podfile.lock , Pods folder and workspace then init pods ->then put your pods pod install

0

After trying the above, I realized I was getting an error on pod install

[!] CocoaPods did not set the base configuration of your project because your project already has a custom config set.

This was causing the error, because cocoapods was not adding the .xcconfig file to my project.

To solve this I went to the Info tab of my project. Set my Based on Configuration File to None for all schemes and targets. Then re-ran pod install

See this link for more information. Cocoapods Warning - CocoaPods did not set the base configuration of your project because because your project already has a custom config set

0

In my case, I accidentally typed an unnecessary dot at the end of the config file which caused this strange problem. Please make sure your config file does not contain any errors!

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