truebit / xUnique

merge Xcode project file is so easy
https://fclef.wordpress.com
Other
1.5k stars 118 forks source link

Project Breaks randomly #31

Closed cepages closed 8 years ago

cepages commented 8 years ago

Hi,

I added an script in the Build Phases in my target with

xunique -v "${PROJECT_FILE_PATH}/project.pbxproj"
xunique -v "${PODS_ROOT}/Pods.xcodeproj"

And sometimes when I build my project the script breaks the project.pbxproj file and a project.pbxproj.ubak file is created

I had the same problem adding the script in the schema.

I'm using XCode 7.2. and I have multiple targets but I apply this to just one target

This is how the file ends

        F3FE3CE444355D7C8F3FB00833AA7C5D /* EPListOfRemindersViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EPListOfRemindersViewController.h; sourceTree = "<group>"; };
        F44FDADA43DF9BF202AC1C0C63C1D58A /* EPSettings.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EPSettings.m; sourceTree = "<group>"; };
        F4EAAEABEFD7861F9D264F81B2429DCF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/DCAccountProfileRegistrationViewController.xib; sourceTree = "<group>"; };
        F4FB62A7530350C8B45E5CF75A56FC1C /* EPBloodSugarMantle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EPBloodSugarMantle.h; sourceTree = "<group>"; };

Any idea where is the problem? or if there is a log where I can find why is breaking the project file?

Thanks

truebit commented 8 years ago

I do not think put it in Build Phases is a good idea, because the project is being built and you are trying to modify the project file. There could be some conflicts.

Try to put it in post build action like it described in README.

cepages commented 8 years ago

@truebit I tried in the post build action too and it broke the project too.

To be honest I just need to be pointed where I can find out what's breaking the project and why.

truebit commented 8 years ago

Because the project file is different for every project (especially after various merges in the repo, that would contain incorrect structure in the file).

You could execute xunique -d project.pbxproj in command line and paste your output here firstly.

cepages commented 8 years ago

mmmm weird I don't have such option:

Usage: xunique [-v][-u][-s][-c][-p] path/to/Project.xcodeproj
xunique: error: no such option: -d

But it seems upgraded:

pip install xUnique
Requirement already satisfied (use --upgrade to upgrade): xUnique in /Library/Python/2.7/site-packages
Cleaning up...
pip install --upgrade xUnique
Requirement already up-to-date: xUnique in /Library/Python/2.7/site-packages
Cleaning  @up...
truebit commented 8 years ago

Sorry, It should be -v instead of -d

cepages commented 8 years ago

Unfortunately the log seems ok

(xUniqueAvoidingMergeConflicts *+%)$: xunique -v ios/myProject.xcodeproj/project.pbxproj
Uniquify and Sort
uniquify PBXProject
uniquify PBX*Group and PBX*Reference*
uniquify XCConfigurationList
uniquify XCConfiguration
uniquify PBX*Target
uniquify XCConfiguration
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify PBX*Target
uniquify XCConfiguration
uniquify PBXTargetDependency
uniquify PBXContainerItemProxy
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify PBX*Target
uniquify XCConfiguration
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify PBX*Target
uniquify XCConfiguration
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify PBX*Target
uniquify XCConfiguration
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify PBX*Target
uniquify XCConfiguration
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify PBX*Target
uniquify XCConfiguration
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify PBX*Target
uniquify XCConfiguration
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
uniquify all kinds of PBX*BuildPhase
uniquify PBXBuildFile
Debug result json file has been written to '/Users/myUser/Documents/Projects/myProject/myProject-lib/ios/myProject.xcodeproj/debug_result.json
replace UUIDs and remove unused UUIDs
Ignore uniquify, no changes made to "/Users/myUser/Documents/Projects/myProject/myProject-lib/ios/myProject.xcodeproj/project.pbxproj
sort project.xpbproj file
Ignore sort, no changes made to "/Users/myUser/Documents/Projects/myProject/myProject-lib/ios/myProject.xcodeproj/project.pbxproj
Uniquify and Sort done

It's weird, it's really random, I run the command and sometimes it breaks the main project, sometimes the Pods project (even without the command pointing to the Pod project ) and sometimes (around 70% of the cases) nothing is broken.

truebit commented 8 years ago

Do you mean running the command xunique -v project.pbxproj in terminal would sometimes fail? If so, please post the error log when it fails, either in main project or cocoapods project. post the fail logs here

truebit commented 8 years ago

If it would fail only in xcode build process, you may need to change to use the commit hook method mentioned in README. maybe related to #24

cepages commented 8 years ago

It seems is working with the hook, but I will test it more, because it was random :)

Btw because I'm testing this in a different branch and I want just to be run in that branch I created this script ( in case someone want to do the same :) )

#!/bin/sh
NAME=$(git branch | grep '*' | sed 's/* //')
BRANCH_USE_XUNIQU="banch_to_use_XUNIQUE"
if [ $NAME == $BRANCH_USE_XUNIQU ]
then
    echo "Branch name $NAME : Warning xUnique is run"
    xunique -v ../ios/myProject.xcodeproj/project.pbxproj
    xunique -v ../ios/Pods/Pods.xcodeproj
else
     echo "Branch name $NAME : xUnique is not run"
fi

Thanks