sitefinitysteve / nativescript-google-analytics

Apache License 2.0
23 stars 14 forks source link

Is this plugin supported in AoT (Ahead of time compilation) in {N} + Angular #32

Open VladimirAmiorkov opened 7 years ago

VladimirAmiorkov commented 7 years ago

Hi,

I am experiencing some errors when I am packaging a project for iOS that uses this plugin. I am doing this workflow for bundling the app and I am getting this error once the app is opened:

file:///app/bundle.js:10941:25: JS ERROR TypeError: Attempted to assign to readonly property. Mar 18 17:54:12 com.apple.CoreSimulator.SimDevice.8A380AE0-BE8A-464E-B1E9-12E1D1F1E55A.launchd_sim[433] (UIKitApplication:com.cobbl.app[0xd1af][5260]): Service exited due to Segmentation fault: 11

This line bundle.js:10941:25 is the bundled code for the initialization of the plugin via the delegate on iOS as described here.

Workaround: What I ended up doing is to follow this article of extending the UIResponder:

import * as applicationModule from "application";

if (applicationModule.ios) {
    var MyAppDelegate = UIResponder.extend({
            // My custom logic here
            return true;
        }

    }, {
            name: "MyAppDelegate",
            protocols: [UIApplicationDelegate]
        });

    applicationModule.ios.delegate = MyAppDelegate;
}
sitefinitysteve commented 7 years ago

Can i get you to cross post to the forums? http://forum.nativescript.org I have no NG2 experience with NS let alone AoT :)

VladimirAmiorkov commented 7 years ago

Hi @sitefinitysteve , Sure I also think to look into this myself and see if I can fix it. It looks to be an issue with the way an UIResponder in iOS is extended since the code for workaround I posted works in AoT Angular.