I'm using Xcode 4.3.3 and have tried to configure my (one and only) scheme so that "Run" will build a release version (i.e. non-debug version) of my app for testing on the simulator and my device.
I attempt to do this as follows:
In the scheme editor window I highlight "Run" in the left column, and then for "Build Configuration" I select "Release". (I also set the debugger to "None").
However, when I build & run the application, the log navigator displays "Build MyApp1" followed by "Debug MyApp1".
My questions are: should this message displayed by the log navigator say "Release MyApp1" to reflect the build type I selected in the scheme editor? Or does "Debug" in this message just always get displayed when you choose "Run"? Is it in fact running the debug or release version?
Thanks,
BH
Go TO Edit Scheme, choose the type that you want.
In order to test whether your compiled file is running a debug version, you can try something like this in your home controller's viewWillAppear:
#ifdef DEBUG
NSLog(#"running debug version");
#else
NSLog(#"running another version");
#endif
If you're not getting the result you're expecting, you can try setting the release flag to YES and debug flag to NO in build settings.
I hope this helps :-)
Related
I have flag in other swift flags for debug so I can have macro in code for DEBUG. Will it trigger in ad-hoc ? How will work ad-hoc build ? As debug or release ?
The default is release but you can change this in the scheme editor
Watch your scheme details to see which configuration is used for the Archive stage (as I assume you're making the Ad-Hoc build from the archived product).
In the menu bar, navigate to Product > Scheme > Edit Schemeā¦ and switch to the one you're currently building if needed.
I am Code::Blocks 13.2 user in Ubuntu 14.04 LTS. How do I set the compiler options, such as compile under Debug or Release mode? I don't see the options readily on the GUI.
'Debug' mode and 'Release' mode are not compiler options. They are options in the
IDE for configuring the whole project (including the compiler options and
all other tool options) between debug mode and release mode.
In the tool bar beneath the top menu bar of the IDE you should see a drop-down menu
that has items Debug and Release for selecting the desired configuration.
See screenshot:-
What the various tool options will be in debug mode and release mode is up to you. The IDE has
sensible defaults. You can set them by navigating YourProject -> Build options
and selecting Debug or Release from the project tree-control of the left
before continuing. See Screenshot:-
To set up the compiler go to Settings->Compiler.
To set up your projects target settings (debug, release, etc...) right click on your project and go to build options.
You may also want to take a look at the over all project settings by also right clicking on the project and going to properties.
If your just editing files on their own you have to add them to a project first (otherwise why are you using an IDE in the first place?) by going to file->new->project
Settings ->Compiler->Global Compiler Settings->and there you can change your settings with flags or defines, and other options.
By default, to "run" my project in release mode, I need to edit the scheme's run settings to use "release" instead of debug.
To not have to edit the scheme each time I want to switch between debug and release mode, I created a new scheme which runs in release. But this is still tedious since I need to click on the relevant scheme if I want to switch.
Is there a way that I can automatically (build + run) in debug / release mode using only short cut keys ?
I don't wan't to profile! Because that launches instruments etc.
EDIT: To be clear - I'm always running on the device.
Debugging build: "Product" Menu => "Build For" => "Running" (shift-command-R)
Release build: "Product" Menu => "Build For" => "Profiling" (shift-command-I)
Run without building (whichever you just built): "Product" menu => "Perform Action" => "Run without building" (control-command-R)
The equivalent in XCode that you seek is the "schemes".
Right of the play/stop buttons, there a pretty handy scheme selector. You just need to create a scheme for debug and another for distribution.
In order to make a scheme for debug or distribution, simply go to the scheme configuration (either selecting "edit scheme..." or "new scheme...") and choose the correct build configuration under "Run -> Build Configuration":
Note: I have XCode 9.1, I don't know if this is valid for older versions.
There is one way that I use it for my projects.
In Xcode, go to the the project settings (project, not target) and add "beta" configuration to the list:
Then you need to create new scheme that will run project in "beta" configuration. To create scheme go here:
Name this scheme whatever you want. The you should edit settings for this scheme. To do this, tap here:
Select Archive tab where you can select Build configuration
Then you need to add a key Config with value $(CONFIGURATION) the projects info property list like this:
Then its just the matter what you need in code to do something specific to beta build:
let config = Bundle.main.object(forInfoDictionaryKey: "Config") as! String
if config == "Release" {
// app running in release configuration
}
else if config == "Beta" {
// app running in beta configuration
}
In XCode 7 you can switch between schemes using the shortcut: control-command-right/left bracket (select next scheme, select previous scheme). So I think creating two schemes is your best bet.
BTW, for everyone asking why one would do this - If you are writing a high performance piece of code you will find yourself constantly switching between release and debug mode for a lot of reasons. Release mode (especially in swift with whole module optimization on) takes forever to build and optimization changes stack traces, etc.
This doesn't seem to be going away.
Here's the problem - I choose Product > Profile in XCode. Instruments opens, asks what I'd like to track, I choose Time Profiler, and it opens, but won't let me start the task, stating the error
Target failed to run: Remote exception encountered: 'Failed to get task for pid 1461'".
The 1461 changes to something different every time.
In Xcode, I have my Profile scheme's build configuration set to "Debug". In the target's build settings I have Code Signing Identity set to iPhone Developer for everything right now. In the project's build settings I have the same.
How can I get rid of this error, so I can test my app?
EDIT: Turns out I had to delete the app from my phone, and I did Product > Clean along with restarting xcode too.
The solution for me was to make sure that my Profile scheme was using the "debug" and not "release" build configuration.
In Xcode 4 select Product/Edit Scheme from the top menu then click on the "profile" button on the left. On the "info" pane you will see a setting for Build Configuration- set that to "debug"
Thanks,
For others coming by this question:
For me, the solution from this question worked:
The solution for me was to make sure that my Profile scheme was using the "debug" and not "release" build configuration.
In Xcode 4 select Product/Edit Scheme from the top menu then click on the "profile" button on the left. On the "info" pane you will see a setting for Build Configuration- set that to "debug"
The icon in Xcode says "Build and Run". How do I change it to "Build and Debug"
I read that if you use "Build and Run" then it does extra work to optimize the code.
"I read that if you use "Build and Run" then it does extra work to optimize the code."
No - this is completely wrong - Release builds typically have optimisation enabled and Debug builds don't. This has nothing to do with how you run the program (i.e. Run vs Debug), it just depends on which configuration you are building.
Option-click the Build and Run button and you'll have the Build and Debug button until you option-click again to change it back to Build and Run.
You need to add breakpoints to your code to change the icon for debugging