Type defined in header of another project within a workspace doesn't necessarily match superclass
| Originator: | ash.furrow | ||
| Number: | rdar://17920217 | Date Originated: | Aug 5, 2014 |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 6 Beta 5 |
| Classification: | Other Bug | Reproducible: | Always |
Summary:
This is a complicated one, and I've tried my best to provide an adequate sample project. Disclaimer: this workspace and library target was created using CocoaPods, but! Please don't close my bug! But! All the project is now is a collection of Xcode project files, workspace files, and xcconfig files. Nothing special. All of the special build phases and everything that CocoaPods does, I've taken out. This is a valid Xcode project setup, and it's got a problem.
The structure of the project is a little complex, but it's essentially iOS app named "Kiosk" depends on a library target in another project (same workspace), and that library target depends on another library target, where the Objective-C source files are. Good times.
OK, so far so good. I created an Objective-C bridging header to use those files in the library I'm transitively linking against. Cool. I can use the classes defined there, and my code will compile. Great. But then I try and run my app, and I get a crash.
2014-08-05 21:18:11.378 Kiosk[4230:4675017] *** NSForwarding: warning: object 0x4a9a0 of class 'Thing' does not implement methodSignatureForSelector: -- trouble ahead
2014-08-05 21:18:11.379 Kiosk[4230:4675017] *** NSForwarding: warning: object 0x4a9a0 of class 'Thing' does not implement doesNotRecognizeSelector: -- abort
I can't paste the full contents of the stack trace – here's the top of it:
* thread #1: tid = 0x4755c9, 0x015f19b2 CoreFoundation`___forwarding___ + 1026, queue = 'com.apple.main-thread', stop reason = EXC_BREAKPOINT (code=EXC_I386_BPT, subcode=0x0)
* frame #0: 0x015f19b2 CoreFoundation`___forwarding___ + 1026
frame #1: 0x015f158e CoreFoundation`__forwarding_prep_0___ + 14
frame #2: 0x013e0981 libswiftCore.dylib`swift_getInitializedObjCClass + 33
frame #3: 0x000475b2 Kiosk`type metadata accessor for ObjectiveC.Thing + 50
frame #4: 0x000469b6 Kiosk`Kiosk.ViewController.viewDidLoad (self=0x7c46a6e0)() -> () + 950 at ViewController.swift:19
frame #5: 0x00046c42 Kiosk`@objc Kiosk.ViewController.viewDidLoad (Kiosk.ViewController)() -> () + 34 at ViewController.swift:0
OK, so. What's going on? The object is being loaded at runtime – I checked that load was getting called on it. But, it turns out that something really weird was going on. The implementation file wasn't #import'ing the header file, so when it went to @implementation, it didn't have a base class at all. Even though the Swift code thought it did.
Super weird, since usually the compiler warns us that there is no base class. It didn't this time – spoooooky.
Relatively minor bug, but I thought I should report it. Sorry I don't have better steps to reproduce. Here's the sample project: http://cloud.ashfurrow.com/3V3I1R3a2O35
Steps to Reproduce:
I've tried a few times to recreate this issue, and I just can't without this project. I'm hoping that you'll be able to debug it and discover the source of the error. Please see my sample app – just try and run it and it'll crash.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Follow-up from Apple
Engineering has determined that this issue behaves as intended based on the following:
In target Pods-Kiosk-Artsy+UIColors > Build Phases > Compile Sources > UIColor+ArtsyColors.m, the file is being compiled with -w which turns all warnings off. Removing -w produces the expected warnings. Adding the correct #include produces the expected non-crashing app.
Please update your bug report to let us know if this is still an issue for you.