Bite-Sized Knowledge: Similar versions a Swift app, but one shared code base
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.
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.
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": so one would have APP_MAIN
and the other would have APP_LITE
.
And there you go. That's all you need.
For more information on what conditions you can use, have a look at https://docs.swift.org/swift-book/ReferenceManual/Statements.html#ID538.