moswald
moswald

Reputation: 11677

Compiling non-source files in Xcode

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.

Upvotes: 2

Views: 318

Answers (1)

Rob Keniger
Rob Keniger

Reputation: 46028

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}.

Upvotes: 2

Related Questions