![](/img/trans.png)
[英]The Copy Bundle Resources build phase contains this target's Info.plist file 'Info.plist' in xcode 6?
[英]Writing to build directory info.plist using Xcode's "New Build System"
在使用“新构建系统”之前,我们有一个像这样的构建阶段脚本:
infoplist="$BUILT_PRODUCTS_DIR/$INFOPLIST_PATH"
builddate=`date`
/usr/libexec/PlistBuddy -c "Set :BuildDateString $builddate" "${infoplist}"
这种在运行时写入 plist 的方式的要点,而不会弄脏项目并且不必隐藏更改。 在使用“旧版构建系统”时,这仍然可以很好地工作。
在“新构建系统”上,此脚本不起作用。 目录变量和写入 plist 将起作用,但更改以某种方式被覆盖。
有没有办法通过构建阶段脚本写入构建的 plist? 如果没有,有没有办法实现仅在应用程序运行时写入信息而不弄脏本地存储库的目标。
正如@rpstw 指出的那样,任何自定义构建步骤都将在新构建系统的Process .../Info.plist
步骤之前运行。
Product > Scheme > Edit Scheme... > Build > Post-actions
如果您要引用任何构建系统环境变量(例如BUILT_PRODUCTS_DIR
或INFOPLIST_PATH
),请确保从选择中更改提供构建设置。
添加您的 shell 脚本,但请记住,如果您编辑应用程序包中的任何文件(即Info.plist
),您将需要重新签署应用程序。 将此添加到您的后期构建步骤:
export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
/usr/bin/codesign --force --sign - --entitlements "${TARGET_TEMP_DIR}/${FULL_PRODUCT_NAME}.xcent" --timestamp=none "${CODESIGNING_FOLDER_PATH}"
看起来有时,在“新构建系统”下, Process Info.plist
步骤毕竟是Run custom scripts
步骤。
所以我使用脚本在包中生成另一个custom.plist
#!/usr/bin/env ruby
require 'cfpropertylist'
require 'pathname'
build_info = {
'Time' => Time.now.to_s,
'CommitHash' => `git log --pretty="%h" | head -n1`.rstrip
}
plist = CFPropertyList::List.new
plist.value = CFPropertyList.guess(build_info)
plist_path = Pathname.new(ENV['BUILT_PRODUCTS_DIR']) / ENV['CONTENTS_FOLDER_PATH'] / 'build_info.plist'
plist.save(plist_path, CFPropertyList::List::FORMAT_XML)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.