Is there any way to use a script to add files to an Xcode target?
I’m not talking about build rules or phases here; I know about those. I have a project that requires about 3500 files to be imported into over 100 targets. I’d rather not do this by hand as said files are spread across a few directories and selecting them all by hand would take days to do.
The source code was originally from a makefile-based project that I’m converting to Xcode. I can hack up the makefiles easily enough to create lists of files in their relevant directories relative to $(SRCROOT) easily enough using some perl magic. What I don’t know is what to do with those lists.
It would be ideal if I could somehow run a script that read in the list, found the file inside Xcode (since the files will have already been added to the project as file references and folder groups), then added it to a single target that I could define. Just being able to do this would mean that the entire job of importing and configuring the sources for all the targets would take hours rather than days.
Is this possible to achieve somehow?
Many thanks in advance!
-KT
You have your work cut out for you.
Possibly as a last resort workaround…
When I looked at diff between same project after adding a file, it makes changes to
project.pbxproj fortunately in text.
If there is no other way, possibly post copying your files appropriately, you might be
able to parse/edit this file to reconstruct it…tricky YES, and likely unsupported.
I did find some additional info in this file by Dan Wright A brief look at the Xcode project format
and More on the Xcode project format
Seems the success of the approach will depend on being able to get PBXFileReference(s) for your files.
Good luck
Regards
JimZ