Skip to content
This repository was archived by the owner on Nov 10, 2023. It is now read-only.

Not able to export MyLibrary-Swift.h header from apple_library() #943

Closed
piotrwach opened this issue Oct 13, 2016 · 9 comments
Closed

Not able to export MyLibrary-Swift.h header from apple_library() #943

piotrwach opened this issue Oct 13, 2016 · 9 comments
Assignees

Comments

@piotrwach
Copy link

I have a library that has Swift and Objective-C code. Some Swift classes I want to export to Objective-C, I see that buck correctly generates MyLibrary-Swift.h for all classes marked as @objc, however I don't see a way export this header from my library, so that I can used it in my dependencies. Is this possible?

@nguyentruongtho

apple_library(
    name = 'MyLibrary',
    srcs = [
        'ObjC.m',
        'SwiftKit1.swift',
        'SwiftKit2.swift'
    ],
    exported_headers = [
        'ObjC.h',
        'MyLibrary-Swift.h' <---------------------------------------- this doesn't work
    ],
    visibility = ['PUBLIC']
)
@nguyentruongtho
Copy link
Contributor

This issue will be solved within a week, don't worry :)

@ryu2 ryu2 self-assigned this Oct 18, 2016
@nguyentruongtho
Copy link
Contributor

Sorry for the delay, I had a working version for framework, which probably can fix problem for swift_library has an apple_library dependency, https://github.com/nguyentruongtho/buck/tree/framework_flavor1, but it needs to be cleaned up a bit.

@rnystrom
Copy link

rnystrom commented Nov 9, 2016

@nguyentruongtho update on this?

@nguyentruongtho
Copy link
Contributor

'MyLibrary-Swift.h' <---------------------------------------- this doesn't work

We had a big internal project to be taken care of recently but this one is our high priority now and I'm heavily working on this. I think what you want is to be able to import a mixed target (contains objc and swift), we want the same thing but our method is different. We are not gonna use exported headers with generated swift header (likes above), we will generate module from the target and use the generated module instead.

Currently blocked by this pR #983, as soon as it lands, I will put something up for the above idea.

@rnystrom
Copy link

rnystrom commented Nov 9, 2016

@nguyentruongtho yup trying to do something similar. Currently writing some unit tests in Swift for an ObjC library to make interop changes blocking. We have a bridging header in our unit test suite but looks like its not picking it up when building.

@nguyentruongtho
Copy link
Contributor

nguyentruongtho commented Nov 10, 2016

This is part of the ongoing work for creating module from a target, but I guess it can solve your problem already: https://github.com/nguyentruongtho/buck/tree/tho/swift_exported_header

You can find very dummy poc sample here: https://github.com/nguyentruongtho/buck_swift_test/tree/master/swift_export_headers

Run: rm -rf buck-out && buck run :parent#macosx-x86_64

Let me know if you find any edge cases.

@nguyentruongtho
Copy link
Contributor

As I pointed out here: #1153 (comment), module-Swift.h is a private header (https://developer.apple.com/library/content/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html).

We won't allow to export module-Swift.h in buck as it is wrong. I don't know how that work with Xcode but this is terrible that Apple tooling is not consistent with their documentation.

We should use @import module syntax instead for importing external module and we have it working at Uber, will start merging stuff back to master.

If you all are agree, plz close this ticket. @ryu2

@gontovnik
Copy link

@nguyentruongtho, could you please let me know what is the latest status on that? I'd love if you could ping me on Messenger: http://m.me/gontovnik

Thanks!

@v-jizhang
Copy link
Contributor

Sorry we haven't update this issue for almost 3 years. At this point, we are closing this because it is quite out of date and it is not clear if the issue still exists. Please create a new one if you still see the problem. Thank you.

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

No branches or pull requests

6 participants