Archive in Xcode 4.5 - No errors, but build cancelled
For me the carthage update
build phase was causing the issue.
Also check if you have any other build phases with scripts that modify files or code.
First: +1 on ConfusedNoob's answer, because that was the problem (which led me to numerous experiments and finally this solution.) If my answer helps you, +1 his, too, because his hint was huge!
(Also, see my other answer, below, that bypasses agvtool altogether. I eventually settled-in to using that in all my projects.)
I've been messing with it a bit and the only thing I've found that works reliably to solve it is to use agvtool as a pre-action in the appropriate scheme(s), rather than as a run-script in the build-phases.
- CMD-SHIFT-comma to edit schemes (XCode 6.x)
- Twiddle-open whichever scheme you want this on. I did it on
Run
andArchive
, but I probably only really need it on archive. - Select the "+" icon and "New run script action"
Add your agvtool script. If you care, mine is:
cd ${PROJECT_DIR} ; xcrun agvtool next-version -all
(NOTE: pre-actions don't naturally run in ${PROJECT_DIR}
, so you have to cd
.)
Close & save and that's it.
The problem is that agvtool modifies the project file (unnecessarily, since all the build numbers we care about are elsewhere), and modifying the project file causes the build to cancel.
+1 one on the question, too -- cripes, that was a tough one!
Do you have a custom Run Script that bumps the version with agvtool? I found this to cause this exact behavior. Almost 100% failure to archive, and common failure to build. Removing this fixed the issue for me.
Another technique is to skip agvtool
altogether. Just add this runtime script to the end of your build phases (after copy bundle resources.)
- Select your project
- Select build phases and +
- Add a new
Run Script
phase
- Enter the script
The script, for easy copy/paste:
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$INFOPLIST_FILE")
buildNumber=$(($buildNumber + 1))
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion $buildNumber" "$INFOPLIST_FILE"
Make sure your script runs after the copy-bundle phases of your build