Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

xcodebuild workspace and scheme

Tags:

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?

like image 882
Fergal Rooney Avatar asked May 09 '13 15:05

Fergal Rooney


People also ask

What is scheme in Xcodebuild?

An Xcode scheme defines a collection of targets to build, a configuration to use when building, and a collection of tests to execute.

What are swift schemes?

A scheme sets the targets to be built and the configuration to use. When you build in Xcode or run the app on a device, Xcode is building a scheme that specifies what target is to be built. You can see the active scheme in the Xcode toolbar: Building the project will use the active scheme, Emitron, as the blueprint.

Where is Xcodebuild running?

It seems that xcodebuild is located within /Applications/Xcode. app/Contents/Developer/usr/bin.


1 Answers

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.

like image 188
Jon Avatar answered Jan 06 '23 08:01

Jon