If you have multiple targets use config files.
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 –
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.
- project config file – this will provide the generics
- debug config file – link to debug files
- release config file – link to release files
Next step will be go to your schemes. This can be done as shown below –
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.
In case of multiple projects goto build phases and add the target dependency as show below.
This will build the dependent project first and then proceed building yours.
Helpful xcodebuild commands:
- NATIVE_ARCH – The architecture on which the current build is taking place.
- CURRENT_ARCH – The architecture on which the current build is taking place and if the target is OSX.
- NATIVE_ARCH_ACTUAL -The architecture on which the current build is taking place and if the target is OSX.
- ARCHS – List of all the architectures.
- NATIVE_ARCH_32 _BIT
- NATIVE_ARCH_64_BIT
- OTHER_SWIFT_FLAGS
- 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