Using the same code for different purposes in Xcode
I want to use the same code for different purposes in Xcode. I can create a target using the Duplicate method and then I can also change the name of the schema.
Now when a real scenario arises, I want my code to be centralized as for a new target, I don't want to copy and paste the Main.storyboard and the xib, so ideally what happens if I change something in one place, all goals will share this. But the problem is that 'ViewController in
Main.Storyboard` contains the main project module, so when I run the child target, it cannot work,
source to share
You can of course do this. you can use a single code / file for multiple target and / or single targets as per your requirement.
Take a look at these pictures:
For an existing file in your project, follow these steps to assign multiple targets
Select the file ▶ Utilities window ▶ File inspector ▶ Target audience Membership ▶ Select a target according to your requirement for source file use
Create new file with multiple targets
Menu → New file → Select file type → Assign file name → Next → Select targets for your file.
source to share