Xcode 可以包含在构建过程中生成的应用程序资源文件吗?
我有一堆通过 shell 脚本生成的 iPhone 应用程序内容文件。参与 Xcode 构建过程需要很长时间,因此我定期运行它。
我不想为了将它们包含在我的应用程序资源文件夹中而不断地将这些文件添加到我的 Xcode 项目中。有没有办法让 Xcode 在构建时将文件夹的内容复制到应用程序资源中? (如果我可以指定其他位置,例如 approot 文档文件夹,那就太好了。)
我尝试向我的目标添加一个新的“复制文件构建阶段”,但这似乎不起作用。这似乎是一个常见问题,但我在这里找不到任何相关信息。
-- 编辑(我做了什么)
根据 Jasarien 和 cdespinosa 的建议,我在构建脚本中执行了以下操作。我决定不复制到目的地,因为这只有在使用模拟器时才有效,我认为在部署到设备时这不会起作用。
cp -rf "$PROJECT_DIR/mystuff" "$CONFIGURATION_BUILD_DIR/$CONTENTS_FOLDER_PATH/"
-- 编辑 2
这似乎无法将文件传输到我的 iPhone 上。有什么想法吗?
I have a bunch of content files for my iPhone app that I generate via shell script. It takes way too long to be a part of the Xcode build process, so I run it periodically.
I don't want to have to continually add these files to my Xcode project in order to get them included my app resources folder. Is there a way to get Xcode to copy the contents of a folder into the app resources at build time? (It'd be a bonus if I could specify other locations, such as the approot documents folder.)
I tried adding a new 'Copy Files Build Phase' to my target, but that didn't seem to work. This seems like a common problem, but I couldn't find anything about it here.
-- Edit (What I did)
Per Jasarien and cdespinosa's suggestions, I did the following in a build script. I decided not to copy to the destination, because that would only work when using the simulator, I don't think that'll work when deploying to a device.
cp -rf "$PROJECT_DIR/mystuff" "$CONFIGURATION_BUILD_DIR/$CONTENTS_FOLDER_PATH/"
-- Edit 2
This doesn't appear to get files onto my iPhone. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在应用程序的目标中设置运行脚本构建阶段。编写脚本,以便将资源复制到应用程序包中。
You can setup a Run Script build phase in your app's target. Write the script so that it copies the resources into the app bundle.
这是我用于输出的路径:
只需将文件复制到该目录中,它就是捆绑包(模拟器或设备)。
您还可以在这里查看我的答案:如何使用可变输出文件列表设置 Xcode 构建规则?
This is the path i use for output:
Just copy your files in that directory, it's the bundle (simulator or device).
You can also take a look at my answer here : how to set up a Xcode build rule with a variable output file list?