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

MyProject-Swift.h header not found when embedding framework into ObjectiveC project #303

Closed
edulpn opened this issue Aug 14, 2015 · 21 comments

Comments

@edulpn
Copy link

edulpn commented Aug 14, 2015

I tried following the usage guidelines on the README for ObjectiveC projects several times and it never creates the "-Swift.h" header file so I can import.

I do as follows:

1 - Drag the Charts.xcodeproj to my project
screen shot 2015-08-14 at 3 54 33 pm

(Cmd + B -> Build Successful)

2 - Go to your target's settings, hit the "+" under the "Embedded Binaries" section, and select the Charts.framework
screen shot 2015-08-14 at 4 04 02 pm

(Cmd + B -> Build Successful) This should do step 3 of the Guide

(Since it's a ObjectiveC project, I jump to step 5)
5 - Under "Build Options", mark "Embedded Content Contains Swift Code"
screen shot 2015-08-14 at 3 56 20 pm

(Cmd + B -> Build Successful) After this build I think my "-Swift.h" header file should be already generated, so we should be good, right?!

Alright, so by now I should be able to do a simple #import "NewChartDemo-Swift.h", but then:
screen shot 2015-08-14 at 3 56 55 pm

Am I missing something? I wasn't able to achieve the expected results in any of my several tries, looked up StackOverflow for other people having trouble importing Swift Frameworks into ObjectiveC projects and none of the work arounds work for me.

@polonel
Copy link

polonel commented Aug 15, 2015

I'm fighting this same issue. +1

@danielgindi
Copy link
Collaborator

Sometimes the -Swift.h header is not created until you manually create a Swift file in your project.
And sometimes you just don't know how to name it correctly...
In your case it is definitely import "NewChartDemo-Swift.h", so I'm guessing that Xcode wants you to manually create a .swift file for it to start creating the -Swift.h file.

So here's what you should do:

  1. Remove Charts from your project, along with any "NewChartDemo-Swift.h" imports
  2. Right click and add a new Swift file
  3. Build (a successful build)
  4. Import the "NewChartDemo-Swift.h" in one of your files
  5. Build again, to make sure it works
  6. Add Charts back

@edulpn
Copy link
Author

edulpn commented Aug 17, 2015

Got XCode to generate de -Swift.h file, but the only mapped class was my manually created Swift class

screen shot 2015-08-17 at 10 33 45 am

What else should I try? What are the steps to import Charts source code into the project, like the iOS7 approach?

@danielgindi
Copy link
Collaborator

Are you importing the sources manually? Did you make sure that all the files are in your target?

@edulpn
Copy link
Author

edulpn commented Aug 17, 2015

First approach I tried was importing/dragging the .xcodeproj file into my project, thought it'd be a good start, but in the future I'll need to support iOS7 when using Charts in an actual app. I'll make sure everything belong to my target and try again. Or is this only applicable to importing the sources manually?

@edulpn
Copy link
Author

edulpn commented Aug 17, 2015

Wow! I think I got it working...

screen shot 2015-08-17 at 10 45 42 am

This time I right-clicked my project -> Add files to... Then selected the whole folder, instead of the .xcodeproj file, like this

screen shot 2015-08-17 at 10 46 49 am

Now it looks like I can use Charts classes on my ObjectiveC project. I'll keep the post updated.

@edulpn
Copy link
Author

edulpn commented Aug 17, 2015

Yeah, it does work for me and people from my team. So, for anyone who should face the same issue in the future, add files to project selecting the whole folder (in the picture above) instead of dragging the .xcodeproj file worked for me.

screen shot 2015-08-17 at 10 56 58 am

@danielgindi
Copy link
Collaborator

Or guys, just read the README. It specifically says that for iOS 7 you should add the .swift files, not the framework!

@edulpn
Copy link
Author

edulpn commented Aug 17, 2015

And by the way, AWESOME library @danielgindi , you're getting a dinner + beer sometime soon :)

@danielgindi
Copy link
Collaborator

Thanks :-)

On Mon, Aug 17, 2015 at 5:03 PM, edulpn notifications@github.com wrote:

And by the way, AWESOME library @danielgindi
https://github.com/danielgindi , you're getting a dinner + beer
sometime soon :)


Reply to this email directly or view it on GitHub
#303 (comment)
.

@edulpn
Copy link
Author

edulpn commented Aug 17, 2015

Ah, this was for iOS 8... I'll try iOS 7 later.

@danielgindi
Copy link
Collaborator

iOS7 is what you finally did...

On Mon, Aug 17, 2015 at 5:05 PM, edulpn notifications@github.com wrote:

Ah, this was for iOS 8... I'll try iOS 7 later.


Reply to this email directly or view it on GitHub
#303 (comment)
.

@edulpn
Copy link
Author

edulpn commented Aug 17, 2015

Gotcha... Thanks for the help!

@acegreen
Copy link

acegreen commented Sep 8, 2015

@danielgindi Why does this NewChartDemo-Swift.h go and do we even need it? I have a swift project and a bridging header. but can't do # import "NewChartDemo-Swift.h". I took it out and in my swift file did import Charts.

PS I'm on iOS and added this as a embedded framework as per instructions

@liuxuan30
Copy link
Member

${Your project name}-Swift.h is for objc based project to use swift code I remember. It is generated by XCode, to translate swift code to a header file for objc to import. If you don't need to use swift in objc project, you don't need it. As you can see you are simply a swift project, everything is swift.

@acegreen
Copy link

acegreen commented Sep 8, 2015

@liuxuan30 Ah crap. I got rattled by this without reading that ITS FOR AN OBJECTIVE-C PROJECT!!!

Though I'm left with one issue still

screen shot 2015-09-07 at 10 15 42 pm

@liuxuan30
Copy link
Member

then it goes to swift :-) Check how your 'object' is declared. and its dataSet property.

@acegreen
Copy link

acegreen commented Sep 8, 2015

@liuxuan30 to be honest, I'm not yet familiar with Charts library. The error is in the "ChartSelectionDetail" file

@acegreen
Copy link

acegreen commented Sep 8, 2015

I have a feeling this is a bug in Xcode 7 beta 6

@liuxuan30
Copy link
Member

@acegreen try stackoverflow. or create a new issue with details, current info cannot tell what's wrong. To me it's more like a swift compiler error. should be easy resovled on SO

@venkatesh4446
Copy link

I have framework using bridge file created in sample framework project and i import same bridge file in another project.So i will import same bridge file in framework project and sample project means what happen?

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

6 participants