XCode 5: How to build Debug configuration only - xcode

It seems that XCode always builds both Debug anв Release configurations (see screenshot attached). I can't untoggle "Profile" option. I need to build Debug version only in 95% of my time. How can I save time by not building Release version every time I press "Build"?

By default, XCode practically always build for Debug, in Release XCode build only when you select from menu Archive or to Profile (shortcut cmd+I) and you see this because when selected you see XCode build your project.

The tab you selected just shows the target(s) (MagicCards1 here) that will be built for each action (Run, Profile, Archive...).
Only one build will be made with the appropriate build configuration (Debug, Release, ...) for any given action: your screenshot shows that the 'Debug' configuration will be used to build your target when you run your project, leading me to think that Xcode already does what you're expecting (and that it'll only compile the source files that changed since the last build).
You can try to compare Debug and Release builds made from scratch by cleaning (Shift+Cmd+K) and building (Cmd+R) with different build configurations in the scheme's Run settings.
You should also check if 'Build Active Architecture Only' is set to Yes and if 'Analyze during Build' is set to No in your Build Settings:
You may also want to watch this WWDC 2013 video: Xcode Core Concepts 401. Schemes are covered around the 44'-mark.
https://developer.apple.com/videos/wwdc/2013/?include=401#401

Related

Mac Catalyst build fails with "building for Mac Catalyst-x86_64 but attempting to link with file built for Mac Catalyst-arm64"

After updating to Xcode 12.2, my project started failing to compile because of Apple Silicon-related linking errors. I seem to have most of them fixed, but one sub-project that builds a statically-linked framework is giving me problems. And yet a sibling sub-project with apparently identical build settings doesn't.
During linking, I get this warning about the one framework:
ld: warning: ignoring file ...Build/Products/Debug-maccatalyst/TCSiOSC.framework/TCSiOSC, building for Mac Catalyst-x86_64 but attempting to link with file built for Mac Catalyst-arm64
I'm building on an Intel Mac, to boot (so "build active architecture only" is not a factor). I can't find any build setting that would address this problem, and a Web search turns up no hits on this exact error. Any ideas appreciated!
I consulted Apple for this one, and their engineer recommended some things:
Turn any Swift sub-projects into Swift packages, not embedded Xcode projects. So, I deleted one library's Xcode project from the parent project, and dragged its top-level directory into the parent project to include it as a Swift package. Now... this particular sub-project (SQLite.swift) already had a Swift package defined. I haven't generated a Swift package myself before, so I can't help with that. Also, don’t forget to add it to the Frameworks, Libraries, and Embedded Content list on the app’s target.
Go into your project's build settings and delete the "Supported platforms" setting. If you click on the "levels" button above the build-settings list, you can see where each setting is coming from. "Supported platforms" should be non-bold. Highlight the line and press Delete if it's bold. Then go into your target and do the same thing: delete "Supported platforms."
Set the Base SDK at your project (top) level to iOS; this is a must. Delete it from the target level, so it inherits from the project; I don't know if this holds true for multiple kinds of targets or all projects, but it's working for me.
Remove the VALID_ARCHS build setting from all targets, if it's present. That setting is deprecated.
The "build active architecture" setting doesn't make any difference after these changes in my case. The project now builds and runs under Catalyst just fine.
I have the same issue and found this question. In my case, building on Debug succeeds but on Release fails. The reason is exactly the "build active architecture only" option. It is an option can be found in your PROJECT - "Build Setting" Tab then "Architectures" section. There is a setting for "Build active architecture only". By default, the Debug mode it is Yes while Release mode it is no. That caused my build to fail in release.

What is the difference between Build and Build for Running in Xcode

Xcode has two options under the Product menu, one called Build (Cmd+B) and one called Build for Running (Shift+Cmd+R).
What's the difference here? I can't find anything in the Xcode docs.

Build Project in only Debug Configuration in a Solution

I have a VS2012 solution which has 10 projects.The solution is build by a script for all configurations. There is one project out of the ten that I want only to be build only if the solution is built in (debug,release Internal) configuration. How can I do it in VS2012?
Update 1: If we have a solution which has a project which is configured only for debug mode. If we built the solution in release mode, the project builds in debug mode. The point is, I don't want it to build at all if the solution is not currently build under debug/release_internal.
You can set this up using the configuration manager (accessible via the last item in the active solution configuration dropdown):
Then simply uncheck the relevant "Build" checkbox for all the projects you don't want to build in the given solution configuration/platform (don't forget to do this for each applicable combination of solution configurations/platforms):

When you select Product->Build (⌘B) in XCode, which version is built?

XCode has Build for Running/Testing/Profiling but also "Build". Does this build based on your last selection Run/Test/Profile, or does it default to one of them?
Xcode always uses the Run setup when building.
You can easily verify that it's not your latest selection: Choose "Build For Profiling", and you will see a Release-{platformname} folder in Build/Products within your derived data directory. Choose "Build" afterwards, and Xcode will not overwrite the Release-{platformname} directory but create another directory for Debug builds. This works under the assumption that you haven't changed the default schemes, which use Debug builds for the Run setup and Release builds for the Profile setup.
Likewise, you can change the Run setup to use the Release configuration, and when you simply build, you will see Release-{platformname} folders in the derived data directory.
The platform (name) is determined by your current selection:

Specifying a subproject's Configuration in Xcode

I have an Xcode project (A) referencing another project (B). By default (as far as I understand it) Xcode will implicitly build the configuration for the B dependency that matches the configuration of the A's target (e.g., "Debug"). But what if I want, say, A to build as "Debug" and the B to build as "Release"? How would I go about specifying that in Xcode?
I don't know of any easy approach, but you can brute-force it by calling xcodebuild directly for the dependency with a "Run Script" build phase.
I know it was just an example, but if your real goal is that the sub-project be a Release (no symbols) build, then you may have a better experience by just building the sub-project into a library or framework and checking the resulting binary into your version control system. Whenever I have a piece of the system that seldom changes and that I don't want debug symbols for, I go ahead and build it as a static library and check it in. I often go ahead and move the code elsewhere as well (with a README file with the .a that says where the code is and how it was built). This saves time on both build and checkout and is invaluable for large projects in my experience.
This might help: if the configuration of the project A is not found, Xcode will build Release config as a fallback (or maybe the first config of the list).
Then you can "force" the link using this tip: Xcode custom build configuration causes "library/file not found" for static libraries
Yes, this is not naturally supported by Xcode; when you build a target, it builds one configuration of itself and of all dependent targets.
The workaround, as Rob mentioned, is to have a dependent target that's an Aggregate Target type that comprises a single Run Script build phase, which simply invokes xcodebuild -configuration Release (or whatever).
You can specify the default 'fallback' configuration in the project info.
Change from:
Use 'Release' for command-line builds.
to:
Use 'Debug' for command-line builds.
And default will be 'Debug'.
Diffs of project file:

Resources