Closed alkalim closed 6 years ago
Hi, could you PR? Maybe edit one of the example to be able to test it
could you PR?
Done!
Maybe edit one of the example to be able to test it
I have tested it with the following steps:
Compiled and run the original NatalieExample successfully
Duplicated target NatalieExample which failed to compile:
Applied the patch, compiled and run NatalieExampleCopy successfully.
The result Storyboards.swift changes look allright as well:
When you start fresh storyboard with one target the view controller definition in the storyboard looks like this:
Given that Inherit module from target option is on and you don't assign module explicitly. However when you define more targets and assign this storyboard to them at some point Xcode adds customModule attribute but leaves customModuleProvider="target" as is:
Apparently it goes unnoticed because customModuleProvider has a higher precedence over customModule and is just not used during class load if customModuleProvider="target" is specified.
However Natalie processes customModule attribute regardless of customModuleProvider which results in fully qualified class names. For example, if I have targets mytarget1 and mytarget2 and the storyboard "remembers" customModule="mytarget1" Natalie will generate the following code:
Which will not build for mytarget2.
I would propose to add a special case in ViewController.swift, property customClassWithModule : Change:
if let moduleName = self.customModule {
To:if let moduleName = self.customModule, customModuleProvider != "target" {