jscocoa
jscocoa copied to clipboard
Is the project discontinued?
The project doesn't work on ios 7 and later. Be a long time no one to maintain it. And I found that the latest committed in the Fork Network Graph is @palringosteve.
We managed to get it working from our fork on iOS 6 and later with the following steps:-
- Fork/clone our JSCocoa repo.
- Import libffi-iOS v3.0.13-ios from CocoaPods:-
- pod 'libffi', '3.0.13'
- Drag the following files from JSCocoa into your Xcode project:-
- iPhone/iPhone.bridgesupport
- iPhone/BurksPool.h & .m
- iPhone/GDataDefines.h
- iPhone/GDataXMLNode.h & .m
- iPhone/JavascriptCore-dlsym.h & .m
- iPhone/JavaScriptCore.h
- iPhone/JSBase.h
- iPhone/JSContextRef.h
- iPhone/JSObjectRef.h
- iPhone/JSStringRef.h
- iPhone/JSStringRefCF.h
- iPhone/JSValueRef.h
- JSCocoa/JSCocoaController.h & .m
- JSCocoa/JSCocoaPrivateObject.h & .m
- JSCocoa/JSCocoaFFIArgument.h & .m
- JSCocoa/JSCocoaFFIClosure.h & .m
- JSCocoa/JSCocoaLib.h & .m
- JSCocoa/BridgeSupportController.h & .m
- JSCocoa/class.js
- JSCocoa/jslint-jscocoa.js
- Initialise JSCocoa and load Javascript with the following code:-
NSString *contents = /* load JS into this variable */
// Fetch JS symbols
[JSCocoaSymbolFetcher populateJavascriptCoreSymbols];
// Load iPhone bridge support
NSString *pathToBridgeSupport = [[NSBundle mainBundle] pathForResource:@"iPhone" ofType:@"bridgesupport"];
[[BridgeSupportController sharedController] loadBridgeSupport:pathToBridgeSupport];
// Load JS class kit
JSCocoaController *cocoaController = [JSCocoaController sharedController];
[cocoaController setDelegate:self];
// Load JS main
BOOL success = [cocoaController evalJSString:contents] != NULL;
It's worth noting that as of 1 February 2015 Apple are requiring that apps built with the iOS 8 SDK include both 32- and 64-bit binaries and as of yet we have not been able to get our setup working in 64-bit mode.
@palringosteve , I have cloned your code, but I used liffi with the latest version and not used cocoapod, and I got some errors. I will follow your steps to try it again. Thanks !
Bad luck, it can't work. I got error like this:Warning: Error creating LLDB target at path '/xxxxxxx/Build/Products/Debug-iphonesimulator/xxxxxx.app'- using an empty LLDB target which can cause slow memory reads from remote devices.
1 0xb68909c JSC::JSLock::DropAllLocks::DropAllLocks(JSC::ExecState_) 2 0xb64d7af JSC::JSCallbackObjectJSC::JSGlobalObject::getOwnPropertySlot(JSC::JSObject_, JSC::ExecState_, JSC::PropertyName, JSC::PropertySlot&) 3 0xb6b33c2 JSC::JSProxy::getOwnPropertySlot(JSC::JSObject_, JSC::ExecState_, JSC::PropertyName, JSC::PropertySlot&) 4 0xb3cc38d JSC::JSObject::get(JSC::ExecState_, JSC::PropertyName) const 5 0xb69b24c JSObjectGetProperty 6 0x83dfb JSObjectGetProperty 7 0x8e00c +[JSCocoaController controllerFromContext:] 8 0x86fa5 jsCocoaObject_finalize 9 0xb649a2c JSC::JSCallbackObjectData::finalize(JSC::HandleJSC::Unknown, void_) 10 0xb84a08e JSC::WeakBlock::sweep() 11 0xb84c0e8 JSC::WeakSet::sweep() 12 0xb72a72c JSC::MarkedBlock::sweep(JSC::MarkedBlock::SweepMode) 13 0xb72a365 JSC::MarkedAllocator::tryAllocateHelper(unsigned long) 14 0xb729470 JSC::MarkedAllocator::allocateSlowCase(unsigned long) 15 0xb69d894 JSC::JSCallbackObjectJSC::JSDestructibleObject::create(JSC::ExecState_, JSC::JSGlobalObject_, JSC::Structure_, OpaqueJSClass_, void_) 16 0xb699615 JSObjectMake 17 0x83b5d JSObjectMake 18 0x919ec -[JSCocoaController newPrivateFunction] 19 0x895a5 jsCocoaObject_getProperty 20 0xb64b022 JSC::JSCallbackObjectJSC::JSDestructibleObject::getOwnPropertySlot(JSC::JSObject_, JSC::ExecState_, JSC::PropertyName, JSC::PropertySlot&) 21 0xb70ebb9 llint_slow_path_get_by_id 22 0xb71c973 llint_entry 23 0xb71eef6 llint_entry 24 0xb71aab6 callToJavaScript 25 0xb5f8d11 JSC::JITCode::execute(JSC::VM_, JSC::ProtoCallFrame_) 26 0xb5da76e JSC::Interpreter::execute(JSC::ProgramExecutable_, JSC::ExecState_, JSC::JSObject_) 27 0xb43447a JSC::evaluate(JSC::ExecState_, JSC::SourceCode const&, JSC::JSValue, JSC::JSValue*) 28 0xb64799a JSEvaluateScript 29 0x8391e JSEvaluateScript 30 0x8e841 -[JSCocoaController evalJSFile:toJSValueRef:] 31 0x8e90c -[JSCocoaController evalJSFile:]
And it crashes at https://github.com/palringosteve/jscocoa/blob/master/iPhone/JavascriptCore-dlsym.m#L129