xcodebuild workspace and scheme

29,002

You're almost there, but your syntax is a bit off. According to the man page:

xcodebuild -workspace workspacename -scheme schemename [-configuration configurationname] [-sdk [sdkfullpath | sdkname]] [buildaction ...] [setting=value ...] [-userdefault=value ...]

Where buildaction is one of the following:

buildaction ... Specify a build action (or actions) to perform on the target. Available build actions are:

       build       Build the target in the build root (SYMROOT).  This is the default build action.

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

       test        Test a scheme from the build root (SYMROOT).  This requires specifying a scheme.

       installsrc  Copy the source of the project to the source root (SRCROOT).

       install     Build the target and install it into the target's installation directory in the dis-
                   tribution root (DSTROOT).

       clean       Remove build products and intermediate files from the build root (SYMROOT).

In the Xcode IDE, you choose the buildaction to run through the Product menu, or by clicking and holding the round button on the top left of the IDE (Run = Play triangle, Test = wrench icon, etc).

Also, be careful to note where xcodebuild is looking for your build scheme - it can either be in your .xcproj OR your .xcworkspace file, depending on which one you created. (If you didn't manually create a workspace, you will have a .xcproj file).

You can also ascertain which schemes you have via your 'Manage Schemes' setting in Xcode.

Share:
29,002

Related videos on Youtube

Fergal Rooney
Author by

Fergal Rooney

Updated on August 23, 2020

Comments

  • Fergal Rooney
    Fergal Rooney over 3 years

    I am a little confused as to what happens with the xcodebuild command line tool when you specify a workspace and scheme.

    I understand how a configured scheme works in the XCode IDE GUI. The build action lists the targets to build and for each action (Analyze, Test, Run, Profile, Archive), you select which one you want the build action to execute for.

    So if I have each action (Analyze, Test, Run, Profile, Archive) selected in the build action for building, what happens when I execute the below command.

    xcodebuild clean install -workspace MyWorkspace.xcworkspace -scheme MyScheme 
    -configuration AdHoc SYMROOT=PATH DSTROOT=PATH...
    

    It searches for MyScheme.xcscheme in the main xcodeproj which has all this configuration specified when editing the scheme in XCode.

    What does xcodebuild read in from this file? Does it just build the configured target with the AdHoc configuration and disregard everything else?

  • Fergal Rooney
    Fergal Rooney over 7 years
    So if I specify build as the build action, it will look at the Scheme configured to get the build configuration such as Debug / Release?