Skip to content

[Build] Generate ObjC compatibility header for library Swift targets #2341

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

Merged
merged 1 commit into from
Sep 18, 2019

Conversation

aciidgh
Copy link
Contributor

@aciidgh aciidgh commented Sep 17, 2019

This will generate the ObjC header for library Swift targets so they can be
used in other ObjC targets. This is only done for macOS.

rdar://problem/51780725

@aciidgh
Copy link
Contributor Author

aciidgh commented Sep 17, 2019

@swift-ci smoke test

@aciidgh
Copy link
Contributor Author

aciidgh commented Sep 17, 2019

@swift-ci smoke test

This will generate the ObjC header for library Swift targets so they can be
used in other ObjC targets. This is only done for macOS.

<rdar://problem/51780725>
@aciidgh
Copy link
Contributor Author

aciidgh commented Sep 18, 2019

@swift-ci smoke test

@aciidgh aciidgh merged commit 4e468ab into swiftlang:master Sep 18, 2019
@aciidgh aciidgh deleted the objc-header branch September 18, 2019 04:22
@MarvinNazari
Copy link

@aciidb0mb3r: Is this released in Xcode 11.2? Because I'm still seeing the issue. I have a sample if it helps?

@aciidgh
Copy link
Contributor Author

aciidgh commented Nov 5, 2019

No, this change is not present in Xcode 11.2

@tomangistalis
Copy link

Is this going to be released with Xcode 11.3 or we have to wait for Swift 5.2?

@jlubeck
Copy link

jlubeck commented Jan 9, 2020

How about Xcode 11.3?

@gurhub
Copy link

gurhub commented Jan 13, 2020

Maybe with 11.4?

@oonoo
Copy link

oonoo commented Jan 26, 2020

Is there an update on when this is released / available in Xcode?

@wooster
Copy link

wooster commented Feb 28, 2020

This is only done for macOS.

@aciidb0mb3r Any reason not to do this for iOS, as well?

@SamuelZhaoY
Copy link

SamuelZhaoY commented Mar 12, 2020

I wish this could be supported in iOS as well. Currently, I am facing cases like delivering Swift packages to ObjC based App target. Without able to directly import the autogenerated swift header in ObjC, it will be very painful to add a Swift adaptor layer in the app.

@devedup
Copy link

devedup commented Apr 22, 2020

This is working in iOS project on Xcode 11.4.1 for me.

I've tested it on an old Objective-C project and successfully can use Swift Package manager with it. Here is what I did:

  1. Swift Packages - add package dependency, as normal to include my package
  2. In an Objective-C .m file, include the module like so:
    @import YourSwiftPackageName;
  3. Ensure in your swift package that you have used @objc to expose Swift to your Objective-C
  4. Ensure you have used public to expose your Swift in your package to your main project, as it's in another module.
  5. Ensure your Swift Package is listed in your targets 'Frameworks, Libraries and Embedded Content'. I note this because I have 2 targets - and it only added them to one of my targets, not both, so I kept getting Module not found errors.

@juliensechaud
Copy link

I'm able to add a SwiftPackage into MainTarget Objective-C.m file
But no chance when trying to add it to my Objective-C.h file.
Any idea to solve this ?

@gistya
Copy link

gistya commented May 3, 2021

I'm unable to use @objc protocols (declared in Swift files in a Swift Package) in Obj. C files in an Xcode project framework that explicitly links to that package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet