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']
)
This issue will be solved within a week, don't worry :)
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.
@nguyentruongtho update on this?
'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 https://github.com/facebook/buck/pull/983, as soon as it lands, I will put something up for the above idea.
@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.
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.
As I pointed out here: https://github.com/facebook/buck/pull/1153#issuecomment-276615983, 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
@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!
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.