Add files to an Xcode project from a script?

Viewed 38971

Right now I'm using a few scripts to generate files that I'm including as resources in Xcode. The thing is I'm running the script, then deleting from the project, then adding back into the project. There must be a way to automate this last step, so that the script can generate the files and automatically add them into the xcode project for me.

I'm using bash but any language examples would help.

Thanks, Andrew

8 Answers

If you already have the files somewhere on your system, relative to your source root, you can always add a "Copy Files" phase. This will allow you to specify a directory where your resources should be copied from.

You can combine this with the Build Script phase answer provided to you already. For instance, run a script to check out your assets from Subversion into a subdirectory of your project, and then follow that up with a Copy Files phase that copies from "$(SRCROOT)/Assets".

I found myself with a similar situation using Ionic Capacitor. What I was expecting was to include files on the "Copy Bundle Resources" bundle phase. What I found is that Ionic already packs you some inclusions and if you slip your files along this folders you get it included as well.

enter image description here

Do you see the App folder inclusion? It our entry point.

To include on it I add a script that do something like this:

cp -Rf ./includes/yourfolder/ ./ios/App/App/

I managed to solve the issue

"Code object is not signed at all"

that can be encountered during build upload to iTunes Connect in this way:

I didnot include the script to Bundle resources.

So the script (in this case Python file) is executed during build, (it does what it has to do) but it is not included in the bundle of the app.

How to do?

Open Build Phases, go to Copy Bundle Resources section, select the file and remove it with (-).

Related