问题描述
我制作了一个 ruby 脚本,它从其他格式的数据生成一个 Plist(这个脚本在 xcode 的项目文件夹中).
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}"
此脚本将 plist 输出到以下文件夹 ${PROJECT_DIR}/plistr/output/data.plist
This script output the plist in the following folder ${PROJECT_DIR}/plistr/output/data.plist
我不知道如何将其复制到 Bundle 资源中,以便我可以使用以下内容访问它:
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"];
我的实际解决方法是将脚本作为第一个构建步骤运行,并在复制捆绑资源"中手动添加对生成的 plist 的引用
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
请注意,不建议将 info.plist 复制到包中,如果在复制包资源构建阶段复制它也会产生警告.
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.
看看这个官方声明.
这篇关于创建 Plist 并将其复制到资源包中的构建阶段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!