Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interface Builder Inherit Module from Target picking wrong target

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?

like image 774
kiyoshi Avatar asked Jun 29 '18 21:06

kiyoshi


2 Answers

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.

like image 149
vedrano Avatar answered Oct 31 '22 21:10

vedrano


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.)

like image 25
Fattie Avatar answered Oct 31 '22 21:10

Fattie