JSBridge for Qt5 - qt5

I found that Swift had a framework called WebViewJavascriptBridge which you can register bridge like:
bridge = WebViewJavascriptBridge(webview)!
bridge.setWebViewDelegate(delegate)
bridge.registerHandler("readConfigString")
I want to rewrite it C++ in Qt5, so I'm wondering if there is such framework in Qt5?

I think what you are looking for is QtWebChannel

Related

Cocoapod With Mix and Match Swift and Objective-c code

I've been tasked with splitting out the model layer of an existing app into a separate framework. I'm trying accomplish this using cocoapods to make a pod which I'll import back into the main app.
The issue I'm having is the app I'm splitting the code out from is a mix of Swift and Objective-c. It's not cleanly split so the Swift code makes use of Objective-c code and the Objective-c code makes use of Swift code.
I'm struggling to understand how to achieve this, or if it's even possible? When you're in a framework the bridging header and the generated *-swift.h don't seem to work the same way. Then pods is another complication on onto.
I've tried to experiment with a simple project here. SPOILER ALERT. It doesn't compile.
https://github.com/Megatron1000/TestMixAndMatch
I've tried to find an example of a cocoapod that's setup in the same entangled language way but haven't been able to. Can anyone point me to one I can use as an example?
I have a (private) pod that contains Obj-C and Swift code. In the podspec I've simply added them like this
s.source_files = 'Project/*.{swift}',
'Project/legacy/*.{h,m}'
Technically in Xcode this project is a framework.
Here you can find the technical details how to combine them in a Project.
Technically if you create a framework you'll need to include the Obj-C headers in the umbrella header of the framework
If you want to use Swift methods in your Obj-C classes you'll need to include them as
#import <ProductName/ProductModuleName-Swift.h>
if you're building a framework or simply
#import "ProductModuleName-Swift.h"
if you're working on a regular project
Perhaps the best approach in this case is to simplify the design of the framework and just rewrite objective-c legacy code info swift. You mention that the codebase is already partially in Swift, which will make it even easier to complete the transition.

Library's all code is written by Swift but Framework's header seems Objective C?

I'm making app with using Xamarin.
I have to bind some iOS framework which is written by Swift to CSharp.
Sad news is Xamarin does not support bind Swift framework at this moment, So I almost gave up.
But I have a question.
Header files of the library that I've built to framework looks Objective C. But All source code is written by Swift. (this framework : https://github.com/NordicSemiconductor/IOS-DFU-Library)
What is this?
Is this natural or they did something extra work to make it as Objective C when it's in framework?
This means that I can keep doing binding work?
Please correct me, if you have to.
As far as xamarin is concern, it doesn't matter if a Cocoa lib is written using objective C or swift, or C++ for that matters.
What you'll have to compile the lib into a *.framework compiled library using xcode. So swift or objc, well, doesn't matter.
Simply open the project in Xcode and build it. Obviously, don’t do build and run as you can’t run it (again unless you have a test suite). Now, look under the Products group in XCode and you should see a file called DFULibrary.framework.
Once you have the compiled binary, then you'll have to encapsulate it in a C# (or F#) iOS binding project (again, they say ios binding, not objc binding nor swift binding... guesss why :p ) as explain here : https://developer.xamarin.com/guides/cross-platform/macios/binding/objective-c-libraries/
Now, it's true that they say:
To do a comprehensive binding, you will want to understand the
Objective-C API definition and familiarize yourself with the .NET
Framework Design guidelines.
but I would pin that on a lack of update of the documentation. Just replace ObjC understanding by swift understanding :)
YOu will end up with a C# api anyway.
Enjoy

Mac creating simple dylib?

I need to create a dylib using XCode for my client. The dylib will have only two function start, and stop. The people i m making this for use mono and they will call this dylib. How can I create this?
Thanks.
Xcode has project templates for Cocoa, C++ and C dynamic libraries. Just create one of these and add you functions to it.

Android and Objective-C

I'm completing a project for the iPhone entirely written in Objective-C. I'd like to port this for Android too.
While the user interface of the iPhone and the Android OS are very different and will need different code, can I some how import the core of my code (ie. the black box that does the thinking) as is to Android as part of some Java code?
I have no familiarity with bridging between Objective-C and Java even though I have written in both.
You got luck! Phil Hassey has recently ported his own game from iPhone to Android within a week and wrote up what he did steps by steps. Here is his journey: http://www.philhassey.com/blog/2010/08/03/porting-galcon-using-the-android-ndk/
You could have a look at Apportable which allows to generate an Android app from an existing Objective-C code base. See this article too.
there is a fork of the gcc that supports objective-c on the android by patching the NDK on
http://code.google.com/p/android-gcc-objc2-0/. But it's considered beta at the moment and i'm not sure if jni/java bridges are already implemented
I have been doing a lot of work on this front — for example by creating my own C++ base framework that does not depend on STL (called Platform Core) and writing the core of the next version of my iOS app with that, so that I can easily port it to Android and whatever else has a C++ compiler and strikes my fancy.
I suggest having a (ick, I can't believe I'm about to say this, but eh), ahem, having a C++ core (there, I said it!) so it can be easily ported.

creating a reusable library in XCode 3.2

How do I create a reusable library/module in XCode 3.2? What I want to do is create a bunch of classes that provide certain functionality compile them into some kind of library, add such a library to an existing xcode project and use the classes in it.
I come from .NET world so what I want to do is basically to create an equivalent of 'assembly' and then reference it somehow in my XCode project.
I am developing for iOS btw.
If you add a target called static library you will get the equivalent of an assembly, just put all the sources in the target and decide what headers should be published and what should be hidden to the user of your library.
What you are looking to do is create a 'framework'.
This page has some useful information.
http://developer.apple.com/mac/library/documentation/MacOSX/Conceptual/BPFrameworks/Frameworks.html