Reputation: 2621
I want to use the same code for different target in Xcode. I am able to create the target using the Duplicate method and then I am able to change scheme name as well.
Now the real scenario comes, I want to be use my code in centralised way like for new target, I don't want to copy and paste the Main.storyboard and xib as well, so, ideally what would happen, if I would change anything in one place, all target would share that.But the issue comes, that ``ViewControllerin
Main.Storyboard` holds the master project "module" so, when I run the child target, it could not run.
Upvotes: 7
Views: 6370
Reputation: 79726
Of-course you can do it. you can use single code/file for multiple target and/or single target, according to your requirement.
Have a look at these snapshots:
For existing file in your project follow these steps to assign multiple targets
Select your file ▶ Utilities window ▶ File Inspector ▶ Target Membership ▶ Select target according to your requirement for source file usage
Create new file with multiple targets
Menu >> New File >> Select File Type >> Assign File Name >> Next >> Select targets for your file.
Upvotes: 5
Reputation: 409
Have you tried removing the Module and select Inherit From Target
instead?
Upvotes: 0
Reputation: 1245
You can open Utilities panel, select File inspector tab and mark necessary targets for every file you want to share.
See attached image as a reference.
Upvotes: 5