Anyone who has developed a native application for iOS will have encountered the dreaded EXC BAD ACCESS error with zero information about what caused the crash.
NSZombies catches attempts to access deallocated objects (which are the primary causes of that error) by replacing the deallocated object with a zombie.
When a zombie is accessed a helpful message is logged to the console: message sent to deallocated instance
Take a read of Finding Memory Leaks for instructions on how to activate NSZombieEnabled on your Debug executable.
Make sure you only activate NSZombies on your Debug executable as you don't want to release an application that never frees memory.
Showing newest posts with label Build Configuration. Show older posts
Showing newest posts with label Build Configuration. Show older posts
Monday, 16 August 2010
Thursday, 12 February 2009
Using Xcode Targets for Adhoc iTunes Artwork
By creating multiple Xcode targets you can adjust what files are included in each target.
eg iTunesArtwork for adhoc users or testers
As the iTunesArtwork file only works for adhoc builds you want to exclude it from debug and release builds.
To create an Adhoc target which includes your iTunesArtwork file you need to:
- Create a new Adhoc target
- Add your iTunesArtwork file to your project
- Change the target memberships for your iTunesArtwork
Step by Step:
- Duplicate the primary target (right click -> Duplicate)
- Rename the new target to Adhoc
- Add your iTunesArtwork file to your project as described here
- Change the target memberships for your iTunesArtwork file to Adhoc only using:
Select Target -> right click -> Get Info -> Targets
(make sure only Adhoc is selected)
Once you've made these changes you can explore the Target build phases. The iTunesArtwork file should only appear in Copy Bundle Resources for the Adhoc target.
It may be useful to have matching targets and configurations for each type of build eg
- Debug
- Adhoc
- Release
When changing the build type set both the active configuration and active target.
Other uses for multiple targets include:
- Different icons for Debug / Adhoc / Release builds
- Incrementing build numbers only for Adhoc / Release builds
Labels:
Build Configuration,
iOS,
iPhone,
Xcode
Identifying the Current Xcode Configuration
The easiest way to identify the current configuration in code is by creating a preprocessor macro under your Xcode project build settings.
Step by step:
- Project menu -> Edit Project Settings -> Build tab
- Select All Configurations
- Scroll down to GCC 4.0 - Preprocessing
- Add the following to Preprocessor Macros Not Used in Precompiled Headers:
CONFIGURATION_$(CONFIGURATION)
Assuming you have Debug, Adhoc and Release configurations, this will generate preprocessor macros for each configuration. ie
- CONFIGURATION_Debug
- CONFIGURATION_Adhoc
- CONFIGURATION_Release
In your code you can now use something like:
#ifdef CONFIGURATION_Debug
NSLog(@"Debug message");
#endif
#if defined (CONFIGURATION_Debug) || defined (CONFIGURATION_Adhoc)
NSLog( @"Warning message");
#endif
Labels:
Build Configuration,
iOS,
iPhone,
Xcode
Subscribe to:
Posts (Atom)