New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-1917] NSBundle(forClass…) produces unexpected results with generic class #44526
Comments
@gparker42, how does Foundation determine the bundle for a class generated at runtime? @slavapestov, classes for concrete generic types are generated at runtime, right? |
Right, it appears that NSBundle(forClass🙂 is not doing the right thing with an instantiated class. |
NSBundle returns the main bundle when asked about runtime-generated classes. I don't know if NSBundle has any way for a class to modify that lookup. |
(In this case I assume it is returning the "bundle" for the swift executable.) |
Comment by Andrew Bennett (JIRA) Still getting this in `Apple Swift version 4.0 (swiftlang-900.0.65 clang-900.0.37)` against iOS 11 Foundation. It's easy to work around, but non obvious to diagnose 🙂 |
Comment by Matt Holgate (JIRA) In our case, we found that we don't even get the main bundle here. We seem to get the "Frameworks" folder in our Main bundle: NSBundle </Users/matt/Library/Developer/CoreSimulator/Devices/C1C54C4C-FADE-4772-9FFB-00DC7B29584A/data/Containers/Bundle/Application/D6DB5BB0-64AD-47EF-B4AB-ABB11FE3E919/XXXXXX.app/Frameworks> (loaded) |
Was that your type, or one from the overlays? That's the path NSBundle would probably return for a type defined in the standard library or overlays. |
Comment by Matt Holgate (JIRA) @belkadan it was one of our types. |
@swift-ci create |
We're making progress on this one with a combined Swift / ObjC runtime change. Here's the Swift side: #17910 |
4.2: #17930 (still needs the corresponding libobjc change to do any good) |
Backwards-deployment support: #18060 |
4.2: #18076 |
All right, everything's merged in. Tomorrow's 4.2 snapshots should work on everywhere but this year's OS betas. |
Additional Detail from JIRA
md5: cb154d16763f26979a576b5c71e56e1d
Issue Description:
Consider the following code,
Bar
works as expected, butFoo
returns a different bundle. Happens inside a test case.The text was updated successfully, but these errors were encountered: