I'm developing 2 different apps that share 95% of the same code and views. What is the best way to go about this using Xcode?
You can collaborate on Xcode or any other IDE as if you are in the same space.
Use targets. That's exactly what they are for.
Learn more about the concept of targets here.
Typically, the majority of projects have a single Target, which corresponds to one product/application. If you define multiple targets, you can:
For example you may define Precompiler Macros for one target and other macros for the other (let's say OTHER_C_FLAGS = -DPREMIUM
in target "PremiumVersion" and OTHER_C_FLAGS = -DLITE
to define the LITE
macro in the "LiteVersion" target) and then include similar code in your source:
-(IBAction)commonCodeToBothTargetsHere
{
...
}
-(void)doStuffOnlyAvailableForPremiumVersion
{
#if PREMIUM
// This code will only be compiled if the PREMIUM macro is defined
// namely only when you compile the "PremiumVersion" target
.... // do real stuff
#else
// This code will only be compiled if the PREMIUM macro is NOT defined
// namely when you compile the "LiteVersion" target
[[[[UIAlertView alloc] initWithTitle:@"Only for premium"
message:@"Sorry, this feature is reserved for premium users. Go buy the premium version on the AppStore!"
delegate:self
cancelButtonTitle:@"Doh!"
otherButtonTitles:@"Go buy it!",nil]
autorelease] show];
#endif
}
-(void)otherCommonCodeToBothTargetsHere
{
...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With