Cocoapods: `pod install` rewrites entire project.pbxproj file

Created on 30 Dec 2013  ·  11Comments  ·  Source: CocoaPods/CocoaPods

Recently running a pod install will cause huge changes to happen to my project file. The project is really old (3-4 years) and we've made lots of changes to settings that aren't preserved by the rewrite.

It looks like the problem is that our project file is in JSON format and cocoapods keeps trying to convert it back to XML.

Side note: not sure how/when our project was converted to JSON. If this is important I can investigate further.

Most helpful comment

Workaround for others trying to keep line change count down for code-review purposes:

Once 'pod install' is done doing its thing:

  1. Open your project in Xcode
  2. Make a change in Project Navigator (e.g. drag a file to a different position, and then back)

This will cause Xcode to rewrite the pbxproj file. Bonus: you will see what pod install actually changes! Observe, before:

~/dev/sosh/NinjaTurtle(lz-pod-update) $ git diff --stat -- Turtle4/Turtle4.xcodeproj/project.pbxproj
 Turtle4/Turtle4.xcodeproj/project.pbxproj | 22326 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 18475 insertions(+), 3851 deletions(-)

After:

~/dev/sosh/NinjaTurtle(lz-pod-update) $ git diff --stat -- Turtle4/Turtle4.xcodeproj/project.pbxproj
 Turtle4/Turtle4.xcodeproj/project.pbxproj | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

I was hoping there was a way for me to edit the faq with this workaround. If someone points me to a way to edit I will happily do so.

Thanks for the hard work CocoaPods team!

All 11 comments

We have an explanation of how and why this happens in the guides. Whilst there is discussion about making CP do partial changes to the xcodeproject it's unlikely to mitigate the actual issue WRT the format change.

Thanks, that explains it!

As of 0.24, cocoapods will use xcproj (if installed) to reformat the project file to the older JSON-esque format.

this happened again to me using 0.34.2

Workaround for others trying to keep line change count down for code-review purposes:

Once 'pod install' is done doing its thing:

  1. Open your project in Xcode
  2. Make a change in Project Navigator (e.g. drag a file to a different position, and then back)

This will cause Xcode to rewrite the pbxproj file. Bonus: you will see what pod install actually changes! Observe, before:

~/dev/sosh/NinjaTurtle(lz-pod-update) $ git diff --stat -- Turtle4/Turtle4.xcodeproj/project.pbxproj
 Turtle4/Turtle4.xcodeproj/project.pbxproj | 22326 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------
 1 file changed, 18475 insertions(+), 3851 deletions(-)

After:

~/dev/sosh/NinjaTurtle(lz-pod-update) $ git diff --stat -- Turtle4/Turtle4.xcodeproj/project.pbxproj
 Turtle4/Turtle4.xcodeproj/project.pbxproj | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

I was hoping there was a way for me to edit the faq with this workaround. If someone points me to a way to edit I will happily do so.

Thanks for the hard work CocoaPods team!

This should also be fixed in 0.36 negating the need to use xcproj entirely

I am still experiencing the issue, tried with 0.36.

@spiridonkopicl I hit this with a coworker, but on the Pods/Pods.xcodeproj/project.pbxproj, not our core project file. Is this what you're seeing?

@cbowns hi, sorry maybe my previous comments is pointing wrong. I will try to explain how I thought that this is related issue. In my project I added a new configuration, and run pod install (0.35) on whole project. pbxproj is rewritten.. This: https://issues.jenkins-ci.org/browse/JENKINS-26368 leads me to here, where is comment that 0.36 addressed this issue. So I updated to 0.36 and run again pod install but still jenkins issues exists. Do you have any suggestion how I can figure out is it still present, entire pbxproj is rewritten ?

I also still see Pods/Pods.xcodeproj/project.pbxproj do a reorg on any update. I wouldn't mind except it muddles PRs.

--- a/Example/Pods/Pods.xcodeproj/project.pbxproj
+++ b/Example/Pods/Pods.xcodeproj/project.pbxproj
@@ -7,11103 +7,11103 @@

Also I'm running 0.36

we still have this problem w/ 0.38.2
I uninstall xcproj, but it still in ASCII format.
Our problem is whenever two person pod install/update independently, they will run into git confict in Pods/Pods.xcodeproj.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pronebird picture pronebird  ·  3Comments

k06a picture k06a  ·  3Comments

tlandsmancars picture tlandsmancars  ·  3Comments

luhui picture luhui  ·  3Comments

spencerkohan picture spencerkohan  ·  3Comments