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?
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”.
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.
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