Automatically build cocoa pods for Xcode Workspace - ios

Just wanted to know what is the best way/place to run pod install or pod update so that each time when I build the project in Xcode, the command runs automatically.
I tried with putting pod install in Xcode Project -> Scheme -> Pre-actions, but was not able to see any output. Is there any other better way?

Related

Xcode 10.2 Update issue Build system error -1: Unable to load contents of file list: input/output xcfilelist

After upgrading to Xcode 10.2 I am getting 2 errors
:-1: Unable to load contents of file list: 'xxxxx/Pods/Target Support
Files/Pods-xxxx/Pods-xxxxx-frameworks-Debug-input-files.xcfilelist'
(in target 'xxxxx')
:-1: Unable to load contents of file list: 'xxxxx/Pods/Target Support
Files/Pods-xxxxx/Pods-xxxxx-frameworks-Debug-output-files.xcfilelist'
(in target 'xxxxx')
I updated all my pod and changed build system to "Legacy Build System" but still getting the same build error
I struggled with this for several hours today and this is what finally worked for me:
sudo gem update cocoapods --pre
pod update
clean
build
From what I've read, this is an issue with the new build process that is enabled by default in Xcode 10.2 though I've not found the workaround clearly documented anywhere yet. There may be a more elegant solution than what I described.
delete 'Pods/', 'Podfile.lock', 'yourappname.xcworkspace'
pod deintegrate
pod install
it's work for me
I have encountered this problem every time, using the above method to solve, I do not know why, how to completely solve
To illustrate the answer of #nfranzmeier:
Go to your project:
Select the right target
Build Phases
Unfold [CP] Embed Pods Frameworks script phase
Remove the files under Input Files Lists and Output Files Lists sections by selecting each of them and clicking on the - button
And you're done!
None of the solutions above worked for me. What did the trick was:
Go to Xcode > Project > Info > Configurations
Set the values for Debug > Pods-XXX.debug and Release = Pods-XXX.release
This solved the issue for me on Xcode 12.0 beta
Just pod install fixes this.
You don't necessarily want to update your pods (especially if you have not locked in versions explicitly). We had this error after creating a new Scheme.
This solved my problem:
Open **Terminal**
1) run -> pod deintegrate
2) run -> pod install
In **Xcode**
3) Click Product Menu
4) Keep Pressing Option Button
5) Click Clean Build Folder
6) Run
This worked out for me:
cd ios && pod deintegrate
pod install
Then go ahead and rerun your project
I had changed the Run Configurations, from: Debug to DEV, but didn't change the Scheme:
On top left, select your project name, next to your device:
Then, select your project and click "Edit"
Last, change from Debug to your desired "Run configuration", in my case was DEV:
Do that, for every single one in the list on the left, but for Profile, leave that one as Release or your equivalent:
You can just edit your xxxx.xcodeproj/project.pbxproj file and delete the offending lines xxxinput-files.xcfilelist and xxxoutput-files.xcfilelist from the inputFileListPaths() outputFileListPaths() so they're empty again and then save it and rebuild
In my case the error happened when archiving the app.
The cause was that the wrong build configuration was selected in the build scheme. This happened after introducing xcconfig-files for staging environment.
How i fixed it:
select the build scheme in Xcode (next to the "play" button)
select product -> scheme -> edit scheme
check if the correct build scheme is selected
see here:
For me, this was caused because I was setting up a custom configuration (.xcconfig) file for different environments.
I wasn't importing the Pods/Target Support Files/Pods-XXXXXX/Pods-XXXXXX.release.xcconfig into my configuration file.
This guide helped me find the missing step.
https://thoughtbot.com/blog/let-s-setup-your-ios-environments
Thanks Patrick.
In my case
-> pod deintegrate
-> pod clean
-> pod install
then rebuild the project works fine.
My XCode = 11.3.1
cd ios
rm Podfile.lock
edit Podfile as below
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'
>> Uncommented and bumped the version to 10
flutter clean
flutter pub get
pod repo update
pod update
For myself it works like that:
For example app name is "xyz"
click xyz(top) -> project(xyz)-> info -> configuration -> Debug -> xyz -> "Select Pods-xyz.debug"
xcode-13 or above
For me (using Mac Mojave) using the above solutions didn't work..
I manage to successfully overcome this issue by installing RVM on my Mac via:
curl -L https://get.rvm.io | bash -s stable --auto-dotfiles --autolibs=enable --rails
As described on this page.
And then re-install cocoapods via:
gem install cocoapods
And lastly run again:
pod install
I hope this helps someone who was stuck endlessly like me :)
I have the same issue and do the below steps and now am able to make build successful
go to Project->Configurations and set the valid configuration file for configuration.
if you see already set correct valid configuration file then do pod install
if you are not able see valid configuration file then pod install and Now you can see the valid configuration file just choose the right one now.
Note : I have this issue on Xcode 11.7
These are the steps that worked for me:
In the terminal, inside of project document, type:
pod update
If pod is not found, you should install Cocoapods:
sudo gem install cocoapods
If it returns a ruby/gem error, you should install (or reinstall) Ruby:
curl -L https://get.rvm.io | bash -s stable
rvm install ruby-2.7.2
sudo gem install cocoapods
Try to update pods again, and when it is finished, open .xcworkspace file.
I solve the cloud_firestore not found the issue as well by this after integrating a new version of that cloud_firestore.
(optional) update the podfile with the required version of cloud_firestore for fast compiling (saves 500k+ lines of execution).
delete 'Pods/', 'Podfile.lock', 'yourappname.xcworkspace'
pod deintegrate
pod install
If still have this problem and using flutter, you should open Runner Info Tab (in Xcode) set configuration file to None. then run pod deintegrate pod install.
I resolved this issue with....
Go to your Targets in xcode
Go to Build Phases
Next go to Run Script and check it has any files in input file lists or output file lists
Now, Remove files (input-files.xcfilelist / output-files.xcfilelist) using symbol - from Input file Lists and Output file Lists respectively
Try to go to your project directory.
Navigate to /ios
Remove Podfile.lock
Run project
Change build configuration from release mode to debug mode.

Error Build for Testing when run command pod install

I've a problem when I run "Build for Testing" on Xcode.
Step 0: In pod file using pod for target test as image below:
Step 1: Go to terminal and run command pod install.
Step 2: Go back to Xcode and touch tab bar Product -> Build for testing then the project warning error.
I trying to fix it 2 days. Unfortunately, my project still error. I appreciate kind of support me to solve it.
This happens because when you run pod install it changes the build configuration.
go to Project >> Build Settings search for architecture.
then make sure you have the same configuration for build active architectures only in both places
1. your project build configuration
2. pods project build configuration
If they differ your project will not build

Cocoapods error for one project target while others are working fine

I have create 3 project target (Development, Production and Staging).Expect Production other working fine after pull the changes of others while building the production target xcode giving the error :
gone through some of the available solution but no success!!!
If you change something the conflict will be occur, do like remove your WorkSpace once and again install or update your Pods,it will Work
Run pod install or pod update your CocoaPods installation.
For additional Information see this1
Choice-2
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:
Deleting the Podfile.lock file in your project folder
Deleting the Pods folder in your project folder
Execute pod install in your project folder
Do a Clean in Xcode
Rebuild your project
Conclusion: don't run pod install while project opened in the Xcode.
Update answer
I. Project Cleanup
In the project navigator, select your project
Select your target
Remove all libPods*.a in Linked Frameworks and Libraries
II. Update CocoaPods
Launch Terminal and go to your project directory.
Update CocoaPods using the command pod install
I have solved my problem by this way :
After implementing lot many solution i got this error :
By removing Check pods manifest.lock, Copy pods resources and Embed pods frameworks from Build Phases of Tests project target(xxxTests) i solved the issue.
NOTE: If any one still getting any issue related to pods, then try to remove libpods-xxx.a from Link Binary with libraries and again add it.

The sandbox is not in sync with the Podfile.lock-ios

I have got the following errors after trying multiple answers from the google.
PhaseScriptExecution Check\ Pods\ Manifest.lock /Users/apple/Library/Developer/Xcode/DerivedData/Build/Intermediates/FoodSpot.build/Debug-
iphonesimulator/FoodSpotTests.build/Script-36819C3C1B6A30F50091382D.sh
cd "/Users/apple/Downloads/FoodSpot 2"
/bin/sh -c /Users/apple/Library/Developer/Xcode/DerivedData/Build/Intermediates/FoodSpot.build/Debug-iphonesimulator/FoodSpotTests.build/Script-36819C3C1B6A30F50091382D.sh
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.
I have updated and installed many times, but they are of no use.
For me, the reason was missign User-Defined variables in the Build Settings!
Looking into the issue, the Build Phases tries to diff 2 files.
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
Just because of missing PODS_PODFILE_DIR_PATH and PODS_ROOT variables, assumes them as "" so ${PODS_PODFILE_DIR_PATH}/Podfile.lock points to /Podfile.lock and same for the other one.
So it fails in
diff /Podfile.lock and /Manifest.lock
I fixed this by adding 2 User-Defined settings to the Build Settings
PODS_ROOT = ${SRCROOT}/Pods
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
After hours of searching this is the only solution that worked for me
For me, it works after the following:
pod deintegrate --verbose
pod install --verbose
Run 'pod install' or update your CocoaPods installation.
You have answer in the error itself !
The error message states that you should update your CocoaPods installation.
You could remove libPods in frameworks and libraries and update Cocoapods using pod install.
Also:
clean and build the project
SO references :
CocoaPods Errors on Project Build
Error:"The sandbox is not in sync with the Podfile.lock..." after installing RestKit with cocoapods
I had been searching for hours and I found solutions as follow:
In my case, method 3 works.
Method 1:
choose the target > go to Build Phrases > click Link Binary With Libraries > remove all libPods.a files
open Terminal > direct to your project > run:
pod install
clean and build project
ref.1
Method 2:
open Terminal > direct to your project > run:
pod deintegrate --verbose
pod install --verbose
ref.2
Method 3:
choose the target > go to Build Settings > click "+" sign
add 2 User-Defined Settings: [to the left = to the right]
PODS_ROOT = ${SRCROOT}/Pods
and
PODS_PODFILE_DIR_PATH = ${SRCROOT}/
ref.3
Just go to Build phases and click on [CP]check Pods Manifest.lock.
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
Both PODS_PODFILE_DIR_PATH and POD_ROOT should define in user-Defined in build settings.
POD_ROOT should have correct path to Manifext.lock file and
POD_PODFILE_DIR_PATH should have correct path for Podfile.lock
So Add below in build settings.
PODS_ROOT ---- ${SRCROOT}/Pods
PODS_PODFILE_DIR_PATH ---- ${SRCROOT}
The problem is Podfile.lock and Manifest.lock cannot be found by the Check Pods Manifest.lock Script in your targets build phase.
This is usually caused by PODS_PODFILE_DIR_PATH and PODS_ROOT variables not being defined.
Go to build settings tab to define them.
You will need to look for Podfile.lock and Manifest.lock in your project and get the the full paths of their directories. The directory paths will be the values you use for PODS_PODFILE_DIR_PATH and PODS_ROOT.
Deleting the derived data did the trick for me . I deleted by going into the finder itself.
Make changes in the podfile as given below:
Older pod file
target :TargetName, :exclusive => true do
Changed pod file
target 'TargetName' do
I'm pretty sure that you have opened your Projects' workspace which you try to install new Pods. So try out the following (for me this worked):
Clean the project
Close the project
Run pod install
Open the project and try re-building it once more
Problem might have been resolved.
Edit
It turned out my issue was due to a new line at the end of the Manifest.lock that was not present in the PodFile.lock file. Running a diff on the two files highlighted the issue.
Adding a new line to the end of the PodFile.lock file solved it.
Original Answer
None of the answers have worked for me so I have just checked the "For install builds only" under "[CP] Check Pods Manifest. lock" which is found in the build phases tab.
I believe this setting means it will only run that check when archiving, allowing me to continue developing as I don't need to archive the app on my machine.
Use with caution though as it may not be the best solution for everyone.
This happens if cocoa pods don't install or uninstall properly
If you want to install cocoa pods run
pod install
if you you want to uninstall cocoa pods then run command
pod deintegrate
I had the same issue. Turned out the cocoapods version on Manifest.lock was higher than what I had on my mac. I had to do a 'sudo gem install cocoapods', to get the version of the cocoapods upto what was specified on the Manifest.lock file. This fixed the issue and I had no errors on building the project.
Im facing the same issue now and fixed using this command after navigating to project location in terminal.
pod install --repo-update
I fixed this by adding 2 User-Defined settings to the Build Settings
PODS_ROOT = ${SRCROOT}/Pods
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
In my case, I got same error after integrating my other targets. To solve problem I needed to add both targets in Podfile:
abstract_target 'myApp' do
use_frameworks!
pod 'Alamofire', '~> 3.0'
pod 'SwiftyJSON'
target 'myAppOtherTarget'
end
Make sure you add a "pod install" command line build step, before the Xcode Project build step.
The error is coming from the build phase run script in your Xcode project's target, which is unable to find Podfile.lock. This file is generated by CocoaPods, which must be installed in a build step in your TeamCity project.
My build steps look like:
Command line: bundle install --path .bundle (installs cocoapods local to the project using Gemfile).
Command line: bundle exec pod install --verbose (uses Podfile)
Command line: carthage update --platform iOS (uses Cartfile)
Xcode Project
Command line to build an archive
Command line to upload a build
Hope this helps.
In my case, the errors were occurring on a _Tests target. I didn't need the _Tests target, and so I deleted it. This resolved the error.
If you happen to move your Podfile like i did and face this issue, the solution discussed below may help -
Delete all of the following - Pods folder, xcworkspace
file, podlock file (skip the ones that are not available for subfolders)
delete all steps that has [cp] in it from the build phase tab
repeat step 1 & 2 for all the sub projects that you have in your workspace
open workspace, go into each project and delete framework for pods, and delete the pods folder from each project
close workspace
run pod install
you should now be able to open, build and run the project
I just fixed it by updating the Cocoapod, cause before the error there was log where the warning shows we need to upgrade our cocoapods as the pod files are not supported by the current cocoapod version, So clean the project , upgrade cocoapod then install pod.
1. Clean project
2. sudo gem install cocoapods/gem install cocoapods
3. pod install (optional if your project still shows error)
Note: I found this error for my flutter application in iOS platform
I think you are trying to use your old project pod folder in your current project, you have to copy Manifest.lock file of your current project and replace that file in your old project's pod folder which you added. Manifest.lock file location YourProject->Pods->Manifest.lock
Hope This was helpful. worked for me!
Please check Top Sites - Sandbox Sync iOS for more explanation. I fixed the issue by changing file paths from
diff "${PODS_PODFILE_DIR_PATH}/Podfile.lock" "${PODS_ROOT}/Manifest.lock" > /dev/null
to
diff "${SRCROOT}/Podfile.lock" "${SRCROOT}/Pods/Manifest.lock" > /dev/null
in Xocde -> "Open Your Project" -> "Select Your Project" -> "Select Your Target" -> Build Phases -> Check Pods Manifest.lock
If not, try changing paths as mentioned above, along with Legacy Build System. To change build system Xcode -> File -> Workspace Settings -> Build System -> Legacy Build System
I hate to say this, but I just removed the pods/ or didn't include them in the project and it built. I don't know if this will have a long-term effect on the project though.
This is presently my .sh build script for ionic5 for ios. It will probably change in the future.
# BUILDING FOR IOS
##################################
#
# MAKE SURE YOU UNPLUG ALL DEVICES!!!!!
#
##################################
ionic cordova platform remove ios
ionic cordova prepare ios
ionic cordova platform add ios
ionic cordova build ios --prod --release --buildFlag="-UseModernBuildSystem=0" --verbose
cd platforms
cd ios
open "MyApp.xcworkspace/"
cd ..
cd ..
It had be plaguing my project, so I thought I'd take them out. I am yet to deploy the project so far though... so who knows.
BigSur 11.1, XCode 12.4 (12D4e)

iOS project not seeing local changes when developing a Cocoapod project

I'm working on a framework that is available via Cocoapods.
I have my project set up using their suggested setup, and their development page says "You can work on the library from its folder on your system." but when I make changes to the files in the "Development Pods" folder and build my project, the changes do not show up.
I've tried running $ pod install on the project, which regenerates the xcworkspace file, but the changes still don't show up. I'm unsure how the changes are being missed, as I've commented out a large chunk of code and added a few NSLogs, but it still runs as if I never made the changes.
I've also tried cleaning the project via xcode.
Any ideas?
Bonus q: What is the correct way to work on a cocoapod framework? The documentation is rather lacking when it comes to setting up a project like this.
Edit: Here's the podfile:
platform :ios, "6.0"
pod "MyFramework", :path => "../"
(using an example name as the pod is't published yet)
The fix was to delete my xcworkspace [rm -rf MyFramework.xcworkspace] and recreate it via pod install.
The only difference I can see is that Pods is now included in the build targets for my demo app's scheme.
Here's the general process for developing a cocoapod.
Run pod lib create <Pod Name> to create your project.
cd MyDirectory
pod lib create MyPod
Make sure to run pod install inside your example project. This will generate a .xcworkspace file.
cd MyPod/Example
pod install
Open your example project via the .xcworkspace file.
Xcode -> File -> Open -> MyPod.xcworkspace
Edit your pod via Pods/Development Pods.
Project Navigator -> Pods -> Development Pods -> MyPod -> <file>
Clean, build, & run your example project.
Make sure to clean (cmd+shift+k) your project before running, otherwise changes made to your pod will not be captured.

Resources