If you have an app that has slight variations, but is mostly the same, you could use a combination of multiple schemes and compilation conditions. For instance, you could have two apps with slightly different onboarding experiences, but for the most part they’re the same. Xcode build settings makes that possible.
If you look at your Build Settings there’s something called “Active Compilation Conditions”. Right there is essentially a build label you could use to conditionally include/exclude code once you do a build. These are essentially macros you could use in Xcode.
For instance, you could use #if
to push different views depending on the version of the app like so:
#if APP_MAIN
let fullVc = FullExperienceViewController.instantiate(coordinator: self)
navigationController.pushViewController(fullVc, animated: true)
#endif
#if APP_LITE
let liteVc = LiteExperienceViewController.instantiate(coordinator: self)
navigationController.pushViewController(liteVc, animated: true)
#endif
As I mentioned above, for each scheme you’d have their respective compilation labels under “Active Compilation Conditions” in Xcode: so one would have APP_MAIN
and the other would have APP_LITE
. And there you go. That’s all you need.
Hope these Xcode build settings help you avoid having to unnecessarily manage multiple repositories.
For more information on what conditions you can use, visit the Swift documentation.