{ "id": "172089", "key": "TIMOB-26318", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "20232", "name": "Hyperloop 3.1.2", "archived": false, "released": true } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2018-08-21T12:58:13.000+0000", "created": "2018-08-18T13:03:05.000+0000", "priority": { "name": "Critical", "id": "1" }, "labels": [], "versions": [ { "id": "20222", "name": "Hyperloop 3.1.1", "archived": false, "released": true } ], "issuelinks": [], "assignee": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "updated": "2018-08-24T07:48:39.000+0000", "status": { "description": "A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.", "name": "Resolved", "id": "5", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "13715", "name": "Hyperloop", "description": "Hyperloop project" } ], "description": "When attempting to register a UIApplicationDelegate instance through hyperloop the following exception is thrown:\r\n\r\n{noformat}\r\n[ERROR] : can't find selector registerApplicationDelegate for \r\n[ERROR] : -[HyperloopPointer registerApplicationDelegate]: unrecognized selector sent to instance 0x60c00009c520\r\n[ERROR] : Script Error {\r\n[ERROR] : column = 26;\r\n[ERROR] : description = \"-[HyperloopPointer registerApplicationDelegate]: unrecognized selector sent to instance 0x60c00009c520\";\r\n[ERROR] : line = 128;\r\n[ERROR] : message = \"-[HyperloopPointer registerApplicationDelegate]: unrecognized selector sent to instance 0x60c00009c520\";\r\n[ERROR] : name = NSInvalidArgumentException;\r\n[ERROR] : nativeStack = \"1 libobjc.A.dylib 0x0000000114af1031 objc_exception_throw + 48\\n2 CoreFoundation 0x0000000115beb784 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132\\n3 Hyperloop Test 0x000000010d1ab106 +[HyperloopUtils invokeSelector:args:target:instance:] + 4646\\n4 Hyperloop Test 0x000000010d19f1a1 Dispatch + 1489\\n5 JavaScriptCore 0x000000010d5a0b63 _ZN3JSC19APICallbackFunction4callINS_18JSCallbackFunctionEEExPNS_9ExecStateE + 595\\n6 ??? 0x000002c074094034 0x0 + 3025603739700\\n7 JavaScriptCore 0x000000010d567d00 llint_entry + 29438\\n8 JavaScriptCore 0x000000010d567d00 llint_entry + 29438\\n9 JavaScriptCore 0x000000010d56081a vmEntryToJavaScript + 304\\n10 JavaScriptCore 0x000000010da41d43 _ZN3JSC7JITCode7executeEPNS_2VMEPNS_14ProtoCallFrameE + 147\\n11 JavaScriptCore 0x000000010d9fd617 _ZN3JSC11Interpreter14executeProgramERKNS_10SourceCodeEPNS_9ExecStateEPNS_8JSObjectE + 12343\\n12 JavaScriptCore 0x000000010dc442c4 _ZN3JSC8evaluateEPNS_9ExecStateERKNS_10SourceCodeENS_7JSValueERN3WTF8NakedPtrINS_9ExceptionEEE + 308\\n13 JavaScriptCore 0x000000010d59fec2 JSEvaluateScript + 482\\n14 Hyperloop Test 0x000000010cece121 -[KrollBridge evalFileOnThread:context:] + 1281\\n15 Hyperloop Test 0x000000010ced3f0c -[KrollInvocation invoke:] + 124\\n16 Hyperloop Test 0x000000010ced53df -[KrollContext invoke:] + 159\\n17 Hyperloop Test 0x000000010ced5775 -[KrollContext invokeOnThread:method:withObject:callback:selector:] + 165\\n18 Hyperloop Test 0x000000010cece293 -[KrollBridge evalFile:callback:selector:] + 115\\n19 Hyperloop Test 0x000000010cecf105 -[KrollBridge didStartNewContext:] + 2565\\n20 Hyperloop Test 0x000000010ced605b -[KrollContext main] + 1819\\n21 Hyperloop Test 0x000000010ced51b6 __21-[KrollContext start]_block_invoke + 38\\n22 libdispatch.dylib 0x0000000116da86cb _dispatch_call_block_and_release + 12\\n23 libdispatch.dylib 0x0000000116da9709 _dispatch_client_callout + 8\\n24 libdispatch.dylib 0x0000000116db3708 _dispatch_main_queue_callback_4CF + 1279\\n25 CoreFoundation 0x0000000115b2cc99 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9\\n26 CoreFoundation 0x0000000115af0ea6 __CFRunLoopRun + 2342\\n27 CoreFoundation 0x0000000115af030b CFRunLoopRunSpecific + 635\\n28 GraphicsServices 0x0000000118ad4a73 GSEventRunModal + 62\\n29 UIKit 0x000000010f7dd057 UIApplicationMain + 159\\n30 Hyperloop Test 0x000000010cebae04 main + 100\\n31 libdyld.dylib 0x0000000116e1e955 start + 1\\n32 ??? 0x0000000000000001 0x0 + 1\";\r\n[ERROR] : sourceURL = \"file:///Users/richard/Library/Developer/CoreSimulator/Devices/21CF36EB-29EB-4B54-980E-5E6B514B4869/data/Containers/Bundle/Application/EEC17584-4B00-4E92-A39A-8F5E8DDECBCC/Hyperloop%20Test.app/hyperloop/titanium/tiapp.js\";\r\n[ERROR] : stack = \" at dispatch@[native code]\\n at value@file:///Users/richard/Library/Developer/CoreSimulator/Devices/21CF36EB-29EB-4B54-980E-5E6B514B4869/data/Containers/Bundle/Application/EEC17584-4B00-4E92-A39A-8F5E8DDECBCC/Hyperloop%20Test.app/hyperloop/titanium/tiapp.js:128:26)\\n at global code@file:///Users/richard/Library/Developer/CoreSimulator/Devices/21CF36EB-29EB-4B54-980E-5E6B514B4869/data/Containers/Bundle/Application/EEC17584-4B00-4E92-A39A-8F5E8DDECBCC/Hyperloop%20Test.app/app.js:31:40)\";\r\n[ERROR] : }\r\n{noformat}\r\nI'm providing an example project where I've copied and pasted the example code from Titanium's wiki", "attachment": [ { "id": "65453", "filename": "Hyperloop_Test.zip", "author": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-18T13:03:00.000+0000", "size": 4918959, "mimeType": "application/zip" } ], "flagged": false, "summary": "Hyperloop: iOS - TiApp Utility Class methods throw selector-error", "creator": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "subtasks": [], "reporter": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "environment": "CLI 7.0.5\r\nSDK 7.3.0.GA\r\nHyperloop 3.1.1", "closedSprints": [ { "id": 1065, "state": "closed", "name": "2016 Sprint 17 SDK", "startDate": "2018-08-13T17:39:36.846Z", "endDate": "2018-08-27T17:39:00.000Z", "completeDate": "2018-08-29T16:10:57.013Z", "originBoardId": 114 } ], "comment": { "comments": [ { "id": "440873", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "This looks valid - although I tested it just a few weeks ago. Let me check this on Monday and come back to you asap!\r\n\r\n*EDIT*: Found it. What a silly error, sorry for that! You can patch your Hyperloop simply by going to {{/modules/iphone/hyperloop/3.1.1/hooks/generate/templates/builtins/titanium.js}} and change line 132 (the selector) from {{registerApplicationDelegate}} to {{registerApplicationDelegate:}}. Same goes for the {{unregisterApplicationDelegate}} and {{unregisterApplicationDelegate:}} if used. It will be added to Hyperloop 3.1.2 asap!\r\n\r\n*EDIT 2*: Ok, so the method works now, but the selector does not seem to be picked up so far. Debugging the iOS source, it looks like the [{{tryToInvokeSelector:}} call|https://github.com/appcelerator/titanium_mobile/blame/7_3_X/iphone/Classes/TiApp.m#L694] returns {{NO}}, indicating that the method selector cannot be resolved. Then I debugged all methods that the generated Hyperloop-class has and it indeed includes the selector:\r\n{code:objc}\r\n- (char) application:(id)arg1 didFinishLaunchingWithOptions:(id)arg2; (0x106ee60c0)\r\n{code}\r\nYou may note that it uses {{char}} instead of {{BOOL}}, but that should still work, since {{BOOL}} extends the {{char}} type. I tried with another selector ({{applicationDidEnterBackground:}}) and it also did not work. The selector for that one looks like this:\r\n{code:objc}\r\n- (void) applicationDidEnterBackground:(id)arg1; (0x106ee6c10)\r\n{code}\r\nWhich is also fine. The only difference is that the \"arg1\" is usually called \"application\", but that should not matter for the selector itself. Finally, I verified that the Hyperloop-defined class indeed implements the {{UIApplicationDelegate}} protocol by using the objc-runtime API {{class_copyProtocolList}} to introspect the class protocol definitions. \r\n\r\nI am running out of ideas, but it may be the selector-argument naming causing this. It works with native modules, so it must be a Hyperloop bug, not SDK bug.\r\n\r\n*EDIT 3*: I create a [pull request|https://github.com/appcelerator/hyperloop-examples/pull/78] to show my current state on this.\r\n\r\n*EDIT 4*: It may be that our Hyperloop-defined classes do not export a proper public header and therefore do not respond to the {{respondsToSelector}} API.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-18T19:14:43.000+0000", "updated": "2018-08-19T13:14:48.000+0000" }, { "id": "440930", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hey [~rlustemberg], discard my previous comments. The issue why it wasn't fired after the initial fix was that I provided the wrong instance to {{registerApplicationDelegate}}. Passing the correct one works fine and should do for you as well. Right now, we are still investigating why the \"this\" from a non-require-based scope does not work (e.g. if you use {{defineClass}} in the same file as the execution). Let me know if your test cases work already! [Working example here|https://github.com/appcelerator/hyperloop-examples/pull/78/files]", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-21T10:59:32.000+0000", "updated": "2018-08-21T11:15:21.000+0000" }, { "id": "440933", "author": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "body": "Great news!. I’ll test later today and let you know. BTW, is there a trick to be able to debug Hyperloop using Xcode. Out of the box it doesn’t work on my case. The Hyperloop object is not available and an exception is thrown. \r\n", "updateAuthor": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-21T12:30:38.000+0000", "updated": "2018-08-21T12:30:38.000+0000" }, { "id": "440934", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Yey. The Hyperloop stubs (or \"wrappers\") are generated based on the usage and represent virtual classes. Using Chrome dev-tools (Android) or Safari (iOS), you could debug it down to the stubs and see the invocations, but everything else is done internally using reflection.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-21T12:53:56.000+0000", "updated": "2018-08-21T12:53:56.000+0000" }, { "id": "440939", "author": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "body": "So if I'm using Hyperloop in a project, but also using iOS native modules, I won't be able to debug the latter because Hyperloop won't work?", "updateAuthor": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-21T13:26:11.000+0000", "updated": "2018-08-21T13:26:11.000+0000" }, { "id": "440941", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "I think then I misunderstood your question. You can always debug the project. You only need to make sure the Hyperloop stubs are copied to your app target, e.g. by copying the stubs from build/hyperloop/ios/js/* to your Xcode-target and be sure that they are copied to your app bundle. But this is highly unrelated to this ticket. To keep this one clean, we should focus on this one.", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-21T13:30:02.000+0000", "updated": "2018-08-21T13:30:02.000+0000" }, { "id": "440943", "author": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "body": "Supercool, that's all I needed to know :) . I'll report any issue I might have registering the UIApplicationDelegate objects. ", "updateAuthor": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-21T13:40:17.000+0000", "updated": "2018-08-21T13:40:17.000+0000" }, { "id": "440969", "author": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "body": "Hyperloop 3.1.2 Beta can be checked [here|https://github.com/appcelerator-modules/hyperloop-builds/releases/tag/v3.1.2-beta.1].", "updateAuthor": { "name": "hknoechel", "key": "hansknoechel", "displayName": "Hans Knöchel", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-21T21:59:09.000+0000", "updated": "2018-08-21T21:59:09.000+0000" }, { "id": "441037", "author": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "body": "It's working on my use case (registering app delegate methods for the XMPP framework). And indeed, it's necessary to generate the class in a separate require, otherwise, the 'this' in the wrapper object does't survive the app resigning active. Defining the app delegate class on a separate file works correctly. I've tested with `didFinishLaunchingWithOptions` , `applicationDidBecomeActive` and `applicationWillResignActive`. Sorry I was a bit late in my reply.", "updateAuthor": { "name": "rlustemberg", "key": "rlustemberg", "displayName": "Richard Lustemberg", "active": true, "timeZone": "Europe/Berlin" }, "created": "2018-08-24T07:48:39.000+0000", "updated": "2018-08-24T07:48:39.000+0000" } ], "maxResults": 9, "total": 9, "startAt": 0 } } }