I am executing the following javascript code on iOS using the JavaScriptCore framework. Javascript code verified.
var myCallback = undefined; *browserify logic* { 1: [function(require, module, exports) { var q = require('./user'); var p = new Promise(function(resolved, reject) { myCallback = function() { resolved('test'); } }); p.then(function(x) {printFunc('test');}).catch(function(e){printFunc('test2');}); q(); }, { "./user": 2 }], 2: [function(require, module, exports) { function q() { printFunc("Callback called!"); myCallback(); printFunc("Callback called end!"); } module.exports = q; }, {}] }, {}, [1]);
printFunc is a method implemented in Swift that just prints something for the console. Here is the implementation:
let printFunction : @convention(block) (String) -> String = {input in print("|\(input)|") return "" }
The problem is that I get the following error:
|Callback called!| Error compiling builtin: Invalid private name '@capabilities' |Callback called end!|
Even stranger, if I delete the βCallback called!β Fingerprints and "Callback call end!" the code runs without errors and it prints a "test".
Have you guys encountered this strange behavior? Is this a known bug with the implementation of Promise?
source share