CocoaPods Errors on Project Build
Solution 1
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
Solution 2
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:
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:
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:
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:
Solution 3
Go to the target's Build Settings
and make sure the value of PODS_ROOT
equals ${SRCROOT}/Pods
in "User-Defined" section.
Solution 4
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)..
Solution 5
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:
- Drag this file into my Xcode Project in Xcode, choosing not to copy.
- Now there is a reference in our project, we can set the configurations:
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.
Related videos on Youtube
Undistraction
Updated on July 08, 2022Comments
-
Undistraction almost 2 years
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 aPods
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'
-
onmyway133 over 9 yearsA simple "pod install" fix this :)
-
Gelldur over 7 yearsImportant!
[!] From now on use MyProject.xcworkspace.
not te old `.xcodeproj' -
desigNerd almost 6 yearsWhen you test in an emulator there's just a white screen though
-
mfaani over 3 years
-
-
Hlung almost 11 yearsIf 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
andCopy Pods Resources
phases. And also removelibPods.a
in Link Binary with Libraries. -
abbood over 10 years@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! -
Undistraction over 10 years@abbood Write it up and I'll give you the win.
-
cbowns over 10 yearsThat's not what
Podfile.lock
is for: read Cocoapods' documentation on "Working with teams" for more information about it. -
abbood over 10 years@cbowns you are absolutely right, thanks for the comment. I updated my answer.
-
asgoth over 10 yearsMeans cocoapods is not installed properly. run
sudo gem install cocoapods
-
fresidue over 10 yearsWorked for me. Was annoyed. Now happy.
-
PatrickNLT about 10 years
gem install cocoapods
is even better. Most of the timesudo
shouldn't be necessary with gems. -
rharvey almost 10 yearsIn 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!
-
shaikh almost 10 yearsYour answer made my day. I was stuck in it for hours. hats off
-
Alex Ryan almost 10 yearsThis turned out to be it for me! My $PODS_ROOT was set incorrectly
-
Glogo almost 10 yearsAfter 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
-
The Camster over 9 yearsI had to reinstall cocoapods AND restart XCode to resolve this issue.
-
Echelon over 9 yearsHad to run
gem install cocoapods
and thenpod install
and just about everything else mentioned on this thread... -
rounak over 9 yearsThanks for this, it fixed the error. FWIW, I got the error after doing a
gem update cocoapods
-
Julian over 9 yearscool fix but I'm afraid after cleaning project and derived data you may notice why you need this :)
-
jowie over 9 yearsI deleted my xcworkspace file and did pod install, but I still get the same error message.
-
DanBlakemore over 9 yearsJust 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....
-
Nickolas over 9 yearsThe script seems to be generated by CocoaPod. Where did you put this script?
-
SleepsOnNewspapers about 9 yearsgives me a ld: library not found for -lPods-/*My Project Name*/Tests
-
SleepsOnNewspapers about 9 yearsalso will this give me errors on future pod installs?
-
Joseph DeCarlo almost 9 yearsDon't just arbitrarily remove your workspace - Even if your workspace was created by Cocoapods, it is maintained by you.
-
Charlie almost 9 yearsThis was the only thing that fixed it for me.
-
swebal almost 9 yearsFixed problem. Got error when performing "pod update"
-
Chiara over 8 yearsI'm glad I could help Charlie
-
Jonny over 8 yearsDid not help me. I removed the only pod I had installed by commenting it out, then pod install, then all error hell broke loose.
-
Leena over 8 yearsThis worked for me deleted every file related to pods and reinstalled pods.
-
pr4n over 8 yearsWorks great. This is what was needed.
-
Alix about 8 yearsI agree with you, I did all you did including removing workspace file and it did work for me.
-
xevser about 8 yearsWorked for me. Thank you.
-
Bandish Dave over 7 years@jowie same here... can you please guide me if you had solved it out.
-
coolcool1994 over 7 yearsThen I get ".h" file not found error from fileName that uses the Pod
-
Jacksonkr over 7 yearsI had to add
PODS_ROOT
to my target with this path and violá (I also added it toheader search paths
as "$(PODS_ROOT)" recursive -
Admin over 7 yearsI DID like yours. But i still get that same shitty error. What is this!!! nobody has a correct answer on this.
-
Admin over 7 yearsDid not WORKED For me.
-
Admin over 7 yearsThis is GOOD putting NONE helped.
-
Jayprakash Dubey over 7 years@YumYumYum : Then try to reinstall your pods.
-
Ankit Kargathra almost 7 yearsTried above all solutions but this one worked. In my case it remained to set path in a release.