每次构建项目时,如何强制 Xcode 重新构建项目中的 Info.plist 文件? [英] How do I force Xcode to rebuild the Info.plist file in my project every time I build the project?

查看:31
本文介绍了每次构建项目时,如何强制 Xcode 重新构建项目中的 Info.plist 文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

显然文件被缓存了,所以只有在它被改变时才会被构建.我将环境变量设置为增加我的版本号,等等,并独立于 plist 更新它们(实际上是在项目构建设置中).是否有一个脚本可以用作脚本构建阶段来强制 Info.plist 更新?其他方便的方法?

Apparently the file gets cached, so it only gets built when it gets changed. I have environment variables set to increment my version number though, and such, and update them independently of the plist (in the project build settings, actually). Is there a script that I can use as a script build phase that will force the Info.plist to update? Some other convenient way?

推荐答案

选择Edit Scheme",然后从左侧的控件中选择Build".

Select 'Edit Scheme', then select 'Build' from the control on the left.

然后,添加一个 Pre-actions 步骤,确保在Provide build settings from"下拉菜单中选择了有问题的方案,然后将其添加到下面的编辑窗口中:

Then, add a Pre-actions step, ensure the scheme in question is selected in the 'Provide build settings from' pulldown and then add this into the edit window below:

rm "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}"

这将删除 Info.plist 的缓存版本,导致每次点击构建时 XCode 都会重建它.

This will delete the cached version of Info.plist, causing XCode to rebuild it each time you hit build.

或者,如果您让 Xcode 预处理模板 Info.plist 文件,只需使用

Alternatively, if you let Xcode preprocess a template Info.plist file, simply touching the template with

touch ${PROJECT_DIR}/${INFOPLIST_FILE}

也能用.

调试前操作脚本

当您犯错时,操作前步骤不会提供任何信息.您可以通过将此行添加到脚本中来调试构建变量的使用

The pre-actions steps do not provide any information when you have made a mistake. You can debug the use of your build variables by adding this line to the script

echo "${CONFIGURATION_BUILD_DIR}/${INFOPLIST_PATH}" > ~/debug.txt

然后检查 ~/debug.txt 的内容以验证预操作脚本是否已运行并查看您是否使用了正确的路径.

Then check the content of ~/debug.txt to verify that the pre-action script has run and to see if you've used the correct path.

这篇关于每次构建项目时,如何强制 Xcode 重新构建项目中的 Info.plist 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆