14

I have a project with three schemes, (Debug-MyApp, Beta-MyApp, MyApp). This project has three configurations (Debug, Beta, and AppStore). Moreover, each target builds their respective configurations. When I use a custom class in Interface Builder and use "Inherit module from target" (the default), it always picks Beta_MyApp module instead of whatever target I'm building (Usually Debug-MyApp). I verified this in the xibs/storyboards, since opening the file in Xcode causes the customModule property to be set to Beta-MyApp.

I have also tried setting both the Project and Target settings for Interface Builder Xib default module and Interface Builder Storyboard default module to Debug_MyApp.

The end result is that none of my custom classes render correctly; even though Designables says "Up to date" and "no interface builder errors occur".

My current workaround is explicitly setting all the modules to Debug_MyApp, and not using inherit module from target, which results in the views rendering correctly.

Has anyone experienced this / know how to remedy?

john
  • 23
  • 6
kiyoshi
  • 837
  • 1
  • 8
  • 20
  • I have the same experience. I have 2 targets, and only the main one (Release) will display it's `IBDesignables` properly. When I work using the Testing target, (which is all of the time), the `IBDesignables` turn up empty and everything is white. The default module is Release, which is wrong. It should inherit, but it doesn't. However, changing everything to Release manually results in the Testing build not working due to missing harcoded interface classes. Did you have any success? – Peterdk Sep 07 '18 at 15:25
  • I did test with XCode 10 beta, and suprisingly it seems to work properly now. I do get my views rendered. Maybe a idea to test? – Peterdk Sep 07 '18 at 15:35
  • Lol I have no idea how to fix it, I just can't run SwiftGen with multiple targets exactly because of this problem. Refs to https://github.com/SwiftGen/templates/issues/25 – atereshkov Sep 13 '18 at 12:14
  • This is an incredible mistake by Apple. The situation is even worse in 11.2.1 – Fattie Nov 22 '19 at 12:53

2 Answers2

5

Not sure what exactly helped since I did several things, but after last change I get no more issues with inheriting module from target.

  • changing Display Name for non-main targets to have a different name than main target
  • updating corresponding IBSC_MODULE (Default module) property for non-main targets in project.pbxproj file from e.g. "MyApp" to "Debug-MyApp"

It seems like when duplicating existing (main) target, Xcode did not update IBSC_MODULE property at all, so Interface Builder thinks that he operates with main target, not duplicated one. Error during runtime seems like reasonable one from that perspective.

vedrano
  • 2,961
  • 1
  • 28
  • 25
4

There appears to be an epic, blockbuster bug in 11.2 onwards...

If you happen to change the Display Name, yes the Display Name, at any point...

the entire logic of the project in terms of the targets seems to be totally fouled from that point onwards.

"Inherit Module from Target" really doesn't work any more, and you essentially have to manually set every single "Module" field on every single storyboard, any time you change anything.

Again, it does seem to be a totally blockbuster bug introduced around 11.0.

The only solution is just the workaround - manually set every single storyboard. (Of course, if you miss one ... crash.)

Community
  • 1
  • 1
Fattie
  • 27,874
  • 70
  • 431
  • 719