Here’s a collection of tips and tricks for dealing with The Xcode Experience™ as your project management needs get complex; we’re quoting some parts particularly novel to us, but all of these are worth reading thoroughly!
Non-code assets for static libraries
There are occasions when static libraries require assets, e.g., images and sound files. Sub-projects and projects in the same workspace share a build directory and Xcode manages the build order of each project so that the main target is always built last. Because of this we can add build phases to our main project and sub-project which copy static library assets into the main bundle…
Improve performance by moving run time operations to compile time
To improve performance move expensive operations from run time to build time and cache the result. This can be achieved by creating an OS X ‘Command Line Tool’ target that runs as part of the bundles build process. Core Data can be used to store the data created at build time (Core Data is cross platform so a Core Data store that is created on OS X can be read by iOS)…
Custom Build Phases and Scripts
So one bug, that I manage to repeat just about every project, is errors with the constants that reference resources. I get the names of PNG files, tags and identifiers wrong all the time. Or I change the name in the resource, even something simple like capitalization. Fortunately with enough testing these errors come to light. But I’ve also solved this problem before. And in a way that uses the compiler to test for some form of correctness. The simple solution is to create a process that preprocesses the resources and creates a source file with all the constants.
But how to drive the preprocess? Xcode custom build phases and custom build scripts are nearly ideal for this type of work…
Easy Xcode Static Library Subprojects and Submodules
In which a method is presented for reliably building static libraries with subprojects in Xcode, and it is suggested that this method, combined with Git submodules or other similar mechanisms, provides the best way to share libraries, frameworks, or other code between projects…
Avoiding duplicate symbol issues when using common utilities within a static library
…Use the preprocessor to rename the symbols automatically during the build phase. This is done by adding a series of -DOldSymbol=NewSymbol flags to the ‘Other C Flags’ build setting – like -DTPCircularBuffer=ABCircularBuffer, for instance…
How exactly does __attribute__((constructor)) work?
1. It’s run when a shared library is loaded, typically during program startup… NOTE: Although this syntax is specific to GCC, LLVM and Clang have been written to support it as well, and code compiled using Clang-LLVM seems to work just like GCC-compiled code.
Slim down your iOS app by excluding files from production builds
…You won’t find this feature in Apple’s documentation. But it does exist in the form of a user-defined build setting called EXCLUDED_SOURCE_FILE_NAMES and it’s a really handy feature. I’ll use TestFlight in this example but you can use this approach to exclude any files from a build…
Open Source Project Providing An API For Manipulating Xcode Projects
…This project provides an API for editing Xcode projects. Through the API you can perform many different manipulations directly through code such as adding a file to a project, adding frameworks, and more…
And to finish up with one on working practices, for those of us still finding Xcode 4 gets in our way more often than Xcode 3 did:
How to make Xcode’s UI work for you (maybe)
(maybe) is a good way to put it, yes. But it is becoming less loathsome with some work setting up designated tabs, we’ll grant that much.
UPDATES:
Compiling Image Resources into a Static Library
OCLint: A static source code analysis tool for Objective-C and related languages
octo-online / Xcode-formatter is uncrustify for Xcode source formatting.
And so is UncrustifyX.
benoitsan / BBUncrustifyPlugin-Xcode uncrustifies the open file.
Injection for Xcode changes code at runtime!
garnett / AutoresizeMask-for-Xcode shows resize masks created in code
KSImageNamed: Xcode autocomplete for imageNamed
Tool: Xcode Plugin For Colorizing Debug Console Text For Easier Debugging
Deploymate – An essential Xcode companion for iOS developers
Creating an Xcode4 Plugin and Common Xcode4 Plugin Techniques
questbeat / Lin: “completion for NSLocalizedString and localizedStringForKey:value:table:”
brennanMKE / Xcode4CodeSnippets is a great collection of … snippets.
MAY