Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Archive with Xcode's command line build tool (xcodebuild archive)

Tags:

The command line tool to build Xcode projects, xcodebuild, has a new build action available in Xcode 4: archive.

From man xcodebuild:

       archive     Archive a scheme from the build root (SYMROOT).  This requires specifying                    a workspace and scheme. 

Unfortunately, when I try to use it I get an error:

$ xcodebuild archive -workspace SimpleTestApp.xcworkspace -scheme SimpleTestApp xcodebuild: error: Failed to build workspace SimpleTestApp with scheme SimpleTestApp.     Reason: The selected run destination is not valid for this action. 

My impression is this doesn't actually work yet. Has anyone got it to work? If so, how?

like image 475
Steven Fisher Avatar asked Mar 21 '11 23:03

Steven Fisher


People also ask

What does Xcodebuild archive do?

It archives your Xcode project by running the xcodebuild archive command and exports the archive into an . ipa file with the xcodebuild -exportArchive command. This . ipa file can be shared and installed on test devices, or uploaded to App Store Connect.

What is Xcodebuild command?

xcodebuild is a command-line tool that offers the ability to build and test your Xcode projects.

How do I build and archive in Xcode?

Navigate to your project's settings. Under iOS (or the target you want to build your app for) > Identity, you'll want to increment the Build number. For example, if the Build number was 1, you'll want to set it to 2. Then, in the top menu, under Product, click on Archive.


1 Answers

For information I'm 99% sure that xcodebuild archive was working in a previous Xcode 4 version, maybe a Beta... And this is really frustrating since -verbose and syslogs doesn't bring much details.

So I would call that... a Bug!

If automating your build is what you are looking for, there is a way to generate IPA archive from command line using xcrun PackageApplication

With xcrun to package and xcodebuild to build, you can almost achieve what xcodebuild archive is supposed to do. I would prefer to use xcodebuild since we can expect this to generate a .xcarchive (.app + .dSYM), more interesting than an IPA.

Not so off-topic, but if anyone knows how to get more logs from xcodebuild and Xcode, I'm really interested!

EDIT: After looking in Apple Forums, I confirm this is an Xcode BUG introduced with GM2... I guess Apple Xcode engineers are working on Xcode 4.1 that I think final version will be released with OSX Lion... In june maybe? With a fix? :(

like image 159
Vincent Guerci Avatar answered Sep 23 '22 00:09

Vincent Guerci