Xcode IDE Plugin Custom Error: "Could not find class name ..."

I developed my own Xcode.ideplugin to add a custom object to the Xcode scope of the Object Library . I have a custom object template based on a class that I called IBMyCustomObject, which in turn has the name runtimeClassName of a class called MyCustomObject (the class name runtime is the name of the class that will be created at runtime when the Xib file is loaded).

After several studies, I was able to successfully work. Now I can drag my custom object from the Object Library area to the Xib files normally, set the object properties in the inspector panel, and everything else works fine. The only problem occurs during compilation, where Xcode ibtool gives me the following error while compiling the Xib file:

 Exception name: NSInvalidArgumentException Exception reason: Could not find class named MyCustomObject 

And here is the complete exception tracking log:

 Exception backtrace: 0. CoreFoundation 0x0226d6d8 __exceptionPreprocess 1. libobjc.A.dylib 0x01fe98b6 objc_exception_throw 2. CoreFoundation 0x022fd721 -[NSException raise] 3. ??? 0x000116b8 [IBCocoaTouchToolObjectPackage initWithRequest:] 4. ??? 0x00010597 [IBCocoaTouchTool .cxx_destruct] 5. ??? 0x0000b63d [IBCocoaTouchTool compileNibForRequest:minimumCompatibility:layoutInfo:] 6. IBFoundation 0x00362c51 __72-[IBMessageReceiveChannel deliverMessage:toTarget:withArguments:result:]_block_invoke 7. IBFoundation 0x00362996 -[IBMessageReceiveChannel deliverMessage:toTarget:withArguments:result:] 8. IBFoundation 0x00362673 __80-[IBMessageReceiveChannel runBlockingReceiveLoopNotifyingQueue:notifyingTarget:]_block_invoke 9. libdispatch.dylib 0x029c2444 _dispatch_barrier_sync_f_slow_invoke 10. libdispatch.dylib 0x029d34b0 _dispatch_client_callout 11. libdispatch.dylib 0x029c1766 _dispatch_main_queue_callback_4CF 12. CoreFoundation 0x022d2b6e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ 13. CoreFoundation 0x022137eb __CFRunLoopRun 14. CoreFoundation 0x02212bf3 CFRunLoopRunSpecific 15. CoreFoundation 0x02212a0b CFRunLoopRunInMode 16. Foundation 0x01c1fe55 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] 17. ??? 0x0003ac67 [IBAbstractCocoaTouchTool startServingReceiveChannel:] 18. ??? 0x0003ad62 [IBAbstractCocoaTouchTool startServingSocket:] 19. ??? 0x0003aec7 [IBAbstractCocoaTouchTool protocolCapabilities] 20. ??? 0x0001053e [IBCocoaTouchTool .cxx_destruct] 21. libdyld.dylib 0x9313d725 start Exception info:{ } 

Any ideas on how I can get Xcode (more precisely, ibtool) about the MyCustomObject class so that it can find it at compile time? I tried many things, including placing MyCustomObject within the framework and loading the package at runtime, but nothing worked at all. If I replace IBMyCustomObject runtimeClassName with NSMutableDictionary (or any other Foundation or UIKit class) instead of MyCustomObject, everything will work fine, but I really need to use my own MyCustomObject class.

PS: For anyone interested in developing such plugins, I will post all of my findings in a detailed blog post on sensiblecocoa.com (framework using the plugin) as soon as I understand everything.

+7
ios objective-c cocoa-touch xcode cocoa
source share
1 answer

Well, it turns out that Xcode (more specifically, ibtool) generates a completely new process called the “Interface Builder Cocoa Touch Tool” at compile time, which explains why downloading the MyCustomClass package had no effect. One of the possible solutions to this issue that I was considering was using dylib injection to inject the MyCustomClass library into the newly created process, but none of the methods I found were reliable enough for reliable and stable production code.

Finally, I ended up using NSMutableDictionary instead of MyCustomClass , which compiled perfectly. Then I used the setter property method in the object owner class to convert the loaded NSMutableDictionary to MyCustomClass , and then manually assigned all the dictionary keys to the appropriate properties. As I said, I will talk about the details of plugin development at sensiblecocoa.com .

+6
source share

All Articles