0

I've got an app that's functional (in the app store). In the past, we only had one version of our app with one Target in Xcode. Our development cycle is getting a little more complex, so we want to have two Xcode targets: production and development. These two targets would have two different bundle identifiers so we can have the different versions running on the phone at the same time. This is a similar strategy to this: https://www.raywenderlich.com/68613/create-paid-lite-version-iphone-app

I've basically followed the raywenderlich instructions to duplicate my target and set a preprocessor macro. The only change so far is using a different icon.

The "Original" version of the app is the "production" version. The newly duplicated target is the "development" version.

I'm using a storyboard where the LaunchViewController is set as the Is Initial View Controller option.

In the AppDelegate, I have code that gets the root viewcontroller via window?.visibleViewController and sets some information on it:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]? = nil) -> Bool {
    // ...
    guard let launchVC = window?.visibleViewController as? LaunchViewController else {
        NSLog("visibleViewController is nil or not LaunchViewController")
        return
    }
    NSLog("calling startUserManagerAndLogin  - launch")
    launchVC.startUserManagerAndLogin()
    // ...
    return true
}

In the original (production) version of the app, everything continues to work fine. I see the following line in the console, and the app launches correctly:

... Visible View Controller: Optional(<MyApp.LaunchViewController: 0x7f84dea02a00>)

However in the development version of the app. I'm seeing the guard case fail. Here's what I see in the console:

... Visible View Controller: Optional(<UIViewController: 0x7fbd1e509570>)
... visibleViewController is nil or not LaunchViewController

The root view controller is different between the production and development targets. I don't see how the root view controller can be different between two targets unless I explicitly set that (which I didn't).

I checked the project files and the "General -> Deployment Info" is the same between the two targets. I also checked the storyboard, and there's nothing there that specifies different view controllers.

Any ideas what's going on or how I can fix it?

Thanks!

SuperDuperTango
  • 1,398
  • 1
  • 14
  • 32

1 Answers1

0

Gah! FFS I figured it out. Turns out there was another log line that I missed that said:

... Unknown class _TtC8MyApp20LaunchViewController in Interface Builder file.

I found this out because I tried instantiating my LaunchViewController by hand (from the storyboard) and got this error as well. I figured out that the module was wrong.

I then found the SO question: XCODE 7.1 Swift 2 Unknown class in Interface Builder file which helped me find that there were some old storyboard elements that didn't have Inherit Module From Target selected. I toggled the checkbox to on, and now it's working. Phew.

enter image description here

SuperDuperTango
  • 1,398
  • 1
  • 14
  • 32