CocoaPods Errors on Project Build

141,876

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:

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

Solution 3

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

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:

  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.

Share:
141,876

Related videos on Youtube

Undistraction
Author by

Undistraction

Updated on July 08, 2022

Comments

  • Undistraction
    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 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'
    
    • onmyway133
      onmyway133 over 9 years
      A simple "pod install" fix this :)
    • Gelldur
      Gelldur over 7 years
      Important! [!] From now on use MyProject.xcworkspace. not te old `.xcodeproj'
    • desigNerd
      desigNerd almost 6 years
      When you test in an emulator there's just a white screen though
    • mfaani
      mfaani over 3 years
  • Hlung
    Hlung almost 11 years
    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.
  • abbood
    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
    Undistraction over 10 years
    @abbood Write it up and I'll give you the win.
  • cbowns
    cbowns over 10 years
    That's not what Podfile.lock is for: read Cocoapods' documentation on "Working with teams" for more information about it.
  • abbood
    abbood over 10 years
    @cbowns you are absolutely right, thanks for the comment. I updated my answer.
  • asgoth
    asgoth over 10 years
    Means cocoapods is not installed properly. run sudo gem install cocoapods
  • fresidue
    fresidue over 10 years
    Worked for me. Was annoyed. Now happy.
  • PatrickNLT
    PatrickNLT about 10 years
    gem install cocoapods is even better. Most of the time sudo shouldn't be necessary with gems.
  • rharvey
    rharvey almost 10 years
    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!
  • shaikh
    shaikh almost 10 years
    Your answer made my day. I was stuck in it for hours. hats off
  • Alex Ryan
    Alex Ryan almost 10 years
    This turned out to be it for me! My $PODS_ROOT was set incorrectly
  • Glogo
    Glogo almost 10 years
    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
  • The Camster
    The Camster over 9 years
    I had to reinstall cocoapods AND restart XCode to resolve this issue.
  • Echelon
    Echelon over 9 years
    Had to run gem install cocoapods and then pod install and just about everything else mentioned on this thread...
  • rounak
    rounak over 9 years
    Thanks for this, it fixed the error. FWIW, I got the error after doing a gem update cocoapods
  • Julian
    Julian over 9 years
    cool fix but I'm afraid after cleaning project and derived data you may notice why you need this :)
  • jowie
    jowie over 9 years
    I deleted my xcworkspace file and did pod install, but I still get the same error message.
  • DanBlakemore
    DanBlakemore over 9 years
    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....
  • Nickolas
    Nickolas over 9 years
    The script seems to be generated by CocoaPod. Where did you put this script?
  • SleepsOnNewspapers
    SleepsOnNewspapers about 9 years
    gives me a ld: library not found for -lPods-/*My Project Name*/Tests
  • SleepsOnNewspapers
    SleepsOnNewspapers about 9 years
    also will this give me errors on future pod installs?
  • Joseph DeCarlo
    Joseph DeCarlo almost 9 years
    Don't just arbitrarily remove your workspace - Even if your workspace was created by Cocoapods, it is maintained by you.
  • Charlie
    Charlie almost 9 years
    This was the only thing that fixed it for me.
  • swebal
    swebal almost 9 years
    Fixed problem. Got error when performing "pod update"
  • Chiara
    Chiara over 8 years
    I'm glad I could help Charlie
  • Jonny
    Jonny over 8 years
    Did 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
    Leena over 8 years
    This worked for me deleted every file related to pods and reinstalled pods.
  • pr4n
    pr4n over 8 years
    Works great. This is what was needed.
  • Alix
    Alix about 8 years
    I agree with you, I did all you did including removing workspace file and it did work for me.
  • xevser
    xevser about 8 years
    Worked for me. Thank you.
  • Bandish Dave
    Bandish Dave over 7 years
    @jowie same here... can you please guide me if you had solved it out.
  • coolcool1994
    coolcool1994 over 7 years
    Then I get ".h" file not found error from fileName that uses the Pod
  • Jacksonkr
    Jacksonkr over 7 years
    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
  • Admin
    Admin over 7 years
    I DID like yours. But i still get that same shitty error. What is this!!! nobody has a correct answer on this.
  • Admin
    Admin over 7 years
    Did not WORKED For me.
  • Admin
    Admin over 7 years
    This is GOOD putting NONE helped.
  • Jayprakash Dubey
    Jayprakash Dubey over 7 years
    @YumYumYum : Then try to reinstall your pods.
  • Ankit Kargathra
    Ankit Kargathra almost 7 years
    Tried above all solutions but this one worked. In my case it remained to set path in a release.