Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add file to all targets in Xcode when you have many targets?

Tags:

xcode

I have a project with over 50 targets and growing and it is becoming cumbersome to add files to all targets because it takes a long time to select each target.

I am aware of multiple methods to add a file to multiple targets but they all involve checking a box for each target. (for those looking for that: How to add .plist file to all targets in XCode?)

What I'm looking for is an alternative method or script that can be used to add a file or set of files to all targets in the project without selecting them one by one. Anyone know of a trick?

like image 497
BFar Avatar asked Dec 29 '16 01:12

BFar


People also ask

How do I add files to Xcode project?

Xcode offers several ways to add existing files and folders to your project: Drag the files from the Finder into the Project navigator. Click the Add button (+) in the Project navigator's filter bar, and choose Add Files to “projectName”. Choose File > Add Files to “projectName”.


1 Answers

Here is a link to GitHub repo. In the example project I have three targets, added file only in first target. When you run ruby ./addfile.rb from project's directory, the script will add img.jpg resource into two other targets (projex2, projex3). You need to install xcodeproj ruby gem before running the script. You should run sudo gem install xcodeproj in terminal.

like image 93
hsafarya Avatar answered Oct 14 '22 10:10

hsafarya