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

21,796

Solution 1

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? :(

Solution 2

This seems to work for me:

xcodebuild -project TestApp.xcodeproj  -scheme TestApp -configuration "Ad Hoc" archive
Share:
21,796

Related videos on Youtube

Steven Fisher
Author by

Steven Fisher

Have been programming mobile (iOS and Android) full time since March 2009. I use SQLite a lot. Historical experience in many more languages and environments, especially C/C++ and Borland Pascal/Delphi. I have an infrequently updated blog and a Twitter feed that gets updated with any old thing that pops into my head.

Updated on July 09, 2022

Comments

  • Steven Fisher
    Steven Fisher almost 2 years

    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?

    • Taras Kalapun
      Taras Kalapun about 13 years
      Anyone knows how to start xcodebuild archive?
    • Steven Fisher
      Steven Fisher about 13 years
      Yeah, I'm calling it against a workspace not a project.
    • ljkyser
      ljkyser almost 13 years
      Are you able to build fine from within xcode?
    • Steven Fisher
      Steven Fisher almost 13 years
      Yes, it works fine within the IDE. But I want to automate my build.
    • RPM
      RPM almost 11 years
      Make sure the name of the scheme is exactly the same. my scheme was called "MyProject Ent" in Xcode and from command line I was calling "MyProjectEnt" and that was not correct. Edit this is "Manage Schemes"
    • Steven Fisher
      Steven Fisher almost 11 years
      It probably would have worked if you'd quoted it, too: -scheme "MyProject Ent"
  • Steven Fisher
    Steven Fisher almost 13 years
    Yeah, it works fine in the GUI. xcodebuild is the name of the command line component to do it. I'm clarifying this a bit in the question, thanks.
  • Steven Fisher
    Steven Fisher almost 13 years
    That's my forum thread. :) It seems like what I want isn't possible at this point.
  • Vincent Guerci
    Vincent Guerci almost 13 years
    Haha, I should have checked names! That is bogging me too, I love archives concept, and the simplification it brings for AppStore submission, but would love too to automate this in the beta stage! >_<
  • keegan3d
    keegan3d almost 12 years
    It seems to be broken again in 4.3.2: unsupported build action 'archive' :(
  • Vincent Guerci
    Vincent Guerci almost 12 years
    I've abandoned the idea of using this a long time ago... and use Xcode IDE to do this... man xcodebuild still mention archive as a valid buildaction... sounds like a bug... again.