views:

223

answers:

1

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  A: 

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.

Jasarien
That makes sense. I'm looking at the Xcode variables for where to copy my files. Do I want to copy them into a build directory, so that it gets installed at the end of the build process, or do I go directly to the install destination?
zekel
Might as well copy them directly into the ${CONTENTS_FOLDER_PATH}/<wherever>
cdespinosa
Don't forget to add the generated files as the phase's Input Files, so that it depends on them, so that Xcode will not run the script until the files are ready to be copied. You may also want to add the copies' paths as the phase's Output Files.
Peter Hosey