简体   繁体   中英

iOS app is only crashing on TestFlight build

I have an ios app in Swift.The app runs fine and does not crash when uploaded locally from xcode. But the app is crashing when uploaded from testflight. I found that there is nothing wrong in code. I have implemented Crashlytics in my app, it has given following report.

Crashed: com.apple.main-thread
EXC_BREAKPOINT 0x0000000100160fe4

Crashed: com.apple.main-thread
0  App                     0x100160fe4 HomeViewController.viewDidLoad() -> () (HomeViewController.swift:57)

1  App                     0x100161014 @objc HomeViewController.viewDidLoad() -> () (HomeViewController.swift)

2  UIKit                          0x18c373ec0 -[UIViewController loadViewIfRequired] + 1036

3  UIKit                          0x18c38b94c -[UIViewController __viewWillAppear:] + 132

4  UIKit                          0x18c5101d4 -[UINavigationController _startCustomTransition:] + 1144

5  UIKit                          0x18c42ab78 -[UINavigationController _startDeferredTransitionIfNeeded:] + 676

6  UIKit                          0x18c42a7e0 -[UINavigationController __viewWillLayoutSubviews] + 64

7  UIKit                          0x18c42a744 -[UILayoutContainerView layoutSubviews] + 188

8  UIKit                          0x18c37107c -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1200

9  QuartzCore                     0x189561274 -[CALayer layoutSublayers] + 148

10 QuartzCore                     0x189555de8 CA::Layer::layout_if_needed(CA::Transaction*) + 292

11 QuartzCore                     0x189555ca8 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32

12 QuartzCore                     0x1894d134c CA::Context::commit_transaction(CA::Transaction*) + 252

13 QuartzCore                     0x1894f83ac CA::Transaction::commit() + 504
14 QuartzCore                     0x1894f8e78 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 120

15 CoreFoundation                 0x1861f09a8 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32

16 CoreFoundation                 0x1861ee630 __CFRunLoopDoObservers + 372

17 CoreFoundation                 0x1861eea7c __CFRunLoopRun + 956

18 CoreFoundation                 0x18611eda4 CFRunLoopRunSpecific + 424

19 GraphicsServices               0x187b88074 GSEventRunModal + 100

20 UIKit                          0x18c3d9058 UIApplicationMain + 208

21 App                     0x1000d8688 main (NewProductData.swift:18)

22 libdyld.dylib                  0x18512d59c start + 4

I am not understanding anything from this reports, please help me out if anyone knows.

Here is viewDidload

  override func viewDidLoad() {
    super.viewDidLoad()
     Giving instance of HomeViewController to AppDelegate
      let appDele = UIApplication.shared.delegate as! AppDelegate
      appDele.homeVC = self
    token = FIRInstanceID.instanceID().token()!
//Method to handle Firebase token  
    UserDefaults.standard.set(token, forKey: "Notificationtoken")
    print("@@@@@@@@@@@@@@@@@@@@@@@ token provided is \(String(describing: token))")
     let tokenstr = UserDefaults.standard.value(forKey: "Notificationtoken") as! String
    if(token == tokenstr){
        handleFCMToken(token: tokenstr)
    }
    else{
        handleFCMToken(token: token!)

    }

    setUpNavBar()
    setPopUpImage()
    setUpcarousel()
    setUpDelegates()
    let help = Helper()

    help.setUpGoogleAnalytics(screenName: "Home")

    self.presenter = HomeViewPresenter(homeView: self)
    presenter.getCarousel()
    if(showProfile){
        ProfileClicked()
    }
    // Do any additional setup after loading the view.
}

And here is viewWillAppear

 override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    setUpUI()


}

and method of setupUI

 func setUpUI(){
    let wholesaler:Wholesaler = Helper.getWsProfile()

    DispatchQueue.main.async {
        self.wholesalerName.text = "Hello, \(wholesaler.wholesaler_name)"
        self.pdsPoints.text = "\(wholesaler.pdsPoints!)"
        self.visibilityPoints.text = "\(wholesaler.visibilityPoins!)"
    }
    iconNameString = ["SMS","Customer\n Groups","Visibility\n Contest","My\n Earnings","\(wholesaler.lastSchemeMonth!)\n Schemes","App\n News", "", "Contact\n Us"]

}

I think that viewing some code of your HomeViewController will give us more insight.

But here some comments:

  • Not sure about the full stack, but its seems weird that viewWillAppear is being called before viewDidLoad for some reason. Are you calling super correctly on those corresponding methods?
  • Have you try profiling the app using instruments in release mode vs debug mode? You can manage this on your schema settings.
  • Another hint, but I think it kind of advanced for your scenario, is the optimization level. Go to your target settings and search for Optimization Level , you'll notice it is different for debug and release. Sometimes complex algorithms with multiple blocks and/or threads may be affected by this.

Home it helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM