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

Integrating to C++ project #81

Closed
Noxalus opened this issue May 22, 2014 · 6 comments
Closed

Integrating to C++ project #81

Noxalus opened this issue May 22, 2014 · 6 comments

Comments

@Noxalus
Copy link

Noxalus commented May 22, 2014

Hello,
First, I would like to say that I'm new to objective-C world so I'm sorry if my question is too lame...

I'm currently trying to integrate this bridge into my C++ project and I have some issues targeting an iOS device.

What I've done is simple, I've just put the WebViewJavascriptBridge.* files to my project and compiled it with -x and objective-c++ flags.

On WebViewJavascriptBridge.h, I have a lot of semantic issue with WVJB_WEBVIEW_TYPE but after a quick search I found that adding the import of UIKit is enough to remove these errors.

But know, I have 12 semantic issues into WebViewJavascriptBridge.m with typeof and strongDelegate and I don't know how to fix that.

Do you have any idea of what can be the origin of these issues ? Did I do something wrong ?

Thanks in advance for your answer.

@marcuswestin
Copy link
Owner

Hey @Noxalus,

Thanks for taking the time to try and write in with your problems. Sorry that WVJB is not working out as easily for you as it should be.

I have little experience working with cpp in objc projects, but let's start tackling this together and see where we get.

Here are some clarifications and some questions.

  • Re WVJB_WEBVIEW_TYPE: WebViewJavascriptBridge is built to work both for iOS and for OSX. However, the classname of webviews is different on iOS & OSX (WebView & UIWebView respectively). So we declare a macro variable which will replace "WVJB_WEBVIEW_TYPE" with the correct type at compilation time
  • Re typeof and strongDelegate: I need more information to know what's going on here. What are the warnings?
  • Are you building with xcode? If no, I would recommend starting by creating an iOS project in xcode and then integrate your cpp code.

Cheers,
Marcus

@Noxalus
Copy link
Author

Noxalus commented May 22, 2014

Thank you very much for your answer!

For WVJB_WEBVIEW_TYPE, it's UIWebView for iOS but this type is defined in UIKit.h right ? You import WebKit.h OSX side, why don't you do the same thing for iOS ?

For typeof and strongDelegate, it's not warnings but errors. Xcode says that they are undeclared.

To answer to you, yes, I use Xcode 5 but the C++ project on which I work is a big framework that should compile on a lot of plateforms, including iOS. So I just can't create an Xcode project and import the C++ code into it.

Thanks again.

EDIT: Also, the iOS example available on the repository works pretty well, the problem really seems to be about the C++ integration.

@Noxalus
Copy link
Author

Noxalus commented May 23, 2014

I post a new message to notice you that I think I resolved the problem.

Finally, I start reading your code and I find out that all errors that I had were just after this section of the code:

/* Platform specific internals: OSX
 **********************************/
#elif defined WVJB_PLATFORM_IOS

I've check if it was the same thing on the main branch, but it's not. It's WVJB_PLATFORM_OSX instead of WVJB_PLATFORM_IOS so I made the change and it compile well.

This error is still into the 4.1.0 release.

Thanks for your help and sorry to ask my question before to read the entire code.

Have a nice day.

@Noxalus Noxalus closed this as completed May 23, 2014
@Noxalus Noxalus reopened this May 23, 2014
@Noxalus
Copy link
Author

Noxalus commented May 23, 2014

Ok, sorry again, It seems that I checked a little bit to quick... There is already an #if defined WVJB_PLATFORM_OSX so in the elif it's really WVJB_PLATFORM_IOS (the mistake was in comment).

So to return to the initial problem here are the errors that I encounter:

alt Error

Like I said before it's about typeof and strongDelegate but strongDelegate is a variable defined using typeof so I think that the problem is only related to typeof keyword.

EDIT: I confirme that, if I replace all typeof by the type of _webViewDelegate (I put id), I can compile without error. But I don't know if it's the right way...

@marcuswestin
Copy link
Owner

Hey, I finally patched this up in 5f10f81. Please let me know if it didn't fix your problem.

Cheers, and thanks again!

@izzusan83
Copy link

hi,
I try to use your code in unity3d Xcode project but i have a strange problem.

i have used unity3d 4.6.2 with Xcode 6.1.1 and she import your code in Xcode i have a error:

webViewDidStartLoad
2015-03-03 10:37:19.195 perceval[1355:1715745] -[__NSCFType countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x18913bf0
2015-03-03 10:37:19.196 perceval[1355:1715745] *** WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: -[__NSCFType countByEnumeratingWithState:objects:count:]: unrecognized selector sent to instance 0x18913bf0
2015-03-03 10:37:22.363 perceval[1355:1715745] WVJB RCVD: {"data":"Hello from JS button","callbackId":"cb_1_1425375442341"}
2015-03-03 10:37:22.363 perceval[1355:1715745] ObjC received message from JS: Hello from JS button
2015-03-03 10:37:22.363 perceval[1355:1715745] -[__NSCFType addObject:]: unrecognized selector sent to instance 0x18913bf0

you have any idea?

  • Thansk a lot.

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

3 participants