3 Replies
      Latest reply on Jul 19, 2016 11:36 AM by jhunter_rs
      jhunter_rs Level 1 Level 1 (0 points)

        I'm starting with a working app, and trying to encapsulate as much functionality as possible into an embedded framework.  Everything in the embedded framework is Obj-C or C, and the new 'skeleton' project is Obj-C.

         

        I believe I'm building my framework so that it defines a Module with a particular name.

        I've used nm against the framework contents and believe my custom class is implemented in there, the symbols weren't stripped out.

        The umbrella header for the framework specifies ALL of the headers that used to go into the working app target, even AppDelegate.h.

        I believe I've updated my Storyboards so that the Module field for each custom view controller specifies the Module name, and have inspected Main.storyboard to confirm that my intended custom class name and module name are reflected in the XML source.

         

        At runtime, I get a variant of "unknown class in interface builder file." 

        Unknown class _TtC8<moduleName>25<customClassName> in Interface Builder file.

         

        My impression from canvassing these forums, StackOverflow, and Google is that basically anyone who tries to use embedded frameworks hits some variant of these errors, and that there are a bunch of mostly-unrelated fixes on offer depending on exactly which variant one is hitting.

         

        First off, what's up with the name mangling in the error message?  Does the leading _T mean that the runtime is trying to load a Swift class, and does the presence of the moduleName mean its looking for the custom class inside some kind of namespace?

         

        Please help.

        • Re: failing to load custom class from embedded framework
          jhunter_rs Level 1 Level 1 (0 points)

          Similar error when using static lib instead of embedded framework:

           

          I'm now persuing a fallback strategy that doesn't use an embedded framework.  All of the .xibs and .storyboards are now included in the app build, but I'm trying to pull all of the non-main C and Obj-C code out of static libraries.

           

          At runtime, the app crashes with a similar error, only the name of my class isn't mangled anymore.

           

          In a sense, this is progress!  I ran nm against the executable code inside the app bundle, and lo and behold, the missing class was never linked into the executable.  This sort of makes sense, in that the linker is only pulling in classes along the known-required execution paths from main.m.  On the other hand, LOTS of objective C classes in a typical application only get referenced after a .storyboard is loaded and starts trying to instantiate things. 

           

          I'm going to try disabling dead code stripping for the executable to see if that works.  But even if it does, that can't be the only/best soluton, can it?