简体   繁体   中英

Why my project.pbxproj file changes its format

project.pbxproj is like json.But since I use the latest Xcode(7.3.1),it changes to plist.Here is my project.pbxproj :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>archiveVersion</key>
    <string>1</string>
    <key>classes</key>
    <dict/>
    <key>objectVersion</key>
    <string>46</string>
    <key>objects</key>
    <dict>
        <key>0047E8048E5EE8D208C0B009261D5816</key>
        <dict>
            <key>fileRef</key>
            <string>A1C5C2AA97A78115584DFC22517232F2</string>
            <key>isa</key>
            <string>PBXBuildFile</string>
        </dict>
        <key>008246B8B3F0ED1F2BCDAC8B0BF9CB2F</key>

The problem is I can't commit my project.And I get this error:

File 'project.pbxproj' is broken. Cannot find PBXProject name.

I'm using Xunique to avoid conflicts,maybe this will help.Please tell me how to deal with this.Many thanks!

@Lumialxk

I had a very similar thing occur yesterday. Similar in that my project.pbxproj file was in plist format, different in that I did not get a File 'project.pbxproj' is broken message. Instead, the issue surfaced for me via a merge conflict. Where the conflict was in the project.pbxproj file. There was one conflict and it was the entire contents of the file. In other words there were two versions of the file. One on my new branch where it was in plist format. And one on our base branch where it was in the normal JSON-like format. Either way, it sounds like the same thing you are seeing.

Important to note that both branches pre-merge worked with Xcode. Xcode didn't seem to have an issue with the plist formatted project.pbxproj file.

I solved the issue by doing a git reset --hard HEAD to throw away my attempted merge, this got me back to a point where I had a branch with a plist project.pbxproj file that I could build and run without issue. I then chose a random build setting (code signing), changed its value and then changed it back (ie I just "touched" it to force Xcode to modify it). I then built the project. And then re-opened the project.pbxproj file in a text editor. After having "touched" the file it was back in the normal format, no more plist format.

From there it was smooth sailing.

Credit goes to my co-worker for suggesting the "touch" approach.

I'm not sure what caused the issue. Here are some details about my setup:

I'm running Xcode 7.3 (so I don't think it had anything to do with 7.3.1). I recently upgraded from Cocoapods 0.39.0 to 1.0. I think this is the culprit. I ran into issues building some pods with 1.0 which I resolved by forcing the use of 0.39.0 like this:

pod _0.39.0_ install
pod _0.39.0_ update

Hope this helps!

Update: also added this note in xUnique README file

I am the author of xUnique :)

The solution is very simple, you do not need to downgrade Cocoacpods. just install xcproj :

brew install xcproj

Root cause:

Convert default ASCII pbxproj file to XML format is done by Cocoapods:

Every time CocoaPods creates the Pods.xcodeproj project (when running pod update) or alters your application xcodeproj project (on the first time when you pod install), CocoaPods generates the project using the XML PLIST format, whereas Xcode usually generates its xcodeproj files

Since CocoaPods 0.24.0 (see CHANGELOG.md, CocoaPods automatically converts the generated xcodeproj file to ASCII format if the xcproj is available in the PATH.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM