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-2250] Generated ObjC header doesn't import Foundation if only bridged types are used #44857
Comments
This actually happened to someone: https://twitter.com/avbelow/status/982258484371537921. Attached their test project. I'm going to say that it's not worth trying to be clever here. We should just Tagging as a StarterBug, because anyone can make that change. Meanwhile, a workaround is to make sure you import Foundation before using the generated header. |
Comment by Mani Ramezan (JIRA) @belkadan Hey, I'm interested in picking up this ticket as my first attempt to contribute to Swift compiler. Since it's assigned to you, was wondering to check if it's ok to assign it to myself and try to apply the suggested change. |
Comment by Mani Ramezan (JIRA) @belkadan I added #import <Foundation/Foundation.h> and the tests started failing as they all fail to find: fatal error:
'Foundation/Foundation.h' file not found Do you happen to know a sample for similar situation I can look into for fixing tests? I tried to find some but wasn't successful, so far have found -include foundation.h or asking to use mock sdk that also didn't work. |
Ah, which tests are failing? I would have expected all the PrintAsObjC tests to be using the real SDK, but maybe I'm misremembering. |
Oh. Definitely misremembering. *sigh* I guess we could move the mock SDK's Foundation.h, but that could cause a lot of churn. Hm…maybe we can put a dummy Foundation/Foundation.h inside test/PrintAsObjC/Inputs/, and then add that as an include path everywhere? (and then that header would just turn around and import the mock Foundation as |
Comment by Mani Ramezan (JIRA) Almost all of the tests for PrintAsObjC fail on the last check, // RUN: %check-in-clang %t/Foo.h check. Putting a dummy Foundation/Foundation.h sounds good, let me look into that approach and see if I can have tests passing with that trick |
Note that |
Comment by Mani Ramezan (JIRA) Thanks a lot for that last tip, it helped a lot. I could modify tests and fix the failing ones: 17615 |
Comment by Mani Ramezan (JIRA) Applied the fix and submitted this PR |
Sorry, please don't mark the bug as resolved until the PR is merged! (And sorry for not seeing the PR until now. Your link is broken, which confused me.) |
Comment by Mani Ramezan (JIRA) Re-opening as the PR hasn't been merged, yet |
Comment by Mani Ramezan (JIRA) Thanks for checking. Sorry for the PR link, not sure why it's broken. When I copy/paste in the URL it works, but when I click on it here it's broken. My bad. I also reverted the issue to "In Progress". |
Attachment: Download
Additional Detail from JIRA
md5: 357e61899ba86f33c9bac25b20bb82d9
is duplicated by:
Issue Description:
If an ObjC header is generated from a Swift interface that only uses standard library bridged types, then Foundation is not imported in the generated header, leaving
NSArray
and friends undefined.The text was updated successfully, but these errors were encountered: