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

Cannot Import *-Swift.h generated header file from Obj-c #5

Closed
nebillo opened this issue Mar 26, 2018 · 6 comments
Closed

Cannot Import *-Swift.h generated header file from Obj-c #5

nebillo opened this issue Mar 26, 2018 · 6 comments

Comments

@nebillo
Copy link

nebillo commented Mar 26, 2018

Hi,
thanks so much for providing this information. it really helped me starting out with Buck.

I'm trying to setup a simple project with Objc and Swift inter-op.
I can successfully use Objc from Swift using the bridging header, however I cannot use Swift from Objc code.

When trying to #import "App-Swift.h" (App is the module name) from the obj m file and try to build using Buck, I get the following error:
stderr: App/App.m:3:9: fatal error: 'App-Swift.h' file not found

Any hints?
I am using the latest version of buck which I've installed from the original repo. I know you are using a custom version of it but I am not really sure how to try this out.

Any hints would be extremely helpful. thanks!

@zayhero-zz
Copy link
Collaborator

@nebillo The mixed language support is not working in master branch yet.
You can try with our open source branch which should work:
https://github.com/airbnb/buck/tree/airbnb-modular-external-use
More details can be found here:
https://github.com/airbnb/BuckSample/blob/master/README.md

We are working on merge our changes upstream but haven't finish yet.

@cooksimo
Copy link

cooksimo commented Jul 3, 2018

@zayhero Any updates on getting this work pushed upstream?

@dfed
Copy link
Collaborator

dfed commented Feb 6, 2019

We're working on it. Currently the only bit we need to diverge from Facebook's master is facebook/buck#2163. If you use that branch, you should be good to go.

I'm going to close this issue out, since we have -Swift.h imports working in this repo, and have demonstrated it with #35.

@dfed dfed closed this as completed Feb 6, 2019
@davidxiasc
Copy link

davidxiasc commented May 28, 2019

sorry to bump this issue, but I'm trying to get -Swift.h imports work inside an apple_binary as opposed to an apple_library. Would you have any guidance on how to accomplish this? We have Defines Module and Module Name defined in the Xcode project, but its unclear how that translates into flags

@dfed
Copy link
Collaborator

dfed commented May 28, 2019

@davidxiasc I think it's best to file a new issue here. If you do file a new issue, it would be exceedingly helpful to get a sense of:

  1. What have you tried
  2. What did you expect to happen
  3. What happened

If you want to go above and beyond in your new issue: fork this repo and point us at a branch that shows the issue you're seeing (this isn't required, but will make it way easier/quicker for us to help). Please also include in your issue why you're putting code directly in the binary so we can better understand your use case.

All that said: I pretty strongly advise you to wrap your code in a library, and have your binary depend on the library (as we do here). As far as I can tell, putting code directly in the binary has little-to-no benefit, but it comes with plenty of downsides: all of a sudden you need bridging headers, the name of the binary rule might change between debug and release which changes your module name and can break storyboards, you can't @testable import your binary target, etc.

Note that given the above, we're unlikely to want to merge in an example to master that shows how to accomplish what you're asking. But I'm always curious what folks' use cases are, and I'm happy to help if I can.

@davidxiasc
Copy link

@dfed thanks, continuing in #107

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

No branches or pull requests

5 participants