{"id":20571470,"url":"https://github.com/kf99916/jscontextfoundation","last_synced_at":"2026-04-21T06:06:41.394Z","repository":{"id":56916447,"uuid":"58784027","full_name":"kf99916/JSContextFoundation","owner":"kf99916","description":"JSContextFoundation is a Swift adapter for the JavaScriptCore Framework to build up the JavaScript runtime environment.","archived":false,"fork":false,"pushed_at":"2018-01-03T02:38:03.000Z","size":57,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-17T05:34:25.021Z","etag":null,"topics":["cocoapods","javascript","javascriptcore-framework","jscontext","swift","swift-adapter"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kf99916.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-14T01:48:58.000Z","updated_at":"2019-01-17T23:00:24.000Z","dependencies_parsed_at":"2022-08-20T21:20:23.173Z","dependency_job_id":null,"html_url":"https://github.com/kf99916/JSContextFoundation","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kf99916%2FJSContextFoundation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kf99916%2FJSContextFoundation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kf99916%2FJSContextFoundation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kf99916%2FJSContextFoundation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kf99916","download_url":"https://codeload.github.com/kf99916/JSContextFoundation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242187807,"owners_count":20086224,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","javascript","javascriptcore-framework","jscontext","swift","swift-adapter"],"created_at":"2024-11-16T05:16:19.539Z","updated_at":"2026-04-21T06:06:41.327Z","avatar_url":"https://github.com/kf99916.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSContextFoundation\nJSContextFoundation is a Swift adapter for the JavaScriptCore Framework to build up the JavaScript runtime environment.\n\n[![CocoaPods](https://img.shields.io/cocoapods/dt/JSContextFoundation.svg)](https://cocoapods.org/pods/JSContextFoundation)\n[![GitHub stars](https://img.shields.io/github/stars/kf99916/JSContextFoundation.svg)](https://github.com/kf99916/JSContextFoundation/stargazers)\n[![GitHub forks](https://img.shields.io/github/forks/kf99916/JSContextFoundation.svg)](https://github.com/kf99916/JSContextFoundation/network)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/JSContextFoundation.svg)](https://cocoapods.org/pods/JSContextFoundation)\n[![Platform](https://img.shields.io/cocoapods/p/JSContextFoundation.svg)](https://github.com/kf99916/JSContextFoundation)\n[![GitHub license](https://img.shields.io/github/license/kf99916/JSContextFoundation.svg)](https://github.com/kf99916/JSContextFoundation/blob/master/LICENSE)\n\n## Requirements\n\n- iOS 8.0 or higher\n- Swift 2.3 or higher\n\n## Installation\n\n- [CocoaPods](http://cocoapods.org/):\n\nSwift 2.3\n```ruby\npod 'JSContextFoundation', '~\u003e 0.0.1'\n```\n\nSwift 3.1\n```ruby\npod 'JSContextFoundation', '~\u003e 0.1.1'\n```\n\n- [Swift Package Manager](https://swift.org/package-manager/):\n\nSwift 2.3\n```\n.Package(url: \"https://github.com/kf99916/JSContextFoundation.git\", majorVersion: 0.0.1)\n```\n\nSwift 3.1\n```\n.Package(url: \"https://github.com/kf99916/JSContextFoundation.git\", majorVersion: 0.1.1)\n```\n\n## JavaScript Runtime Environment\nJSContextFoundation builds up the global objects for the JavaScript runtime environment to allow you execute JavaScript code like as in browser or Node.js. Here is the support list for the global objects:\n\n```javascript\nglobal;\nwindow;\nconsole\n  .log([data][, ...]);\n  .info([data][, ...]);\n  .warn([data][, ...]);\n  .error([data][, ...]);\n```\n\n## Usage\n\n```swift\nimport JSContextFoundation\n\nlet jsContext = JSContextFoundation()\n```\n\n### Import JavaScript Module\nTo import JavaScript module, the source of module can be file path or URL: \n#### File Path\n\n```swift\nlet path = NSBundle(forClass: self.dynamicType).pathForResource(\"Module\", ofType: \"js\")!\ndo {\n  try jsContext.requireWithPath(path)\n} catch JSContextFoundationError.FileNotFound {\n  print(path + \" is not found\")\n} catch JSContextFoundationError.FileNotLoaded {\n  print(path + \" cannot be loaded\")\n} catch {\n  print(\"Unknow Exception\")\n}\n\n// ...\n```\n\n#### URL\n\n```swift\nlet url = NSURL(string: \"https://FQDN/Module.js\")!\njsContext.requireWithUrl(url, completionHandler: {error in\n   if let error = error {\n      switch error {\n        case JSContextFoundationError.FileNotFound:\n            print(url.absoluteString + \" is not found\")\n        case JSContextFoundationError.FileNotDownloaded:\n            print(url.absoluteString + \" is not downloaded\")\n        default:\n            print(\"Unknown Error\")\n        }\n        \n        return\n    }\n\n    //  ...\n})\n```\n\nAll other usage is the same as JSContext. See [JSContext in the Apple document](https://developer.apple.com/library/ios/documentation/JavaScriptCore/Reference/JSContext_Ref/index.html) for details.\n\n## Apps using JSContextFoundation\n\nIf you are using JSContextFoundation in your app and want to be listed here, simply create a pull request.\n\nI am always curious who is using my projects :)\n\n[Hikingbook](https://itunes.apple.com/app/id1067838748) - by Zheng-Xiang Ke\n\n![Hikingbook](apps/Hikingbook.png)\n\n## Author\n\nZheng-Xiang Ke, kf99916@gmail.com\n\n## License\nJSContextFoundation is available under the MIT license. See the LICENSE file for more info.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkf99916%2Fjscontextfoundation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkf99916%2Fjscontextfoundation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkf99916%2Fjscontextfoundation/lists"}