6

Right now I'm downloading all resources and adding the references via Xcode GUI. There must be a way to automate this last step, so that a script can copying the resources to the project-directory automatically and generate the references.

In some similar questions it means to build a "new 'run script' build phase to your project." But how is the code, that adds it in a subdirectory of my project.

2 Answers 2

1

I don't know of a tool that exists currently. I also had the need for adding files and folders programmatically to an xcode project file. It was rather involved, so I will describe the method and post a link to my project.

If you add just one file or one folder to the project file and look at the diff, you will discover that each file/folder has multiple entries in the project file that share a UUID. You have to generate a UUID and create entries in the respective subsections of the project file.

My use case was to measure if there are any differences in compilation time between projects that use swift and/or objective c files. This section of code manipulates the project file. It is quickly thrown together and won't win any awards for beauty.

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

Comments

1

To finish this question: I found a solution like this:

find -L "${SRCROOT}/Resources/InitData" -type f -not -name “.*” -not -name “`basename ${INFOPLIST_FILE}`” | xargs -t -I {} cp {} ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/;
find -L "${SRCROOT}/Resources/InitData/Images" -type f -not -name “.*” -not -name “`basename ${INFOPLIST_FILE}`” | xargs -t -I {} cp {} ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/;

Added this in the build section as an initial run script worked for me.

Comments

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.