2

I've got several file pairs:

mydata.json, mydata.raw other.json, other.raw etc...

A custom tool builds these files into data files to be consumed by my app, like so:

mydata.dat, other.dat, etc...

What is the correct way for me to set up Xcode to build these resource files? Either one could change, so I can't just set up a custom build rule for a .raw file, for example. I've thought about using an "external build" project using make, but I don't know how to register the results with Xcode to be copied as a resource.

1 Answer 1

2

You should be able to just add a Run Script build phase to your target in Xcode to run the external build tool and copy the resulting files into your app's bundle. Right-click on your target and choose Add > New Build Phase > New Run Script Build Phase.

You can use whatever scripting environment you prefer, just specify its path in the "Shell" field. For a bash script, you'd specify /bin/bash, for example.

You can then use the predefined Xcode environment variables to get the location of the various folders in the built package. Have a look at the Xcode Build Setting Reference for details. For example, the Resources folder in the app bundle is at ${UNLOCALIZED_RESOURCES_FOLDER_PATH}.

Sign up to request clarification or add additional context in comments.

1 Comment

Ok, good answer (and thanks for the link!). I see that having a separate Run Shell Script target leaves the ${UNLOCALIZED_RESOURCES_FOLDER_PATH} variable undefined, so I definitely need to do this within the primary target's Run Script phase. I'll worry about how to localize these files if I ever need to cross that bridge. ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.