'`xcodebuild` for scheme and target options

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



Solution 1:[1]

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.

Solution 2:[2]

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.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 matt
Solution 2 EmilioPelaez