应用程序在使用NewRelic框架的设备上启动时崩溃

时间:2015-08-29 21:17:38

标签: ios crash newrelic viewdidload

我使用基于Swift的应用程序与NewRelicAgent.framework集成...

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Register the analytics app
    NewRelicAgent.startWithApplicationToken("AA****************************6");

应用程序在LoginViewController上崩溃,启动时第一个视图控制器,带有以下日志 -

0   libsystem_c.dylib               0x00000001978d1690 __sfvwrite + 0
1   libsystem_c.dylib               0x00000001978d8958 __vfprintf + 11352
2   libsystem_c.dylib               0x00000001978f367c __v2printf + 584
3   libsystem_c.dylib               0x0000000197886208 _vsnprintf + 300
4   libsystem_c.dylib               0x0000000197886c54 snprintf_l + 20
5   CoreFoundation                  0x00000001859d7018 __CFStringAppendFormatCore + 11580
6   CoreFoundation                  0x00000001859d42a0 _CFStringCreateWithFormatAndArgumentsAux2 + 244
7   Foundation                      0x000000018681a444 -[NSPlaceholderString initWithFormat:locale:arguments:] + 168
8   Foundation                      0x000000018681a304 +[NSString stringWithFormat:] + 72
9   Zimplifi                        0x00000001001558e0 +[NRMAThreadLocalStore currentThreadDictionary] (NRMAThreadLocalStore.m:238)
10  Zimplifi                        0x00000001001540b8 +[NRMAThreadLocalStore threadLocalTrace] (NRMAThreadLocalStore.m:36)
11  Zimplifi                        0x0000000100154a80 +[NRMAThreadLocalStore prepareSameThread:child:withParent:] (NRMAThreadLocalStore.m:126)
12  Zimplifi                        0x0000000100154500 +[NRMAThreadLocalStore pushChild:forParent:] (NRMAThreadLocalStore.m:91)
13  Zimplifi                        0x0000000100123768 +[NRMATraceController newTraceSetup:parentTrace:] (NRMATraceController.m:310)
14  Zimplifi                        0x0000000100123c6c +[NRMATraceController enterMethod:fromObject:parentTrace:traceCategory:withTimer:] (NRMATraceController.m:374)
15  Zimplifi                        0x0000000100123a40 +[NRMATraceController enterMethod:fromObject:parentTrace:traceCategory:] (NRMATraceController.m:338)
16  Zimplifi                        0x000000010010e92c NRMA__beginMethod (NRMAMethodProfiler.m:1051)
17  Zimplifi                        0x000000010010e500 NRMA__voidParamHandler (NRMAMethodProfiler.m:705)
18  Zimplifi                        0x00000001000677c4 Zimplifi.ZViewController.viewDidLoad (Zimplifi.ZViewController)() -> () (ZViewController.swift:14)
19  Zimplifi                        0x0000000100053d1c @objc Zimplifi.LoginViewController.viewDidLoad (Zimplifi.LoginViewController)() -> () (LoginViewController.swift:27)

LoginViewController是常见ZViewController ....

的子类
class ZViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

    }
}

class LoginViewController: ZViewController {
...
...
}

我的任何视图控制器或项目中都没有与NewRelicAgent相关的任何其他代码(项目目标中的RunScript除外)。

有什么想法解决它?

编辑:使用FIX:)

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        // Register the analytics app
        NewRelicAgent.enableFeatures(NRMAFeatureFlags.NRFeatureFlag_SwiftInteractionTracing);
        NewRelicAgent.startWithApplicationToken("AA****************************6");

        // Your app specific code.......

    }

// Add 'dynamic' before viewDidLoad method and probably any other view life cycle method or method to be traced for analytics
class ZViewController: UIViewController {

    override dynamic func viewDidLoad() {
         super.viewDidLoad()
         // Your implementation...
    }
}

2 个答案:

答案 0 :(得分:2)

Swift应用程序需要New Relic中的一些额外配置:

https://docs.newrelic.com/docs/mobile-monitoring/new-relic-mobile/getting-started/enabling-swift-interaction-traces

您是否已将dynamic声明修饰符添加到方法中并使用功能标志启用了Swift Interaction跟踪?

答案 1 :(得分:0)

其中一个解决方法是避免UIViewController的多级继承 -

PRIMARY KEY

似乎目前NewRelic框架在继承/快速采用方面存在一些问题。