Navigation depending on Xcode target

151 Views Asked by At

I have an app with an UITabBarController, the tabs navigate as usual, but one of the tabs should navigate to different view controllers depending on the project target, everything is laid out with storyboards.

Can not seem to find a way without doing some logic when loading one of the view controllers, and that seems ugly and unscalable.

Any advice is welcome.

1

There are 1 best solutions below

0
pixelrevision On

If you have separate plists for each target you can just add a custom variable that you read via the main bundle info dictionary

plist:

<key>NavigationType</key>
<string>Type1</string>

swift:

guard let navigationType = Bundle.main.infoDictionary?["NavigationType"] as? String else {
  fatalError("Could not find navigation type in the plist")
}
switch navigationType {
case "Type1":
    // do something
case "Type2":
    // do another thing
    ....