How to setup your project in Xcode to support multiple frameworks and sub-projects using XCCONFIGS?

If you have multiple targets use config files.
Screen Shot 2016-07-21 at 2.54.11 PM
This is the way to create them. Below is a sample of what you can specify in the config files.

ARCHS = arm64
CLANG_CXX_LANGUAGE_STANDARD = gnu++98
CLANG_CXX_LIBRARY = libstdc++
LD_NO_PIE = NO
OTHER_LDFLAGS = -Wl,-warn_compact_unwind
HEADER_SEARCH_PATHS = ../code/
FRAMEWORK_SEARCH_PATHS = ../debug

One of the things you can notice is that I am specifying that we only support 64bit architecture. You can also specify the framework and header search paths. This will enable you to easily edit the paths. Once you create the config files you need to set this config file to the configuration. This can be done as shown below –
Screen Shot 2016-07-21 at 3.02.11 PM.png
Go to your project -> Click on the configurations and assign the respective config files to that target. Once its done, the targets automatically read these config files. I prefer to have three config files.

  1. project config file – this will provide the generics
  2. debug config file – link to debug files
  3. release config file – link to release files

Next step will be go to your schemes. This can be done as shown below –
Screen Shot 2016-07-21 at 3.05.06 PM.png
Look closely. Uncheck the parallelize build option. If you have multiple frameworks to be built, its better to uncheck this else you will get into a race condition. You can also click on manage schemes button to manage your schemes, incase you want to share schemes between users.
Screen Shot 2016-07-21 at 3.06.35 PM
In case of multiple projects goto build phases and add the target dependency as show below.
Screen Shot 2016-07-21 at 3.08.30 PM.png
This will build the dependent project first and then proceed building yours.
Helpful xcodebuild commands:

  1. NATIVE_ARCH – The architecture on which the current build is taking place.
  2. CURRENT_ARCH – The architecture on which the current build is taking place and if the target is OSX.
  3. NATIVE_ARCH_ACTUAL -The architecture on which the current build is taking place and if the target is OSX.
  4. ARCHS – List of all the architectures.
  5. NATIVE_ARCH_32 _BIT
  6. NATIVE_ARCH_64_BIT
  7. OTHER_SWIFT_FLAGS
  8. GCC_ENABLE_OBJC_GC – Controls whether the project compiles Objective-C source with support for garbage collection.

I hope that gave you a pretty good idea on proceeding with multiple targets and sub projects.

Leave a Reply

Your email address will not be published. Required fields are marked *