vladiulianbogdan vladiulianbogdan - 1 year ago 118
Javascript Question

'Error compiling builtin' while executing JavaScript code in JavaScriptCore

I execute the following javascript code in iOS using JavaScriptCore framework. The javascript code is browserified.

var myCallback = undefined;

*browserify logic*
1: [function(require, module, exports) {

var q = require('./user');

var p = new Promise(function(resolved, reject) {
myCallback = function() {

p.then(function(x) {printFunc('test');}).catch(function(e){printFunc('test2');});


}, {
"./user": 2
2: [function(require, module, exports) {
function q() {
printFunc("Callback called!");
printFunc("Callback called end!");
module.exports = q;
}, {}]
}, {}, [1]);

printFunc is a method implemented in Swift that just prints something to console. Here is the implementation:

let printFunction : @convention(block) (String) -> String = {input in
return ""

The problem is that I am receiving the following error:

|Callback called!|
Error compiling builtin: Invalid private name '@capabilities'
|Callback called end!|

Even more strange is that if I remove the prints "Callback called!" and "Callback called end!" the code executes without error and it prints "test".

Did you guys encountered this strange behaviour? Is it a known bug with Promise implementation?

Answer Source

This is a bug in the JavascriptCore in the Promise implementation. I opened a ticket at Apple and it is confirmed.

An workaround is to come with your own Promise implementation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download