![](/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.