根据构建配置嵌入不同的框架 [英] Embed different framework based on build configuration
问题描述
我有4种构建配置:
- 调试
- 发布
- WhiteLabelDebug
- WhiteLabelRelease
Debug
和Release
应该链接&嵌入我的自定义LightTheme.framework
而不是WhiteLabelTheme.framework
.
Debug
and Release
should link & embed my custom LightTheme.framework
and not the WhiteLabelTheme.framework
.
WhiteLabelDebug
和WhiteLabelRelease
应该链接并嵌入我的自定义WhiteLabelTheme.framework
而不是LightTheme.framework
.
WhiteLabelDebug
and WhiteLabelRelease
should link and embed my custom WhiteLabelTheme.framework
and not the LightTheme.framework
.
这两个框架都有一些自定义代码,本地化的字符串,颜色,字体和图像.我们使用不同的方案来构建每个配置,并将其作为完全不同的应用程序提交到App Store.但是,目前我们的品牌应用程序和带有白色标签的应用程序都有图像,字体,颜色,字符串等两组,这确实会损害文件的大小.
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.
推荐答案
转到目标构建阶段,并在最后一步中添加New Run Script Phase
.
Go to your target Build Phases and add New Run Script Phase
as the last step.
脚本如下所示:
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
在构建任何* Release版本(以及归档以供提交)时,脚本将删除相应的框架.调试时会将它们保留在适当的位置.
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.
这篇关于根据构建配置嵌入不同的框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!