iOS app is only crashing on TestFlight build - ios

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

Related

How to debug the .app crash in iOS simulator?

I have submitted my app to review and apple got back to me saying it crashes in launch. I got the .app file submitted to apple, and I installed it on the simulator.
xcrun simctl install booted /Users/venkatanandamuri/Desktop/prod\ crash/Myapp.app
It indeed crashed on launch.
The Mac console log shows nothing about the crash on simulator.
I got the crash log from Xcode device logs:
Last Exception Backtrace:
0 CoreFoundation 0x1d590a3a8 __exceptionPreprocess + 232
1 libobjc.A.dylib 0x1d4b0fd00 objc_exception_throw + 59
2 CoreFoundation 0x1d58229f8 -[NSObject+ 223736 (NSObject) doesNotRecognizeSelector:] + 143
3 CoreFoundation 0x1d590fd54 ___forwarding___ + 1411
4 CoreFoundation 0x1d5911b50 _CF_forwarding_prep_0 + 95
5 FBSDKCoreKit 0x105f67530 0x105f24000 + 275760
6 FBSDKCoreKit 0x105f673ac 0x105f24000 + 275372
7 FBSDKCoreKit 0x105f2df28 0x105f24000 + 40744
8 FBSDKCoreKit 0x105f2b0b0 0x105f24000 + 28848
9 FBSDKCoreKit 0x105f2afbc 0x105f24000 + 28604
10 FBSDKCoreKit 0x105f70fe0 0x105f24000 + 315360
11 FBSDKCoreKit 0x105f7078c 0x105f24000 + 313228
12 FBSDKCoreKit 0x105f2bb28 0x105f24000 + 31528
13 FBSDKCoreKit 0x105f34cac 0x105f24000 + 68780
14 Foundation 0x1d638115c __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_2 + 27
15 CoreFoundation 0x1d5878acc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 27
16 CoreFoundation 0x1d5878a8c ___CFXRegistrationPost_block_invoke + 67
17 CoreFoundation 0x1d5877f30 _CFXRegistrationPost + 419
18 CoreFoundation 0x1d5877bbc ___CFXNotificationPost_block_invoke + 99
19 CoreFoundation 0x1d57ee768 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1503
20 CoreFoundation 0x1d5877664 _CFXNotificationPost + 715
21 Foundation 0x1d62727c4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 71
22 UIKitCore 0x202bd2398 -[UIApplication _stopDeactivatingForReason:] + 1339
23 UIKitCore 0x20247010c __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 487
24 UIKitCore 0x202470e5c _performActionsWithDelayForTransitionContext + 119
25 UIKitCore 0x20246feb8 -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 259
26 UIKitCore 0x202474ea8 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 363
27 UIKitCore 0x2027bb904 -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] + 479
28 FrontBoardServices 0x1d82ccc58 __80-[FBSSceneImpl updater:didUpdateSettings:withDiff:transitionContext:completion:]_block_invoke_3 + 243
29 libdispatch.dylib 0x1d5319884 _dispatch_client_callout + 19
30 libdispatch.dylib 0x1d531ce5c _dispatch_block_invoke_direct + 251
31 FrontBoardServices 0x1d830918c __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 47
32 FrontBoardServices 0x1d8308e08 -[FBSSerialQueue _performNext] + 435
33 FrontBoardServices 0x1d8309404 -[FBSSerialQueue _performNextFromRunLoopSource] + 55
34 CoreFoundation 0x1d589a444 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 27
35 CoreFoundation 0x1d589a3c0 __CFRunLoopDoSource0 + 91
36 CoreFoundation 0x1d5899c7c __CFRunLoopDoSources0 + 179
37 CoreFoundation 0x1d5894950 __CFRunLoopRun + 987
38 CoreFoundation 0x1d5894254 CFRunLoopRunSpecific + 451
39 GraphicsServices 0x1d7ad3d8c GSEventRunModal + 107
40 UIKitCore 0x202bdc4c0 UIApplicationMain + 215
41 MyApp 0x104d97148 0x104d90000 + 29000
42 libdyld.dylib 0x1d5350fd8 start + 3
and I symbolicated the crash log , I found:
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x00000001f1be50dc 0x1f1bc2000 + 143580
points to
NSNotificationName.TimeOutUserInteraction.unsafeMutableAddressor (in MyApp) (InterractionUIApplication.swift:0)
I commented out the lines related to this notification, and the app got approved.
Surprisingly the code related to this would not get called on app launch. There is no possibility, as I searched the codebase, and this code would only be called during a sign in process but NOT ON app launch.
I wonder why it crashes, and why it didn't after I commented out the code.
Code related to this notification:
import UIKit
// User Activity Timer
extension NSNotification.Name {
public static let TimeOutUserInteraction: NSNotification.Name = NSNotification.Name(rawValue: "TimeOutUserInteraction")
}
class InterractionUIApplication: UIApplication {
static let timeoutInSeconds: TimeInterval = 60 * 10 // 10 minutes
private var idleTimer: Timer?
private var enabledUserInteractionTracking: Bool = false
func startUserInternactionTracking() {
enabledUserInteractionTracking = true
resetIdleTimer()
}
func stopUserInternactionTracking() {
enabledUserInteractionTracking = false
if let idleTimer = idleTimer {
idleTimer.invalidate()
}
idleTimer = nil
}
// Resent the timer because there was user interaction.
func resetIdleTimer() {
if let idleTimer = idleTimer {
idleTimer.invalidate()
}
idleTimer = Timer.scheduledTimer(timeInterval: InterractionUIApplication.timeoutInSeconds, target: self, selector: #selector(idleTimerExceeded), userInfo: nil, repeats: false)
}
// If the timer reaches the limit as defined in timeoutInSeconds, post this notification.
#objc func idleTimerExceeded() {
NotificationCenter.default.post(name: Notification.Name.TimeOutUserInteraction, object: nil)
}
}
and in MyAppManager class:
func startUserInternactionTracking()
{
(UIApplication.shared as? InterractionUIApplication)?.startUserInternactionTracking()
NotificationCenter.default.addObserver(self, selector: #selector(onTimeOutUserInteraction), name: Notification.Name.TimeOutUserInteraction, object: nil) //This is the commented out line to make review successful
}
func stopUserInternactionTracking()
{
(UIApplication.shared as? InterractionUIApplication)?.stopUserInternactionTracking()
NotificationCenter.default.removeObserver(self, name: Notification.Name.TimeOutUserInteraction, object: nil)
}
I'm sure that startUserInternactionTracking is not called during app launch. But I wonder why this is the reason for crash ?
In AppDelegate, I initialize the manager class:
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var appManager = MyAppManager()
.....
}
Please not this crash only happened on the device apple tested. The pre-prod build worked as expected in all of our test devices .I'm lack of experience to debug this kind of crash. I've never seen this before.
Can someone point me in right direction ?
Subclassing UIApplication looks like a possible cause. According to the documentation
Subclassing Notes
Most apps do not need to subclass UIApplication. Instead, use an app delegate to > manage interactions between the system and the app.
If your app must handle incoming events before the system does—a very rare
situation—you can implement a custom event or action dispatching mechanism. To do > this, subclass UIApplication and override the sendEvent(:) and/or the
sendAction(:to:from:for:) methods. For every event you intercept, dispatch it
back to the system by calling [super sendEvent:event] after you handle the event. > Intercepting events is only rarely required and you should avoid it if possible.
Are you actually instantiating that subclass instead of UIApplication? To do this you would need to create a main.swift file and call UIApplicationMain(,,,) and remove the default #UIApplicationMain macro from the top of your UIApplicationDelegate subclass.
But as the docs say, it doesn't seem like you actually need to subclass UIApplication, I suggest you look into the "coordinator" pattern instantiate an AppController class from your app delegate that manages app level logic.

Error when getting AppDelegate instance in other UIViewController

Hello I have been seeing crash logs for my app which when I open in XCode highlights the following line
let appDelegate = UIApplication.shared.delegate as! AppDelegate
I am stumped as I cannot replicate this in XCode. What are the possible reasons the app may crash here?
This line is at viewDidAppear() and also at viewDidLoad() but 5 out of 5 crash reports all point to the line at viewDidAppear()
Edit:
Here's the crash log
Thread 0 name:
Thread 0 Crashed:
0 MyApp 0x0000000100531208 LoginViewController.initView() + 536 (LoginViewController.swift:107)
1 MyApp 0x0000000100530d88 #objc LoginViewController.viewDidAppear(_:) + 112 (LoginViewController.swift:58)
2 UIKit 0x000000018ee2973c -[UIViewController _setViewAppearState:isAnimating:] + 840 (UIViewController.m:4471)
3 UIKit 0x000000018f07a448 __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 44 (UIViewController.m:5055)
4 UIKit 0x000000018ee7f798 -[UIViewController _executeAfterAppearanceBlock] + 92 (UIViewController.m:4793)
5 UIKit 0x000000018f185990 _runAfterCACommitDeferredBlocks + 564 (UIApplication.m:2528)
6 UIKit 0x000000018f17b958 _cleanUpAfterCAFlushAndRunDeferredBlocks + 384 (UIApplication.m:2497)
7 UIKit 0x000000018f18c68c __34-[UIApplication _firstCommitBlock]_block_invoke_2 + 152 (UIApplication.m:9928)
8 CoreFoundation 0x00000001851372bc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 20 (CFRunLoop.c:1840)
9 CoreFoundation 0x0000000185136a7c __CFRunLoopDoBlocks + 264 (CFRunLoop.c:1881)
10 CoreFoundation 0x00000001851347b0 __CFRunLoopRun + 1224 (CFRunLoop.c:2922)
11 CoreFoundation 0x0000000185054da8 CFRunLoopRunSpecific + 552 (CFRunLoop.c:3245)
12 GraphicsServices 0x000000018703a020 GSEventRunModal + 100 (GSEvent.c:2245)
13 UIKit 0x000000018f074758 UIApplicationMain + 236 (UIApplication.m:3965)
14 MyApp 0x0000000100424f3c main + 56 (BaseViewController.swift:19)
15 libdyld.dylib 0x0000000184ae5fc0 start + 4
I found this delegate is optional value.
unowned(unsafe) open var delegate: UIApplicationDelegate?
So you should use it like this.
if let appDelegate = UIApplication.shared.delegate as? AppDelegate {
// code here
} else {
// error handle
}
I finally figured this out. The crash logs all point to this line
let appDelegate = UIApplication.shared.delegate as! AppDelegate
which is line 107 from my LoginViewController but the actual error is actually triggered by a line of code two lines prior (data related error). Don't know why the logs all point to line 107 though. Thanks for your help.

App crash on viewDidDisappear

There is a very strange crash that occurs only on 5, 5s and SE models with iOS 10.2. Firebase says that 100% of crashes happened in background.
I got able to exactly reproduce the stack of crash (but not the crash itself on the simulator) and only figured out that it happens when the user quit an app. Seems like no other code of viewDidDisappear get called on real crash, because the stack changes in this case.
Actually, the line that mentioned in crash report goes straight after
super.viewDidDisappear(animated) and it is blank…
override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)
self.keyboardAvoiding.endAvoiding()
}
KeyboardAvoiding
func endAvoiding()
{
self.avoiding = false
// Update view frame
updateConstraint(nil)
}
private func updateConstraint(_ keyboardFrame: CGRect?, animationDuration: TimeInterval? = 0.0)
{
// Disable animation
let state = UIView.areAnimationsEnabled
UIView.setAnimationsEnabled(false)
// Force to recalculate view frame if needed (without animation)
self.view.superview?.layoutIfNeeded()
// Restore previous animation state
UIView.setAnimationsEnabled(state)
if let keyboardFrame = keyboardFrame
{
// Decrease view frame
self.constraint.constant = keyboardFrame.height
}
else {
// Reset bottom constraint to initial value
self.constraint.constant = self.initialConstraintConstant
}
// Layout superview
UIView.animate(withDuration: animationDuration ?? 0.0, animations: {
self.view.superview?.layoutIfNeeded()
if let keyboardAvoidingScrollView = self.view.firstViewOfClass(TPKeyboardAvoidingScrollView.self)
{
// Scroll to active text field if scroll view frame changed
keyboardAvoidingScrollView.scrollToActiveTextField()
}
})
}
Here is a crash report:
Hardware Model: iPhone6,2
Code Type: ARM-64
Parent Process: ??? [1]
OS Version: iPhone OS 10.2 (14C92)
Exception Type: SIGTRAP
Exception Codes: #0 at 0x100255178
Crashed Thread: 0
Application Specific Information:
Selector name found in current argument registers: release
Thread 0 Crashed:
0 _______ 0x0000000100255178 _______.PhoneNumberController.viewDidDisappear(Swift.Bool) -> () (PhoneNumberController.swift:97)
1 _______ 0x00000001002551a4 #objc _______.PhoneNumberController.viewDidDisappear(Swift.Bool) -> () (PhoneNumberController.swift:0)
2 UIKit 0x000000018e7026f4 -[UIViewController _setViewAppearState:isAnimating:] + 524
3 UIKit 0x000000018e7765b4 -[UIViewController __viewDidDisappear:] + 140
4 UIKit 0x000000018e7c02e0 -[UINavigationController viewDidDisappear:] + 228
5 UIKit 0x000000018e7026f4 -[UIViewController _setViewAppearState:isAnimating:] + 524
6 UIKit 0x000000018e7765b4 -[UIViewController __viewDidDisappear:] + 140
7 CoreFoundation 0x00000001887ceb10 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 16
8 CoreFoundation 0x00000001887ce214 _CFXRegistrationPost + 396
9 CoreFoundation 0x00000001887cdf90 ___CFXNotificationPost_block_invoke + 56
10 CoreFoundation 0x000000018883db8c -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1500
11 CoreFoundation 0x000000018870fe64 _CFXNotificationPost + 372
12 Foundation 0x0000000189244e0c -[NSNotificationCenter postNotificationName:object:userInfo:] + 64
13 UIKit 0x000000018e9785d8 __102-[UIApplication _handleApplicationDeactivationWithScene:shouldForceExit:transitionContext:completion:]_block_invoke.2100 + 288
14 UIKit 0x000000018e97bfdc _runAfterCACommitDeferredBlocks + 288
15 UIKit 0x000000018e96dd50 _cleanUpAfterCAFlushAndRunDeferredBlocks + 556
16 UIKit 0x000000018e6dd0b4 _afterCACommitHandler + 164
17 CoreFoundation 0x00000001887e20c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
18 CoreFoundation 0x00000001887dfcf0 __CFRunLoopDoObservers + 368
19 CoreFoundation 0x00000001887e0180 __CFRunLoopRun + 1020
20 CoreFoundation 0x000000018870e2b8 CFRunLoopRunSpecific + 440
21 GraphicsServices 0x000000018a1c2198 GSEventRunModal + 176
22 UIKit 0x000000018e7557fc -[UIApplication _run] + 680
23 UIKit 0x000000018e750534 UIApplicationMain + 204
24 _______ 0x00000001000e3188 main (AppDelegate.swift:25)
25 ??? 0x00000001876f15b8 0x0 + 0

Wierd Crash on iphone app

i have a strange reaction with my app.
My app is working fine in almost 10 different devices and also has passed the tests and it's online. But one friend that has iPhone 5s with iOS 9.1 has an issue. When he tries to enter to a table view, which i append items to it with an API call with alamofire and swiftyjson.. the app crashes. From crashlytics i get this strange error
Crashed: com.apple.main-thread
0 Events Near Me 0x1000a532c specialized listMapViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell (listMapViewController.swift:196)
1 Events Near Me 0x1000a3c94 #objc listMapViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell (listMapViewController.swift)
2 UIKit 0x18a37220c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 688
3 UIKit 0x18a372364 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
4 UIKit 0x18a3617b8 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2440
5 UIKit 0x18a376f0c -[UITableView _performWithCachedTraitCollection:] + 104
6 UIKit 0x18a10f22c -[UITableView layoutSubviews] + 176
7 UIKit 0x18a01f7ac -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 644
8 QuartzCore 0x18981eb58 -[CALayer layoutSublayers] + 148
9 QuartzCore 0x189819764 CA::Layer::layout_if_needed(CA::Transaction*) + 292
10 QuartzCore 0x189819624 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
11 QuartzCore 0x189818cc0 CA::Context::commit_transaction(CA::Transaction*) + 252
12 QuartzCore 0x189818a08 CA::Transaction::commit() + 512
13 QuartzCore 0x1898120f8 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
14 CoreFoundation 0x184a47bd0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
15 CoreFoundation 0x184a45974 __CFRunLoopDoObservers + 372
16 CoreFoundation 0x184a45da4 __CFRunLoopRun + 928
17 CoreFoundation 0x184974ca0 CFRunLoopRunSpecific + 384
18 GraphicsServices 0x18fbb0088 GSEventRunModal + 180
19 UIKit 0x18a08cffc UIApplicationMain + 204
20 Events Near Me 0x100095eec main (AppDelegate.swift:15)
21 libdyld.dylib 0x199da28b8 start + 4
And in the line 196 this is the code
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! locationEventsTableViewCell
var dict = arrRes[indexPath.row]
cell.eventTitle.text = dict["eventName"] as? String //here is the issue
So to explain you a bit, with this app you get some events near you depending on your location. I have a protection if there are no events there is a message. But we leave a couple of blocks away and i can get events, among with the cell.eventTitle... but my friend's iPhone crashes through it.
Any idea?
P.S. i'm now downloading iOS 9.1 to my simulator. Another friend with iPhone 5 doesnt have that issue.
As you say that other iphones doesn't have this problem I assumed that your friend's iphone maybe is overloaded from apps or anything else and it doesn't take the json variables in time!
So I suggest first to use if statements to avoid errors like this:
if dict["eventName"] as? String != nil {
cell.eventTitle.text = dict["eventName"] as? String
}
And if you want in your next update maybe you could use completions to reload your tableView data.
Hope it helps.

SIGTRAP on set background color

I have a swift view controller that is a subclass of JSQMessagesViewController and I'm seeing a weird SIGTRAP in viewDidLoad. Namely it occasionally happens when I try to set the background color. It happens sporadically so I'm not sure what might be happening.
override func viewDidLoad() {
super.viewDidLoad()
self.view.backgroundColor = UIColor.whiteColor()
}
Here's the crash log:
Thread 0 Crashed:
0 MyApp 0x00000001000ecc74 MyApp.MessageDetailViewController.viewDidLoad ()() (MessageDetailViewController.swift:130)
1 MyApp 0x00000001000ecc94 #objc MyApp.MessageDetailViewController.viewDidLoad ()() (MessageDetailViewController.swift:0)
2 UIKit 0x0000000187834b40 -[UIViewController loadViewIfRequired] + 992
3 UIKit 0x0000000187834744 -[UIViewController view] + 24
4 UIKit 0x00000001878f4f88 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 308
5 UIKit 0x00000001878f4238 -[UINavigationController _startTransition:fromViewController:toViewController:] + 140
6 UIKit 0x00000001878f3ddc -[UINavigationController _startDeferredTransitionIfNeeded:] + 864
7 UIKit 0x00000001878f3a04 -[UINavigationController __viewWillLayoutSubviews] + 56
8 UIKit 0x00000001878f396c -[UILayoutContainerView layoutSubviews] + 204
9 UIKit 0x00000001878300e4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 652
10 QuartzCore 0x00000001851d6a28 -[CALayer layoutSublayers] + 144
11 QuartzCore 0x00000001851d1634 CA::Layer::layout_if_needed(CA::Transaction*) + 288
12 QuartzCore 0x00000001851d14f4 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 28
13 QuartzCore 0x00000001851d0b24 CA::Context::commit_transaction(CA::Transaction*) + 248
14 QuartzCore 0x00000001851d086c CA::Transaction::commit() + 508
15 QuartzCore 0x00000001851c9dd8 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 76
16 CoreFoundation 0x00000001826a07b0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 28
17 CoreFoundation 0x000000018269e554 __CFRunLoopDoObservers + 368
18 CoreFoundation 0x000000018269e984 __CFRunLoopRun + 924
19 CoreFoundation 0x00000001825c8d10 CFRunLoopRunSpecific + 380
20 GraphicsServices 0x0000000183eb0088 GSEventRunModal + 176
21 UIKit 0x000000018789df70 UIApplicationMain + 200
22 MyApp 0x00000001000286b4 main (main.m:16)
23 ??? 0x00000001821668b8 0x0 + 0
The controller is presented modally in a navigation controller but then can transition to being pushed onto the nav stack (similar to composing a message in the stock sms app). Maybe it is possible that the lack of animation is causing an issue?
func controllerDidSendMessageInThread(controller: MessageDetailViewController, thread: Thread) {
self.dismissViewControllerAnimated(false, completion: nil)
let detail = MessageDetailViewController(thread: thread)
self.navigationController?.pushViewController(detail, animated: animated)
}

Resources