Trying to create a post to get some help on the crash and couldn’t. Previous post https://developer.squareup.com/forums/t/readersdk-crashing-on-native-ios-project-using-swift/9207/1 was marked as spam. Can someone from the admin please help? More details on the comment below
I am converting an existing application that was using POS API to reader SDK. I have followed all the steps described in https://developer.squareup.com/docs/reader-sdk/build-on-ios and tried to run the app on iOS 15.4 simulator. It immediately crashes on application didFinishLaunchingWithOptions function where I am doing
SQRDReaderSDK.initialize(applicationLaunchOptions: launchOptions)
Stack Trace shows the following
2023-04-16 08:36:03.114081-0500 BarneyBrowniPadApp[31916:9957062] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSAttributeDescription 0x104e7d478> valueForUndefinedKey:]: this class is not key value coding-compliant for the key preserveValueOnDeletionInPersistentHistory.'
*** First throw call stack:
(
0 CoreFoundation 0x00007fff20406d44 __exceptionPreprocess + 242
1 libobjc.A.dylib 0x00007fff201a4a65 objc_exception_throw + 48
2 CoreFoundation 0x00007fff204069dc -[NSException init] + 0
3 Foundation 0x00007fff207a218c -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 225
4 Foundation 0x00007fff207a0f68 -[NSObject(NSKeyValueCoding) valueForKey:] + 307
5 RMMapper 0x00000001020187ad -[NSObject(RMCopyable) copyWithZone:] + 621
6 CoreData 0x00007fff25baa10a -[NSEntityDescription copyWithZone:] + 730
7 CoreData 0x00007fff25ba9fad -[NSEntityDescription copyWithZone:] + 381
8 CoreData 0x00007fff25c0b1fe -[NSManagedObjectModel copyWithZone:] + 376
9 CoreData 0x00007fff25c090f3 +[NSManagedObjectModel modelByMergingModels:] + 152
10 SquareReaderSDK 0x000000010a42465f SQRDCurrencyCodeGetISOCurrencyCode + 58081325
11 SquareReaderSDK 0x000000010a4241a8 SQRDCurrencyCodeGetISOCurrencyCode + 58080118
12 SquareReaderSDK 0x000000010a4242ef SQRDCurrencyCodeGetISOCurrencyCode + 58080445
13 SquareReaderSDK 0x000000010a278a5e SQRDCurrencyCodeGetISOCurrencyCode + 56329260
14 SquareCore 0x0000000102704f6f -[NSObject(SQCARCSelectorAdditions) _SQC_performSelector:withObject:withObject:] + 132
15 SquareCore 0x00000001027050b6 +[NSObject(SQCPrivateAdditions) _SQC_cachedPerformSelector:onObject:] + 91
16 SquareReaderSDK 0x000000010a418f3e SQRDCurrencyCodeGetISOCurrencyCode + 58034444
17 SquareReaderSDK 0x000000010a279006 SQRDCurrencyCodeGetISOCurrencyCode + 56330708
18 SquareReaderSDK 0x000000010a278f88 SQRDCurrencyCodeGetISOCurrencyCode + 56330582
19 SquareReaderSDK 0x000000010a402404 SQRDCurrencyCodeGetISOCurrencyCode + 57941458
20 SquareReaderSDK 0x000000010a402a71 SQRDCurrencyCodeGetISOCurrencyCode + 57943103
21 SquareReaderSDK 0x0000000106e09186 SQRDCurrencyCodeGetISOCurrencyCode + 1346388
22 SquareReaderSDK 0x0000000106d81c86 SQRDCurrencyCodeGetISOCurrencyCode + 792148
23 SquareReaderSDK 0x0000000106cc407a SQRDCurrencyCodeGetISOCurrencyCode + 14920
24 SquareReaderSDK 0x0000000106cced9d SQRDCurrencyCodeGetISOCurrencyCode + 59243
25 SquareReaderSDK 0x0000000106ccea1b SQRDCurrencyCodeGetISOCurrencyCode + 58345
26 libdispatch.dylib 0x0000000103812a5b _dispatch_client_callout + 8
27 libdispatch.dylib 0x0000000103813f24 _dispatch_once_callout + 66
28 SquareReaderSDK 0x0000000106cce9c4 SQRDCurrencyCodeGetISOCurrencyCode + 58258
29 SquareReaderSDK 0x0000000106cce425 SQRDCurrencyCodeGetISOCurrencyCode + 56819
30 SquareReaderSDK 0x0000000106cce13c SQRDCurrencyCodeGetISOCurrencyCode + 56074
31 BarneyBrowniPadApp 0x0000000100f9722f $s18BarneyBrowniPadApp0D8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0l6LaunchK3KeyaypGSgtF + 303
32 BarneyBrowniPadApp 0x0000000100f975e7 $s18BarneyBrowniPadApp0D8DelegateC11application_29didFinishLaunchingWithOptionsSbSo13UIApplicationC_SDySo0l6LaunchK3KeyaypGSgtFTo + 183
33 UIKitCore 0x00007fff2508a847 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 214
34 UIKitCore 0x00007fff2508c538 -[UIApplication _callInitializationDelegatesWithActions:forCanvas:payload:fromOriginatingProcess:] + 4128
35 UIKitCore 0x00007fff25091ed8 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1190
36 UIKitCore 0x00007fff24602a92 -[_UISceneLifecycleMultiplexer completeApplicationLaunchWithFBSScene:transitionContext:] + 122
37 UIKitCore 0x00007fff24bf6ba6 _UIScenePerformActionsWithLifecycleActionMask + 88
38 UIKitCore 0x00007fff2460358c __101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke + 198
39 UIKitCore 0x00007fff24602fc9 -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] + 252
40 UIKitCore 0x00007fff246033c2 -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] + 831
41 UIKitCore 0x00007fff24602c6f -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] + 354
42 UIKitCore 0x00007fff2460d0b7 __186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke + 178
43 UIKitCore 0x00007fff24ada115 +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:actions:completion:] + 859
44 UIKitCore 0x00007fff24c1402d _UISceneSettingsDiffActionPerformChangesWithTransitionContext + 246
45 UIKitCore 0x00007fff2460cd3b -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] + 346
46 UIKitCore 0x00007fff2440a465 __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.578 + 796
47 UIKitCore 0x00007fff24408e37 -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] + 253
48 UIKitCore 0x00007fff2440a025 -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] + 255
49 UIKitCore 0x00007fff250907f9 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 513
50 UIKitCore 0x00007fff24b0b112 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 355
51 FrontBoardServices 0x00007fff26546cdd -[FBSScene _callOutQueue_agent_didCreateWithTransitionContext:completion:] + 415
52 FrontBoardServices 0x00007fff26573216 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke.180 + 102
53 FrontBoardServices 0x00007fff265550ef -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] + 209
54 FrontBoardServices 0x00007fff26572df5 __94-[FBSWorkspaceScenesClient createWithSceneID:groupID:parameters:transitionContext:completion:]_block_invoke + 352
55 libdispatch.dylib 0x0000000103812a5b _dispatch_client_callout + 8
56 libdispatch.dylib 0x000000010381593b _dispatch_block_invoke_direct + 295
57 FrontBoardServices 0x00007fff26599da3 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
58 FrontBoardServices 0x00007fff26599c99 -[FBSSerialQueue _targetQueue_performNextIfPossible] + 174
59 FrontBoardServices 0x00007fff26599dcb -[FBSSerialQueue _performNextFromRunLoopSource] + 19
60 CoreFoundation 0x00007fff20373833 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
61 CoreFoundation 0x00007fff2037372b __CFRunLoopDoSource0 + 180
62 CoreFoundation 0x00007fff20372bf8 __CFRunLoopDoSources0 + 242
63 CoreFoundation 0x00007fff2036d2f4 __CFRunLoopRun + 871
64 CoreFoundation 0x00007fff2036ca90 CFRunLoopRunSpecific + 562
65 GraphicsServices 0x00007fff2cb72c8e GSEventRunModal + 139
66 UIKitCore 0x00007fff2508e90e -[UIApplication _run] + 928
67 UIKitCore 0x00007fff25093569 UIApplicationMain + 101
68 BarneyBrowniPadApp 0x0000000101049643 main + 211
69 dyld 0x0000000101d47f21 start_sim + 10
70 ??? 0x000000010f7e8310 0x0 + 4554916624
)
libc++abi: terminating with uncaught exception of type NSException
dyld4 config: DYLD_ROOT_PATH=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.4.simruntime/Contents/Resources/RuntimeRoot DYLD_LIBRARY_PATH=/Users/i858674/Library/Developer/Xcode/DerivedData/BarneyBrowniPadApp-gdiwpwhcikaluyddrzlbhstibkuv/Build/Products/Debug-iphonesimulator:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection DYLD_INSERT_LIBRARIES=/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.4.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib:/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.4.simruntime/Contents/Resources/RuntimeRoot/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib DYLD_FRAMEWORK_PATH=/Users/i858674/Library/Developer/Xcode/DerivedData/BarneyBrowniPadApp-gdiwpwhcikaluyddrzlbhstibkuv/Build/Products/Debug-iphonesimulator
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<NSAttributeDescription 0x104e7d478> valueForUndefinedKey:]: this class is not key value coding-compliant for the key preserveValueOnDeletionInPersistentHistory.'
terminating with uncaught exception of type NSException
CoreSimulator 857.14 - Device: iPad Pro (12.9-inch) (5th generation) (078B57BE-F666-4C58-808F-E84395FF7C59) - Runtime: iOS 15.4 (19E240) - DeviceType: iPad Pro (12.9-inch) (5th generation)
The same app when run on physical device also crashes but the error on the last part says
'[<NSAttributeDescription 0x104e7d478> valueForUndefinedKey:]: this class is not key value coding-compliant for the key JSONKey.'
What am I missing here?
Turns out that the library RMMapper that was used by the app somehow crashing the SquareReaderSDK initialization. Not sure why but I removed the library and it worked.
Glad to hear you were able to figure it out.
Various factors, such as memory issues, invalid or missing configuration settings, or problems with dependencies, can cause a crash on native iOS during initialization. You can use Xcode’s debugging tools to diagnose the case, check system logs, and review crash reports. It’s also helpful to ensure that your code appropriately handles errors and exceptions during initialization.