How to build JavaScriptCore for iOS device? - javascript

I've downloaded Webkit nightly build. I open JavaScriptCore and built it. Compilation done without any error. But the output was a Framework contains only OS X binary. I tried unchecking 'build active architecture only' but only desktop architectures built. (I looked in the binary with lipo tool)
Is there any simple way to do this? I'm expecting static library can be linked to my iOS app project. I'm trying to embed JSC as in-game script engine.

It looks like there is an XCode project for JavaScriptCore that is part of the WebKit codebase. I was able to change the target SDK to iOS and the target architecture to arm6/arm7, and the dynamic framework built fine. You'll need to compile it to a static library, of course, so you'll need to create a new static library target for iOS and copy everything under Targets->JavaScriptCore into your new static library target. It may be a little tricky, but it might work.

I forked phoboslab's repo and updated it to the latest verson from WebKit (as of last friday). It is compatible with iOS 5 and 6 and includes the Objective-C to Javascript bridge to be featured in iOS 7 (no private frameworks or function used).
You can find the repo on GitHub at:
https://github.com/darionco/JavaScriptCore-iOS
I also added a ZIP file to the repo containing the library (.a) and needed header files for convenience.
Cheers!

Related

How does Apache Cordova and ionic framework interact native-ly?

I'm trying to find out how does Apache Cordova & Ionic Framework work?
I searched all over the internet and all I get is,
it is a wrapper around html/css/js and it uses the native web view to interact with native feature. But, you still deploy the native-ly. (That means .apk for Android, e.g.)
But, what I'm interested in is
Is Apache Cordova and Ionic Framework entirely written in javascript?
How do they interact with native mobile platform?
Does cordova/ionic get bundled with .apk file to mediate between the native web view and source code?
I believe what I'm interested in bit of low level detail.
If anybody could shed some light or point me to the resource (which I couldn't find) , it'd be great.
Thanks.
Apache Cordova provides a basic native app responsible for:
Displaying a Webview (UIWebkit by default for iOS, but you can switch to WKWebkit using a plugin. For Android, the "android browser" webview is used up to Android 4.4. From Android 5 (API 21), the webview is basically Chrome for Android).
Allowing the JavaScript running into this webview to "call" (execute) native code thanks to Cordova plugins. This is possible because system Webviews can interact with native code.
Ionic Framework (v1) is made of HTML, JavaScript and CSS (v2 is developed in TypeScript, which is a typed superset of JavaScript). The version 1 relies on AngularJS as a frontend JavaScript framework and helps developers writing "native-like" webapps by providing features like Gestures management, Infinite scrolling, Layouts (Menu, Tabs, Lists...), etc. The version 2 relies on Angular 2 and provides additional components (Date picker, Split panel...) and features (Ionic Native, a JavaScript API which tends to "standardize" the way you use Cordova plugins).
Ionic can be used without Cordova, if you simply want to create a web app (this is still HTML, JavaScript, and CSS). Cordova allows you to put this web app into a native shell. When an hybrid app (Cordova, the plugins you installed, and your web app) is bundled into an .ipa or an .apk, the html/javascript/css codes are moved into a specific folder, where Cordova expects to find an index.html (by default) to load in the Webview.
PS: My english is not perfect but I'd be glad to give more details if a point is not clear.
EDIT:
Please can you answer my specific questions in my post?
Sure!
Apache Cordova is made of JavaScript and Native code. See projects like cordova-android (JavaScript + Java), cordova-ios (JavaScript + Objective-C). Each mobile operating system has a dedicated "platform". When you start a new Cordova project, most of the time, the first operation you do is cordova platform add <platform> (iOS, Android...). These are the codes being loaded. Ionic Framework is a "pure-web" framework, made of HTML, JavaScript and CSS.
Apache Cordova interacts with native mobile platform as any native app: using the system APIs. The webview can interact with both your web app (of course) and the native code, thanks to platform-specific "bridges" (the native code embedded in cordova-android, cordova-ios, cordova-windows, allows that). You have to write a plugin in order to call native code from your JavaScript. For Android, it consists in extending the CordovaPlugin class and overriding the method execute (for instance: cordova-plugin-splashscreen).
The .apk (android) or .ipa (iOS) generated by cordova build (if you're using the cordova-cli) gathers together both the native shell (cordova-android for Android, cordova-ios for iOS) and your webapp. At startup, the main activity/view of Cordova is instantiated, loads the webview, which itself loads your webapp.

Electron UI for Golang Program?

I'd like to make a GUI in Electron for a Desktop Application written in Go (currently it's a command line tool).
What's the convention for communicating between the Electron and Go processes?
Would simply using the Go binary as an API work? Some sort of websocket communication?
You can use go-astilectron it allows you to build cross-platform GUI apps with GO and HTML/JS/CSS (powered by Electron) (disclosure: I'm the author)
The interaction of an application written in electron with its backend is exactly like a Web browser, therefore you have the same options (Web Api, Web Sockets, Ajax, etc.)
You can execute your command line app from your Electron app via child_process.spawn and communicate with it via stdin/stdout.
Murlock
Is an Electron wrapper for Golang to make it easy for this kind of app for Mac. They're working on Windows and looking for contributions for the other platforms.
Similarly to Murlock, may I dare to suggest Webview library. It's a thin wrapper over Webkit and MSHTML that runs on Windows 7+, MacOS, Linux and OpenBSD.
It is much smaller and easier than Electron. Also the resulting apps are smaller and less memory-hungry.
You may have a look at https://github.com/zserge/webview/tree/master/examples/todo-go for a Todo app example that compiles into a small standalone binary.
I've been looking exactly on how to run ElectronJS backend with Go to build a native desktop application.
you can use extraResources with process.resourcesPath variable to get into the Resources folder. and execute your binary. its not very recommended though.
Other option to use: https://github.com/wailsapp/wails
Its very lightweight and can export your app to MacOS and Windows.
Checkout muon which is best described by their readme:
Muon is a lightweight alternative to Electron written in Golang in about ~300 LoC, using Ultralight instead of Chromium. Ultralight is a cross-platform WebKit rewrite using the GPU to target embedded desktop applications that resulted in a fast, lightweight, and low-memory HTML UI solution that blends the power of Chromium with the small footprint of Native UI.
I have not used it myself but it looks very promising!

Distribute Single Page Application as native desktop software

Is it possible to pack s single page application (its JavaScript files and images and all the assets) so that it can be distributed as a native
desktop application? Like having an instance of Chrome without any button that just runs your application offline.
I've used software that seems to be crafted like that, for example TweetDeck by Twitter gives me the impression of being just the web-version of TweetDeck packed in some way to run in a context that is not your standard browser.
You can use NW.js (previously Node WebKit) or Electron to do just that.
There's NW.js.
To package nodejs / html apps on the desktop.
You can do it by implementing a headless browser application.
There is an open source web browser engine here https://www.webkit.org/.
You incorporate it in a native application and parse the source files.
The webkit documentation presumably contains the specifics, have fun :)
Very much possible and all HTML5 apps are doing that, all your need is this:
https://cordova.apache.org/

A Productive Javascript/Phonegap Development Environment

I've been building Android apps for a few years now, and I've arrived to this working setup:
Intellij Idea IDE write/debug
Genymotion "Emulator"
Physical Device (only when needed)
Git
Ant (probably should move to Gradle) Release/Debug builds
And now I'm looking to form an equally productive environment for Javascript (Phonegap, etc), for Android/iOS/Win8Phone.
I want to avoid the "nice-text-editor-only" solution (I believe a full IDE is superior in productivity terms).
Any suggestions?
Try Brackets editor http://brackets.io/. It's a nice editor to code the web. Phonegap plugins also available for this editor. Just take a look at this editor. Make sure to download the version of Brackets with Phonegap Plugin compatibility.
For the Cordova/Phonegap app I developed, I used cloud9. In my workflow, I would first get things working in my browser, then occasionally do builds with Adobe's Phonegap Build service to work out the kinks on my mobile devices.
The nice thing about c9 is you'll have a public URL for the website you're developing so you can preview it in your device's browser, which is typically closer to the environment you'll get with Phonegap.
The weinre debugging tool, although slow if you're running it through http://debug.phonegap.com/, can really help track down problems when debugging on mobile devices.

PhoneGap Build Service "Build in HTML5, CSS, JavaScript" claim

The PhoneGap build service says you can build an app in HTML5, CSS, and JavaScript. However, The phonegap.js is not available for each device (latest download PhoneGap 1.8.1 does not have one for Bada or iOS). So I think the build service is meant to save us from creating the shells for each environment, but I fail to see how the PhoneGap API is supposed to work.
I thought the idea too was that you could build one code base for each environment. I know there are quirks, but why is there a separate phonegap.js file for Android, WebOS, etc.?
The lack of documentation has me confused.
In my experience, there are separate files for each but when using phonegap build if you want to include a universal file for the build there is a way, put <script src="phonegap.js"></script> in your index.html file and don't include any js files, you actually don't even need the phonegap.js file, when I did this and ran it through phonegap build it attached the appropriate .js file to the appropriate build and I suddenly could use the phonegap API's for all the builds I was testing
The phonegap framework is made for specific Mobile Operating Systems. The reason why there are so many is because each framework is for each type of operating system. Like for games, most only work for Windows and some for mac, but very little support for Linux based systems. Phonegap creates APIs for using the camera and other functionalities of the operating system.
Phonegap has their tutorials to show you how to install for iOS and Android. I have not developed for newer systems.
Many people use jQueryMobile to develop with PhoneGap to create a nice simple mobile application.
I hope this helps.
Whilst there are different phonegap.js files for each device, they are very similar (I found this out because I accidentally copied it from an iOS project to the Android one a few times). The differences are important but they do pretty-much work as-is.
The main reason they differ is that they just expose the underlying functionality provided by the Phonegap device-native code (Java, OC etc), which IS device-dependent. The Phonegap devs just take care of hiding that from you. All of the phonegap.js files expose the same functionality, they just connect sometimes to different places 'on the inside'. Hence the differences.
Most source 'you or I' would write for a Phonegap app is device-independent as a result of the above.

Categories

Resources