Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/appcoda/JavaScriptCoreDemo
A Demo of JavaScriptCore in Swift
https://github.com/appcoda/JavaScriptCoreDemo
javascript swift swift-framework xcode8
Last synced: about 1 month ago
JSON representation
A Demo of JavaScriptCore in Swift
- Host: GitHub
- URL: https://github.com/appcoda/JavaScriptCoreDemo
- Owner: appcoda
- Created: 2017-02-17T05:38:51.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-02-17T05:44:59.000Z (almost 8 years ago)
- Last Synced: 2024-08-03T09:12:38.458Z (4 months ago)
- Topics: javascript, swift, swift-framework, xcode8
- Language: Swift
- Size: 75.2 KB
- Stars: 51
- Watchers: 8
- Forks: 11
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-star - JavaScriptCoreDemo
README
# Using JavaScriptCore Framework in Swift Projects
For a long time I wanted to write a post about how Swift and JavaScript can be tied together, and lead eventually to more powerful and rich-featured apps. Being able to embed JavaScript code in iOS projects is not something that you hear for first time, but if you have never tried to do that then you should really read this and find out how simple is to do magical things with just a few actions. The one that makes that magic available has a name, and is called JavaScriptCore framework.
You might be thoughtful about that, and wondering why someone would really like to use JavaScript when everything can be done in Swift. I admit that I was thoughtful too in the beginning, but here are some good reasons that answer to the above:
* iOS developers that were used to write web apps and they miss JavaScript-ing, can take the maximum out of the JavaScriptCore framework coding again using their favourite language.
* There might exist JavaScript libraries that perform specific tasks suitable for your needs, and there’s nothing equivalent in Swift or you have to do it on your own. Why not to use them?
* It’s possible that some tasks are easier to be handled in JavaScript.
* You want to modify the behaviour of your app remotely. In that case the JavaScript code resides on a server and not locally in the app’s bundle. Be careful though, because it’s easy to end up with a disaster.
* You could possibly make your app more flexible and powerful.
* You are curious enough and you want to use JavaScript in your iOS projects.Of course, you can think more than the above, but even these are good reasons to make you want to get started with JavaScript in iOS. Now that you feel the excitement too, let me underline a few necessary technical details. First off, JavaScript execution has its own environment, or to put it in a better way, a virtual machine where it runs into. In the JavaScriptCore framework, the JSVirtualMachine class represents programmatically that virtual machine, but usually you won’t have to deal directly with it. It’s possible to have multiple virtual machines running in an app, but they cannot exchange any data directly.
For the full tutorial, you can refer to this link:
http://www.appcoda.com/javascriptcore-swift/