How to include a file as a resource in Xcode programmatically during build?

I have a file created by a script that runs during the build phase. Therefore, the file does not exist until build time.

How to add a file to an application / project so that my code can access it at runtime?

I know what the file name will be.

Usually, if I created the file manually, I just dragged it into Xcode and I can immediately access it using the file name in the code. Since I create the file at build time, I want to know how to add it to my project.

EDIT: The file I am adding is an image file created by a script during the build phase. I want to have access to this file at runtime in my product.

+4
source share
2 answers

I ended up using assembly links.

+2
source

You can create a file and add it to the project, and then during the build phase, your script can replace the existing file with the generated one ...

Another option is to try to manipulate the project file itself, but it is quite difficult. Here are some related resources ...

+1
source

Source: https://habr.com/ru/post/1402811/


All Articles