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-9574] Generated header doesn't import Foundation when adopting throwing method. #52021

Closed
zienag opened this issue Dec 24, 2018 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@zienag
Copy link

zienag commented Dec 24, 2018

Previous ID SR-9574
Radar None
Original Reporter @zienag
Type Bug
Status Resolved
Resolution Duplicate
Environment

$ swift --version

Apple Swift version 4.2.1 (swiftlang-1000.11.42 clang-1000.11.45.1)

Target: x86_64-apple-darwin18.2.0

Additional Detail from JIRA
Votes 0
Component/s
Labels Bug
Assignee None
Priority Medium

md5: 264cd7f6d84708db12b9c5412b267710

duplicates:

  • SR-2250 Generated ObjC header doesn't import Foundation if only bridged types are used

Issue Description:

If there is throwing method and no Foundation types in public @objc interface, generated header doesn't include Foundation, and it produces compile time error:

@objc public class Foo: NSObject {
  @objc public func throwing() throws {}
}

Error:

While building module 'test_module' imported from /throws_import_bug/throws_import_bug/main.m:11:
In file included from <module-includes>:1:
/throws_import_bug/.build/Products/Debug/test_module.framework/Versions/A/Headers/test_module-Swift.h:187:33: error: expected a type
- (BOOL)throwingAndReturnError:(NSError * _Nullable * _Nullable)error;
                                ^
1 error generated.
/throws_import_bug/throws_import_bug/main.m:11:9: fatal error: could not build module 'test_module'
#import <test_module/test_module-Swift.h>
 ~~~~~~~^
2 errors generated.

test_module-Swift.h contains only

@import ObjectiveC;

and no other imports.

@belkadan
Copy link
Contributor

belkadan commented Jan 7, 2019

Fixed by Mani (JIRA User) in SR-2250 by just importing Foundation all the time. :-)

@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

2 participants