-1

why xcodebuild building the same application differently for scheme and target options?

xcodebuild -target uConnect build

Above commands builds with Release config in build folder inside project.

xcodebuild -scheme uConnect build 

Above builds with Debug config in Xcode’s DrivedData folder.

Wanted to understand what difference -target and -scheme options are making here?

As per my understanding it should always build the application in Release mode since we have selected Release at Project>>Info>>Configuration

use Release for command-line builds

Reference:

enter image description here

Screenshot of Scheme Details for reference

Maverick
  • 11
  • 1

2 Answers2

0

Try editing the scheme. You will see that it specifies the Debug configuration when building. It might look like this:

enter image description here

But, as you've said, when you build the target, you've specified the Release configuration.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • the screenshot you attached that is of "run" phase of a scheme, as you can see the command I am executing that's building the .app. Also you can see in question description that i am not passing any configuration while building the target or building using scheme. – Maverick Aug 11 '21 at 19:00
  • Yes but the scheme has to decide _somehow_ how it's going to treat a build. Think about it: in real life, you can build without running. How does _that_ work, you should ask yourself. – matt Aug 11 '21 at 19:12
  • On this point; I agree with you that Scheme has to decide "what to build" but again my question remains the same where? suppose I want to change build where we have -scheme to release from debug. As you can see other answer from @EmilioPelaez when I use -target option I can change the out put from release to debug using that drop down; he is talking about. – Maverick Aug 11 '21 at 19:56
  • I just verified what you said and you are correct. changing the configuration for Run phase (as per the screenshot you attached) to release from debug; indeed switch the .app to release from debug....... my thoughts are contrary to yours; we can build without running. running is quite different from building. building an application don't need it to be run. – Maverick Aug 11 '21 at 19:58
  • Look: you have to build according to build settings and that requires specifying a configuration. It really doesn't matter what you like or expect. – matt Aug 11 '21 at 20:16
  • I agree with you. All I am trying is align myself to the xcodebuild command's configuration and behaviour. Also, I think; I wasn't crystal clear with my previous comment... all i am saying "Thank You"... changing the Scheme "Run" phase configuration from Debug to Release (as per yours attached screenshot)... switches the build from Debug to Release... but Why "Run" phase even getting into play when I am "build" (command: "xcodebuild -scheme uConnect build"). – Maverick Aug 12 '21 at 06:53
0

A target describes a product that Xcode will build, like your app, the tests, an App Clip or an Extension. When using -target, it will use the configuration specified in the drop down at the bottom of your screenshot.

A scheme is a configuration that describes how a specific target will be built under different circumstances. If you go to the scheme editor, you'll see that you can choose which configuration to build when running, testing, profiling, analyzing, and archiving.

EmilioPelaez
  • 18,758
  • 6
  • 46
  • 50
  • @EmillioPelaez that for the explanation about "target" it makes sense to me now but still quite not clear about building using "scheme" why it's building .app in debug mode. updated screenshot of scheme for reference – Maverick Aug 11 '21 at 19:07
  • Did you go into the Scheme editor to see which Configuration was being used for the different kinds of build types? – EmilioPelaez Aug 11 '21 at 20:49
  • Thanks @EmilioPelaez; information you provided regarding -target and how to handle it's configuration; helps. got information about -scheme and it's configuration from @matt. changing the Scheme "Run" phase configuration from Debug to Release... switches the build from Debug to Release... but Why "Run" phase even getting into play when I am "build" (command: "xcodebuild -scheme uConnect build"). – Maverick Aug 12 '21 at 06:56