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-7051] Compiler fails with "Module not found" error #49599
Comments
The revenge of SR-2772! I guess we need to check if an extension is "empty" even earlier, so that we don't think we need to emit imports for it. |
Hey. The point here is not that it's empty – I just didn't include more details than necessary. The point is that it fails. Why? I don't mark it or any contents as @objc, I don't want it to be imported into App-Swift.h. But even if it gets in there, why doesn't it work? If I would want to do |
It's only including the import in the generated header because of the extension. If the extension were absent, it wouldn't include the import, and if the extension had stuff in it, you'd need it. The actual import doesn't work because static libraries don't have C modules or headers by default. You can make it work, but Xcode doesn't help you do it today. That's not a Swift issue, though. |
Ok, cool. Understanding that this isn't a Swift problem, can you shed some light on how to make it work or point in the right direction? Tried enabling modules, adding headers, bridging header and a few other tricks without any luck. |
Comment by Scott Talbot (JIRA) I also encountered this and, in case others get to here with the same problem, the advice in this blog post helped me: The gist is that you have to copy the `<product>-Swift.h` header to a place in the built products directory and create a module map that references it. |
cysp (JIRA User) great point![]( I used Paul's approach before, won't be surprised if on related issue… :D Thanks for the reference) |
Comment by Pawel Szot (JIRA) I encountered this while experimenting with internal module maps. Even making extension private will not help. |
@swift-ci create |
Attachment: Download
Additional Detail from JIRA
md5: b810dd94930798e2172c09555d671956
is duplicated by:
relates to:
Issue Description:
Trying to make it make it as simple as possible, but still sounds a little complicated. Consider:
1. Project with macOS app (App) and static Swift lib (Lib) that it depends upon.
2. App target has a bridging header and some Obj-C code.
3. Static lib has Foo class inheriting from NSObject and Bar class (plain Swift).
4. When attempting to create an extension for Foo the build fails saying that `module 'Lib' not found`.
5. When attempting to create an extension for Bar the build succeeds.
It appears that compiler recognises that Foo has NSObject in parent hierarchy and automatically adds `@import Lib` into `App-Swift.h`. Is this expected? How do deal with it? Project attached.
Update 2019.01.18:
So glad I've filed this! Saved myself a lot of time figuring out what went wrong… The cases when the extension is not empty also fails, apparently it only doesn't like intermediate classes, e.g.,
Foo
, extendingBar
seems okay:The text was updated successfully, but these errors were encountered: