Skip to content
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

Closed
iby opened this issue Jun 27, 2016 · 14 comments
Closed
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@iby
Copy link

iby commented Jun 27, 2016

Previous ID SR-1917
Radar rdar://problem/33450609
Original Reporter @iby
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s
Labels Bug
Assignee @belkadan
Priority Medium

md5: cb154d16763f26979a576b5c71e56e1d

Issue Description:

Consider the following code, Bar works as expected, but Foo returns a different bundle. Happens inside a test case.

@belkadan
Copy link
Contributor

@gparker42, how does Foundation determine the bundle for a class generated at runtime? @slavapestov, classes for concrete generic types are generated at runtime, right?

@slavapestov
Copy link
Member

Right, it appears that NSBundle(forClass🙂 is not doing the right thing with an instantiated class.

@gparker42
Copy link
Mannequin

gparker42 mannequin commented Jun 28, 2016

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.

@gparker42
Copy link
Mannequin

gparker42 mannequin commented Jun 28, 2016

(In this case I assume it is returning the "bundle" for the swift executable.)

@swift-ci
Copy link
Collaborator

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 🙂

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 6, 2018

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)

@belkadan
Copy link
Contributor

belkadan commented Feb 6, 2018

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.

@swift-ci
Copy link
Collaborator

swift-ci commented Feb 7, 2018

Comment by Matt Holgate (JIRA)

@belkadan it was one of our types.

@belkadan
Copy link
Contributor

@swift-ci create

@belkadan
Copy link
Contributor

We're making progress on this one with a combined Swift / ObjC runtime change. Here's the Swift side: #17910

@belkadan
Copy link
Contributor

4.2: #17930

(still needs the corresponding libobjc change to do any good)

@belkadan
Copy link
Contributor

Backwards-deployment support: #18060

@belkadan
Copy link
Contributor

4.2: #18076

@belkadan
Copy link
Contributor

All right, everything's merged in. Tomorrow's 4.2 snapshots should work on everywhere but this year's OS betas.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

4 participants