Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Embed different framework based on build configuration

I have 4 build configurations:

  • Debug
  • Release
  • WhiteLabelDebug
  • WhiteLabelRelease

Configurations

Debug and Release should link & embed my custom LightTheme.framework and not the WhiteLabelTheme.framework.

WhiteLabelDebug and WhiteLabelRelease should link and embed my custom WhiteLabelTheme.framework and not the LightTheme.framework.

Both of these frameworks have some custom code, localized strings, colors, fonts, and images. We use a different scheme to build each config and submit it to the App Store as a totally different app. However currently both our branded app, and the white label one have both sets of images, fonts, colors, strings, etc. Which really hurts file size.

I can easily weak link both frameworks into the app target, but I can't figure out how to only embed a framework based on the current configuration.

Embed Frameworks settings

like image 468
jamone Avatar asked Aug 01 '26 11:08

jamone


1 Answers

Go to your target Build Phases and add New Run Script Phase as the last step.

Here’s what the script could look like:

if [[ ${CONFIGURATION} == "WhiteLabelRelease" ]]; then
    rm -R "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/LightTheme.framework"
elif [[ ${CONFIGURATION} == "Release" ]]; then
    rm -R "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/WhiteLabelTheme.framework"
fi

When building any of your *Release builds (and Archiving for submission), the script will remove a corresponding framework. It will leave them in place when debugging.

like image 171
pointum Avatar answered Aug 02 '26 23:08

pointum



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!