jamone
jamone

Reputation: 17421

Embed different framework based on build configuration

I have 4 build configurations:

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

Upvotes: 7

Views: 2388

Answers (1)

pointum
pointum

Reputation: 3177

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.

Upvotes: 8

Related Questions