Creating Two Applications From One Target - ios

Is there any way to create two iOS applications from one target and project in XCode?
I have searched for it and got no clear answer..

YES, each target is a different app. Just make additional targets, and they will have seperate build settings and plists.
You can use compiler flags to seperate them, similar to the DEBUG flag, using #if and #endif segments.

Related

Xcode 8 preprocessor Macros?

I am working with multiple targets in Xcode 8.2, Everything is good except handling files.
To import files, I have used different pch for each target but facing issues in using different class files.
How to work with other target files in the source, it throws an error on build app. When I try to add Preprocessor Macros in Build Settings but I can't find the Preprocessor Macros section in Xcode 8. Is there any alternative to this? please suggest some other approaches to handle different target files in the same source.
Thanks in Advance.
Select the target and go to build setting.
There search for "Preprocessor Macros" you will be able to find out.
Set the macros for particular target.
Use #ifdef in the code to check whether macros is defined or not, based on macros definition write the code for specific target.
That particular code will be reflected to that target only.

How to use targets to launch multiple apps using the same code base?

I have an iOS project and I want to have several apps in the store with the same code base, but slight changes in assets and some features enabled in an app and other features in another.
I read in some blogs I can do it using some deferent targets...
How Can I Do It?
You can use targets to set user defined properties, set different assets to each target and enable features in a target and disable them on another. I created a blog here with the details of this process. how to use targets to launch multiple

How can I reduce duplication across multiple Xcode targets?

I have an iOS app with multiple targets: Prod, Beta, Alpha. Each target has different icons, a different bundle ID, and different preprocessor macros.
Unfortunately, there's also a lot of duplication across the targets (URL schemes, build settings, etc.). It's a pain to have to make changes to this configuration in every target, and always worry that I missed a target.
Am I doing it wrong?
I was indeed doing it wrong.
I ended up merging targets and creating a Beta configuration, in addition to the existing Debug and Release configurations.

Build two similar apps from one project

I have a project for a iOS app and wan't to make two different apps from it. I want the apps to have different skins and want the two apps to connect to two different web services. So I want a base app project from which I can select which to build.
I essentially want to fork a project but don't want to maintain two projects
Also they have to be able to be installed on the same device at the same time.
Is there some sort of "good practice advice" on how to do this?
I would also be interested in a similar solution for android projects
A project with different targets will do:
They will allow you to set different Info.plist for each target (which allow you to set different bundle ID, allowing two apps installed at the same device).
It also allows you to set C flags for each target (which allows you to put conditional statements based on the flag in your codes)
You can have the lines that should be executed in the target, in this example the copy target, with ifdef macro:
#ifdef COPY_VER
//lines of code to be executed for the copy target
#else
//lines of code to be executed for the other target(s)
#endif

Creating an application with multiple targets in Windows Phone 7

Is there any way to create a project/application which will have multiple targets.Its same as how we create multiple targets for an iPhone application in XCode.Basically I have an app which has to be made for different targets, with almost all the similar functionalities but with little change.
You can use Configuration Manager to add additional configurations to the list of Debug and Release. Then for each configuration go to Project/Properties/Build/Conditional compilation symbols and add a symbol used with your configuration or target, eg. make it SILVERLIGHT;WINDOWS_PHONE;CUSTOMVERSION1
Then in your code you can say
#if CUSTOMVERSION1
Debug.WriteLine("This is a CUSTOMVERSION1");
#else
Debug.WriteLine("This is not CUSTOMVERSION1");
#endif
Otherwise - if you want to make bigger changes - you would create another project and link files from one project to another project - project/Add/Existing Item//Add As Link(an option in the "Add" button menu). You can then add more files or add different versions of these files as needed. You could use Project Linker to do it faster.

Resources