If you have recently updated to new Xcode, you must have noticed the significant change in binary size. I saw it first when I was updating the
JXcore
's iOS binaries. (If you didn't hear before, JXcore runs node.js applications on Android and iOS.) Long story short, the new binary was almost 10 times bigger than the previous one.
Some of the problems you might be facing with;
- `strip` command is no longer reducing the binary size
- compiled binary is no longer Xcode 6.x compatible (especially the simulators)
- Whatever you did, the binary size is more than 2 times bigger than previous one
Following list of compiler tweaks helped me to solve the problems above. The final binary size was still 1.4x bigger though but this much is really reasonable comparing to my first result.
ENABLE_BITCODE - '-fembed-bitcode'
Starting with the Xcode 7, '-fembed-bitcode' is default during compilation. If you want to keep your framework compatible with Xcode 6.x version, do not use this setting when compiling simulator builds! It will be still working for Xcode 7 hence for the simulators yet it will be also compatible with Xcode 6 builds.
GCC_GENERATE_DEBUGGING_SYMBOLS - '-fno-standalone-debug'
Use (both) settings above for compilation step. These settings kick in before the LLVM bitcode is embedded. So, the binary won't be carrying the LLVM IR for debugging. Now you know the reason why 'strip' didn't help.
P.S. both `-fembed-bitcode` and `-fno-standalone-debug` are compile time options
Optimizing the binary size while preserving the compatibility took my last three hours. Hope the information above saves yours.
P.S. you still need `strip` if you were already using it
Some of the problems you might be facing with;
- `strip` command is no longer reducing the binary size
- compiled binary is no longer Xcode 6.x compatible (especially the simulators)
- Whatever you did, the binary size is more than 2 times bigger than previous one
Following list of compiler tweaks helped me to solve the problems above. The final binary size was still 1.4x bigger though but this much is really reasonable comparing to my first result.
ENABLE_BITCODE - '-fembed-bitcode'
Starting with the Xcode 7, '-fembed-bitcode' is default during compilation. If you want to keep your framework compatible with Xcode 6.x version, do not use this setting when compiling simulator builds! It will be still working for Xcode 7 hence for the simulators yet it will be also compatible with Xcode 6 builds.
GCC_GENERATE_DEBUGGING_SYMBOLS - '-fno-standalone-debug'
Use (both) settings above for compilation step. These settings kick in before the LLVM bitcode is embedded. So, the binary won't be carrying the LLVM IR for debugging. Now you know the reason why 'strip' didn't help.
P.S. both `-fembed-bitcode` and `-fno-standalone-debug` are compile time options
Optimizing the binary size while preserving the compatibility took my last three hours. Hope the information above saves yours.
P.S. you still need `strip` if you were already using it