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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With