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,

+3


source to share


3 answers


You can open the Utilities panel, select the File Inspector tab and mark the required targets for each file you want to split. See attached image for reference. target



+2


source


You can of course do this. you can use a single code / file for multiple target and / or single targets as per your requirement.

Apple document for the same

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



> Test

Create new file with multiple targets
Menu → New file → Select file type → Assign file name → Next → Select targets for your file.

x

0


source


Have you tried to remove the module and select instead Inherit From Target

?

enter image description here

0


source







All Articles