Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Archive in Xcode 4.5 - No errors, but build cancelled

Tags:

xcode

ios

xcode4

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'.

enter image description here

The build logs show no warnings or errors of any kind.

enter image description here

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.

like image 634
Mark Struzinski Avatar asked Jun 01 '13 04:06

Mark Struzinski


People also ask

Why is my build failing in Xcode?

Build operation failed without specifying any errors. Individual build tasks may have failed for unknown reasons. One possible cause is if there are too many (possibly zombie) processes; in this case, rebooting may fix the problem.

Do I need to build before archive Xcode?

Make sure your build is successful Before beginning to archive your build, you need to make sure that the build is successful not only for Debug, for also for Release.

How do I turn off archive in Xcode?

On the Xcode menu, select Product -> Edit Scheme... In the Build section, add the new target, then uncheck all the boxes except the one in the Archive column. This ensures the script will only be run on Archive. (See this question for an explanation and a nice screenshot.)


2 Answers

Xcode 13.2.1 - Super Simple

Put this in a pre or post action (inside the Edit Scheme dialogue). It will bump all version numbers inside your project.

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:

  • A lot of answers leave off the quotes around ${PROJECT_DIR} which prevents the change of directory to the project folder.
  • We can access agvtool directly, instead of using xcrun (at least when I have Xcode command line tools installed, I haven't tried this without them)
  • The new build system prevents archives from completing successfully when a build phase script uses agvtool to modify the project file.
like image 100
Trev14 Avatar answered Nov 15 '22 22:11

Trev14


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 and Archive, 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!

like image 41
Olie Avatar answered Nov 15 '22 21:11

Olie