Reputation: 33471
I've been building iOS apps for > 2 years and never encountered this problem. I am attempting to archive an app for beta distribution. The build succeeds, but at the very end of the process, Xcode reports 'Archive Cancelled'.
The build logs show no warnings or errors of any kind.
Sometimes, by cleaning/cleaning build folder/wiping derived data, I can get the archive to succeed, but there seems to be no pattern to it. Has anyone encountered this issue? I don't even have anything to go on as far as an error message in this case.
Upvotes: 12
Views: 5769
Reputation: 1
Just solved this issue by putting the script code into post actions in Build scheme.
Product -> Schemes -> Edit Scheme -> Build
Expand the build scheme and find Post actions there. Click "+" and add new run script.
Thats it.
Upvotes: 0
Reputation: 4116
You may have a version bump script throwing off the build process (as mentioned above). If that's the case, remove it and put this code below in a post build action (inside the Edit Scheme dialogue). It will bump all version numbers inside your project without causing the issue.
cd "${PROJECT_DIR}" ; agvtool bump
Here's my short blog post on the subject
After a ton of testing I realized a couple of things:
${PROJECT_DIR}
which prevents the change of directory to the project folder.agvtool
directly, instead of using xcrun
(at least when I have Xcode command line tools installed, I haven't tried this without them)Upvotes: 3
Reputation: 12446
I had the same problem. But I fixed it while still using avgtool
.
I was using a Build Phases
Run Script
not as the last step and used the following script which caused errors:
"${DEVELOPER_BIN_DIR}/agvtool" next-version -all
My solution was to use Build Phases
Run Script
as last phase and change the script to the folling
agvtool bump
Upvotes: 0
Reputation: 2300
In my case, I started getting this issue a lot after updating my XCode version. This is what I did to fix it:
Select "Legacy Build System" in the Build System tab.
The application should build without this issue after this if you are working on an older project and everything seems to get compiled.
Upvotes: -1
Reputation: 1371
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.
Upvotes: 1
Reputation: 24675
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.
Run
and Archive
, but I probably only really need it on archive.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!
Upvotes: 33
Reputation: 24675
Another technique is to skip agvtool
altogether. Just add this runtime script to the end of your build phases (after copy bundle resources.)
Run Script
phaseThe 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
Upvotes: 3
Reputation: 10186
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.
Upvotes: 59