Build phase that create a Plist and copy it in resource bundle
I've made a ruby script that generate a Plist from data in other format (This script is inside the xcode's project folder).
I've made a custom run script build phase that call my script:
echo "Running xls Plister"
cd ${PROJECT_DIR}/plistr
ruby plistr.rb
scriptExitStatus=$?
echo "DONE with script: (exitStatus=${scriptExitStatus})"开发者_开发技巧
exit "${scriptExitStatus}"
This script output the plist in the following folder ${PROJECT_DIR}/plistr/output/data.plist
What I can't figure out is how to copy this in the Bundle resource so i can access it with something like this:
[[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"];
EDIT: my actual workaround is to run the script as first build step and manually add the reference to the generated plist in "Copy Bundle Resources"
You can copy a file to the bundle this way:
cp /tmp/foo.txt ${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app
Please notice, copying the info.plist to the bundle is not recommended, it will also produce a warning if copied with the Copy Bundle Resources build phase.
Look at this official statement.
精彩评论