Can Xcode include application resource files that are generated during the build process?

落花浮王杯 提交于 2019-12-09 23:22:21

问题


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?


回答1:


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.




回答2:


This is the path i use for output:

${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}

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?



来源:https://stackoverflow.com/questions/2267760/can-xcode-include-application-resource-files-that-are-generated-during-the-build

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!