My Swift app is crashing SOMETIMES while launching. The stacktrace is giving me a bad access error from native code. There are lots of similar KERN_INVALID_ADDRESS exceptions in swift or objective C applications. But my error is specifically caused by “lookUpImpOrForward + 100“. I have added the stacktrace below. It starts with my appdelegate, but not inside a method. So the native ios codes are unable to launch my app sometimes. It doesn’t happen always. A similar question is asked 5 years ago here but there is no answer to that either. Also, that question is caused by a different line and a very old system. Here is my appdelegate:
import UIKit
import GoogleMaps
import UserNotifications
import Firebase
import FirebaseMessaging
import GoogleMobileAds
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate
{
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
GMSServices.provideAPIKey(google_maps_key)
FirebaseApp.configure()
GADMobileAds.sharedInstance().start(completionHandler: nil)
set_strings()
Messaging.messaging().delegate = self
if #available(iOS 10.0, *)
{
UNUserNotificationCenter.current().delegate = self
let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
UNUserNotificationCenter.current().requestAuthorization(options: authOptions, completionHandler: {_, _ in })
}
else
{
let settings: UIUserNotificationSettings = UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
application.registerUserNotificationSettings(settings)
}
application.registerForRemoteNotifications()
return true
}
func applicationWillResignActive(_ application: UIApplication)
{
}
func applicationDidEnterBackground(_ application: UIApplication)
{
}
func applicationWillEnterForeground(_ application: UIApplication)
{
}
func applicationDidBecomeActive(_ application: UIApplication)
{
}
func applicationWillTerminate(_ application: UIApplication)
{
}
}
AND here is the stacktrace:
Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x4e3c lookUpImpOrForward + 100
1 libobjc.A.dylib 0x34c4 _objc_msgSend_uncached + 68
2 UIKitCore 0x67e8 -[UIView(Hierarchy) subviews] + 104
3 UIKitCore 0x660c -[UIView(MultiLayer) _allSubviews] + 112
4 UIKitCore 0x65d20 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 440
5 UIKitCore 0x65d80 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 536
6 UIKitCore 0x65d80 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 536
7 UIKitCore 0x65d80 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededCollectingViews:forSecondPass:] + 536
8 CoreAutoLayout 0x11f14 -[NSISEngine withBehaviors:performModifications:] + 84
9 UIKitCore 0x9c164 __100-[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:]_block_invoke + 124
10 UIKitCore 0x9aa9c -[UIView(AdditionalLayoutSupport) _withUnsatisfiableConstraintsLoggingSuspendedIfEngineDelegateExists:] + 112
11 UIKitCore 0x99ad0 -[UIView(AdditionalLayoutSupport) _updateConstraintsIfNeededWithViewForVariableChangeNotifications:] + 172
12 UIKitCore 0x5bab4 -[UIView _updateConstraintsAtEngineLevelIfNeededWithViewForVariableChangeNotifications:] + 388
13 UIKitCore 0x5b648 -[UIView _updateConstraintsAsNecessaryAndApplyLayoutFromEngine] + 324
14 UIKitCore 0x5b3d0 -[UIView(Hierarchy) layoutSubviews] + 192
15 UIKitCore 0xe9f044 -[UIPickerView layoutSubviews] + 236
16 UIKitCore 0xea0738 -[UIPickerView selectedRowInComponent:] + 64
17 UIKitCore 0xe9dcc4 -[UIPickerView _updateSelectedRows] + 100
18 UIKitCore 0xe9dd54 -[UIPickerView didMoveToWindow] + 84
19 UIKitCore 0x29aa0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1716
20 UIKitCore 0x29698 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684
21 UIKitCore 0x29698 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684
22 UIKitCore 0x29698 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684
23 UIKitCore 0x29698 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684
24 UIKitCore 0x29698 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684
25 UIKitCore 0x29698 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 684
26 UIKitCore 0x1aa70 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 124
27 CoreAutoLayout 0x11f14 -[NSISEngine withBehaviors:performModifications:] + 84
28 UIKitCore 0x1d914 -[UIView _postMovedFromSuperview:] + 504
29 UIKitCore 0x1c3d0 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 2200
30 UIKitCore 0x3b50ec -[UITransitionView transition:fromView:toView:removeFromView:] + 868
31 UIKitCore 0x313a80 -[UIViewControllerBuiltinTransitionViewAnimator animateTransition:] + 1300
32 UIKitCore 0x46c6f0 ___UIViewControllerTransitioningRunCustomTransition_block_invoke_3 + 52
33 UIKitCore 0x46c564 +[UIKeyboardSceneDelegate _pinInputViewsForKeyboardSceneDelegate:onBehalfOfResponder:duringBlock:] + 96
34 UIKitCore 0x46c4c8 ___UIViewControllerTransitioningRunCustomTransition_block_invoke_2 + 196
35 UIKitCore 0x46c26c +[UIView(Animation) _setAlongsideAnimations:toRunByEndOfBlock:] + 180
36 UIKitCore 0x3134d0 _UIViewControllerTransitioningRunCustomTransition + 484
37 UIKitCore 0x310b38 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_3 + 1584
38 UIKitCore 0xba6e4 -[_UIAfterCACommitBlock run] + 72
39 UIKitCore 0xba5a8 -[_UIAfterCACommitQueue flush] + 164
40 UIKitCore 0xba4c0 _runAfterCACommitDeferredBlocks + 496
41 UIKitCore 0xba0f8 _cleanUpAfterCAFlushAndRunDeferredBlocks + 80
42 UIKitCore 0xba008 _UIApplicationFlushCATransaction + 72
43 UIKitCore 0xb776c _UIUpdateSequenceRun + 84
44 UIKitCore 0xb73b0 schedulerStepScheduledMainSection + 172
45 UIKitCore 0xb8254 runloopSourceCallback + 92
46 CoreFoundation 0x56834 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
47 CoreFoundation 0x567c8 __CFRunLoopDoSource0 + 176
48 CoreFoundation 0x54298 __CFRunLoopDoSources0 + 244
49 CoreFoundation 0x53484 __CFRunLoopRun + 828
50 CoreFoundation 0x52cd8 CFRunLoopRunSpecific + 608
51 GraphicsServices 0x11a8 GSEventRunModal + 164
52 UIKitCore 0x40a90c -[UIApplication _run] + 888
53 UIKitCore 0x4be9d0 UIApplicationMain + 340
54 WhoShares 0x6f544 main + 9 (AppDelegate.swift:9)
Why could this happen? It is not even in my code. Thanks in advance.