Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to copy and paste files in Compile Sources from one target to another?

I have a main target that have certain files included under its target -> Build Phases -> Compile Sources. I'm starting a unit test and would like the unit test to include the same files as the main target. Is there a way to copy and paste the files included in one target to another target?

like image 897
panupan Avatar asked Nov 30 '11 21:11

panupan


2 Answers

Yes, you can follow these steps:

  1. Select all Compile Sources on the main target.
  2. Right click on the selection and choose Reveal in Project Navigator (CMD + Shift + j). The files will be selected in the left pane.
  3. Select another target.
  4. Drag and drop the selected files from Project Navigator to Compile Sources of another target.

Xcode 9.2 Update:

It looks like in Xcode 9.2 you can select only up to 150 items at once to use Drag and drop. If you want to copy more items you can do it in batches.

like image 152
kowal Avatar answered Sep 18 '22 19:09

kowal


You can edit the PBXSourcesBuildPhase section in your ".pbxproj" file. You cand find the file by looking into your ".xcodeproj" file ( right click the project file + show package contents ). After you find the file look for "PBXSourcesBuildPhase". After you find the collection you can just copy/paste source files from one target to the others.

like image 20
filo Avatar answered Sep 21 '22 19:09

filo