amplify-swift
amplify-swift copied to clipboard
SwiftUI Preview (Xcode canvas) crashes when using Amplify Auth code example
Describe the bug
When a SwiftUI View refers to some code manipulating Amplify Auth plugin, Xcode preview crashes
Error :

It looks like the preview renderer does not call the code in the AppDelegate.
Steps To Reproduce
Steps to reproduce the behavior:
-
use Xcode 14
-
create a simple project based on iOS Hello World template in Xcode
-
Compile and check the preview of the Content View - it works
-
follow instructions to add Amplify to the project. I followed the Todo Amplify example (https://docs.amplify.aws/lib/devpreview/getting-started/q/platform/ios/)
-
add auth and AI category
-
use Cognito User Pool console to create a user (username, password and verified email)
-
Add this code to the App Delegate
do {
Amplify.Logging.logLevel = .verbose
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.add(plugin: AWSAPIPlugin(modelRegistration: AmplifyModels()))
try Amplify.configure()
} catch {
print("An error occurred setting up Amplify: \(error)")
}
return true
- Add this code to the Content View Button (just after .padding())
.task {
appDelegate.signIn(username: "<the cognito username>", password: "<the cognito password>")
}
- Open the preview again, it crashes . Commenting out these three lines and it works again.
Expected behavior
Xcode SwiftUI preview should render even if there is some code referencing Amplify.
It looks like the app delegate is not called by the Preview
Amplify Framework Version
dev-preview branch
Amplify Categories
Auth
Dependency manager
Swift PM
Swift version
5.7
CLI version
10.0.0
Xcode version
14 14A309
Relevant log output
Log Messages
-------------------------------------
Translated Report (Full Report Below)
-------------------------------------
Incident Identifier: 847CA124-6D1D-48CC-890A-B6C1304817AB
CrashReporter Key: B7F3E64C-04FC-A43D-0780-40FE46E8E4ED
Hardware Model: MacBookPro18,1
Process: Todo [74950]
Path: /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/8F1A7C45-18E3-4B74-9B33-C6D8B14F843B/data/Containers/Bundle/Application/8B4F7BE1-580A-4D1E-89E2-BC6943B1D8DD/Todo.app/Todo
Identifier: com.stormacq.macos.Todo
Version: 1.0 (1)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd_sim [16089]
Coalition: com.apple.CoreSimulator.SimDevice.8F1A7C45-18E3-4B74-9B33-C6D8B14F843B [3198]
Responsible Process: SimulatorTrampoline [9381]
Date/Time: 2022-09-14 18:52:21.9313 +0100
Launch Time: 2022-09-14 18:52:21.6372 +0100
OS Version: macOS 12.6 (21G115)
Release Type: User
Report Version: 104
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000018bc585a0
Exception Note: EXC_CORPSE_NOTIFY
Termination Reason: SIGNAL 5 Trace/BPT trap: 5
Terminating Process: exc handler [74950]
Triggered by Thread: 0
Kernel Triage:
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
VM - pmap_enter failed with resource shortage
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libswiftCore.dylib 0x18bc585a0 _assertionFailure(_:_:file:line:flags:) + 308
1 libswiftCore.dylib 0x18bc585a0 _assertionFailure(_:_:file:line:flags:) + 308
2 Todo 0x10249e804 AuthCategory.plugin.getter + 1848
3 Todo 0x10249c86c AuthCategory.signIn(username:password:options:listener:) + 236
4 Todo 0x10246722c AppDelegate.signIn(username:password:) + 376 (TodoApp.swift:27)
5 ContentView.1.preview-thunk.dylib 0x110e76168 (1) suspend resume partial function for closure #2 in ContentView.__preview__body.getter + 412 (ContentView.swift:22)
6 ContentView.1.preview-thunk.dylib 0x110e7626d (1) await resume partial function for partial apply for closure #2 in ContentView.__preview__body.getter + 1
7 SwiftUI 0x109369895 0x108504000 + 15095957
8 SwiftUI 0x10936eda5 0x108504000 + 15117733
9 SwiftUI 0x108ae8085 0x108504000 + 6176901
10 SwiftUI 0x108ae806d 0x108504000 + 6176877
11 libswift_Concurrency.dylib 0x1ae384d0d completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*) + 1
Thread 1:: Dispatch queue: com.apple.root.utility-qos
0 libswiftCore.dylib 0x18bf52084 getSuperclassForMaybeIncompleteMetadata(swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::Optional<swift::MetadataState>, bool) + 28
1 libswiftCore.dylib 0x18bf53d70 swift_conformsToProtocolMaybeInstantiateSuperclasses(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, bool)::$_5::operator()((anonymous namespace)::ConformanceSection const&) const::'lambda'(swift::TargetProtocolConformanceDescriptor<swift::InProcess> const&)::operator()(swift::TargetProtocolConformanceDescriptor<swift::InProcess> const&) const + 256
2 libswiftCore.dylib 0x18bf53d70 swift_conformsToProtocolMaybeInstantiateSuperclasses(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, bool)::$_5::operator()((anonymous namespace)::ConformanceSection const&) const::'lambda'(swift::TargetProtocolConformanceDescriptor<swift::InProcess> const&)::operator()(swift::TargetProtocolConformanceDescriptor<swift::InProcess> const&) const + 256
3 libswiftCore.dylib 0x18bf52bd4 swift_conformsToProtocolMaybeInstantiateSuperclasses(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, bool) + 2436
4 libswiftCore.dylib 0x18bf51ffc swift_conformsToProtocol + 100
5 AttributeGraph 0x19bc9ae20 AG::swift::metadata::equatable() const + 116
6 AttributeGraph 0x19bcaf958 AG::LayoutDescriptor::Builder::visit_element(AG::swift::metadata const*, AG::swift::metadata::ref_kind, unsigned long) + 148
7 AttributeGraph 0x19bc9b958 AG::swift::metadata_visitor::visit_field(AG::swift::metadata const*, AG::swift::field_record const&, unsigned long) + 100
8 AttributeGraph 0x19bc9b12c AG::swift::metadata::visit(AG::swift::metadata_visitor&) const + 660
9 AttributeGraph 0x19bcb0780 AG::LayoutDescriptor::make_layout(AG::swift::metadata const*, AGComparisonMode, AG::LayoutDescriptor::HeapMode) + 476
10 AttributeGraph 0x19bcb1a34 AG::(anonymous namespace)::LayoutCache::drain_queue(void*) + 148
11 libdispatch.dylib 0x180135768 _dispatch_client_callout + 16
12 libdispatch.dylib 0x180148c54 _dispatch_root_queue_drain + 912
13 libdispatch.dylib 0x1801495b8 _dispatch_worker_thread2 + 224
14 libsystem_pthread.dylib 0x1ae55eb04 _pthread_wqthread + 224
15 libsystem_pthread.dylib 0x1ae55d904 start_wqthread + 8
Thread 2:
0 libsystem_pthread.dylib 0x1ae55d8fc start_wqthread + 0
Thread 3:
0 libsystem_pthread.dylib 0x1ae55d8fc start_wqthread + 0
Thread 4:
0 libsystem_pthread.dylib 0x1ae55d8fc start_wqthread + 0
Thread 5:: Dispatch queue: com.apple.libtrace.state.block-list
0 libsystem_kernel.dylib 0x1ae509dd4 __ulock_wait + 8
1 libdispatch.dylib 0x18013605c _dlock_wait + 52
2 libdispatch.dylib 0x180135e0c _dispatch_thread_event_wait_slow + 52
3 libdispatch.dylib 0x180146218 __DISPATCH_WAIT_FOR_QUEUE__ + 392
4 libdispatch.dylib 0x180145d18 _dispatch_sync_f_slow + 160
5 libsystem_trace.dylib 0x180075638 ___os_state_request_for_self_block_invoke + 348
6 libdispatch.dylib 0x180133fa4 _dispatch_call_block_and_release + 24
7 libdispatch.dylib 0x180135768 _dispatch_client_callout + 16
8 libdispatch.dylib 0x18013d7f8 _dispatch_lane_serial_drain + 780
9 libdispatch.dylib 0x18013e474 _dispatch_lane_invoke + 448
10 libdispatch.dylib 0x18014a624 _dispatch_workloop_worker_thread + 772
11 libsystem_pthread.dylib 0x1ae55eb40 _pthread_wqthread + 284
12 libsystem_pthread.dylib 0x1ae55d904 start_wqthread + 8
Thread 6:: com.apple.uikit.eventfetch-thread
0 libsystem_kernel.dylib 0x1ae507fcc mach_msg_trap + 8
1 libsystem_kernel.dylib 0x1ae508430 mach_msg + 72
2 CoreFoundation 0x1803708ac __CFRunLoopServiceMachPort + 156
3 CoreFoundation 0x18036aff4 __CFRunLoopRun + 1152
4 CoreFoundation 0x18036a75c CFRunLoopRunSpecific + 584
5 Foundation 0x180bcd00c -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 208
6 Foundation 0x180bcd230 -[NSRunLoop(NSRunLoop) runUntilDate:] + 60
7 UIKitCore 0x10535b6d4 -[UIEventFetcher threadMain] + 424
8 Foundation 0x180bf29d8 __NSThread__start__ + 704
9 libsystem_pthread.dylib 0x1ae5626c8 _pthread_start + 116
10 libsystem_pthread.dylib 0x1ae55d910 thread_start + 8
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x0000600003c24b00 x1: 0x000000018bf20d68 x2: 0x0000000000000007 x3: 0x00000001801892b8
x4: 0x0000000000de9c93 x5: 0x0000000000000013 x6: 0x0000000000000020 x7: 0x0000000000000110
x8: 0x0000600003c24b08 x9: 0x0000000200000003 x10: 0xfffffffe00000000 x11: 0x0000000200000003
x12: 0x0000000000000003 x13: 0x00000000b161605f x14: 0x00000000b1816800 x15: 0x0000000000016800
x16: 0x0000000031800000 x17: 0x0000000000000004 x18: 0x0000000000000000 x19: 0x0000600003c24b00
x20: 0x0000000000000002 x21: 0x0000000000000000 x22: 0x000000000000001a x23: 0x00000001027e9bb0
x24: 0xf00000000000006d x25: 0x00000001027e9ab0 x26: 0x000000000000000b x27: 0x0000000000000000
x28: 0x0000000000000000 fp: 0x000000016d99c4d0 lr: 0x000000018bc585a0
sp: 0x000000016d99c450 pc: 0x000000018bc585a0 cpsr: 0x60001000
far: 0x000000016dbc7bd8 esr: 0xf2000001 (Breakpoint) brk 1
Binary Images:
0x18bc2a000 - 0x18c0a0fff libswiftCore.dylib (*) <ad904577-c508-32a8-a605-2024b66b6f1b> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswiftCore.dylib
0x102460000 - 0x10281bfff com.stormacq.macos.Todo (1.0) <3d745c02-747a-3b49-aecb-1d5f51883767> /Users/USER/Library/Developer/Xcode/UserData/Previews/Simulator Devices/8F1A7C45-18E3-4B74-9B33-C6D8B14F843B/data/Containers/Bundle/Application/8B4F7BE1-580A-4D1E-89E2-BC6943B1D8DD/Todo.app/Todo
0x110e74000 - 0x110e77fff ContentView.1.preview-thunk.dylib (*) <fb36d8cc-1bf0-3b7a-8bca-959f181466df> /Users/USER/Library/Developer/Xcode/DerivedData/Todo-flaqjjkqnisigmcmrxluumrpbbxm/Build/Intermediates.noindex/Previews/Todo/Intermediates.noindex/Todo.build/Debug-iphonesimulator/Todo.build/Objects-normal/arm64/ContentView.1.preview-thunk.dylib
0x108504000 - 0x10999ffff com.apple.SwiftUI (4.0.90.1.107) <60de498d-eca7-3dda-940d-f18f7994d103> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/SwiftUI.framework/SwiftUI
0x1ae351000 - 0x1ae396fff libswift_Concurrency.dylib (*) <3f62c681-21f6-3041-ba80-3a7bdd83c25d> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/swift/libswift_Concurrency.dylib
0x19bc95000 - 0x19bcd1fff com.apple.AttributeGraph (4.0.27) <3b74b196-d6bf-3500-bc50-29e58c476423> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AttributeGraph.framework/AttributeGraph
0x180132000 - 0x180178fff libdispatch.dylib (*) <1aea29ca-25c7-35f6-9ab3-9f033d76ee27> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libdispatch.dylib
0x1ae55b000 - 0x1ae567ffb libsystem_pthread.dylib (*) <6de4a53b-8d96-3c92-b3c9-4a5ed84776fb> /usr/lib/system/libsystem_pthread.dylib
0x1ae507000 - 0x1ae53cffb libsystem_kernel.dylib (*) <3f1dda9e-9999-35d8-9886-03267422f518> /usr/lib/system/libsystem_kernel.dylib
0x180061000 - 0x180078fff libsystem_trace.dylib (*) <d301f0cb-f60e-31d8-82b8-c15d4949a109> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/libsystem_trace.dylib
0x1802ec000 - 0x180696fff com.apple.CoreFoundation (6.9) <9a99211c-ca2a-39ef-a616-376268d7420c> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
0x18070d000 - 0x180fc2fff com.apple.Foundation (6.9) <63a24bd8-44c3-36c4-adb8-42274fead2c0> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/Foundation.framework/Foundation
0x10485c000 - 0x105ef7fff com.apple.UIKitCore (1.0) <57d2c823-58a8-31e9-910f-a0148f0e2d7a> /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
EOF
-----------
Full Report
-----------
{"app_name":"Todo","timestamp":"2022-09-14 18:52:23.00 +0100","app_version":"1.0","slice_uuid":"3d745c02-747a-3b49-aecb-1d5f51883767","build_version":"1","platform":7,"bundleID":"com.stormacq.macos.Todo","share_with_app_devs":0,"is_first_party":0,"bug_type":"309","os_version":"macOS 12.6 (21G115)","incident_id":"847CA124-6D1D-48CC-890A-B6C1304817AB","name":"Todo"}
{
"uptime" : 32000,
"procLaunch" : "2022-09-14 18:52:21.6372 +0100",
"procRole" : "Foreground",
"version" : 2,
"userID" : 504,
"deployVersion" : 210,
"modelCode" : "MacBookPro18,1",
"procStartAbsTime" : 768121159974,
"coalitionID" : 3198,
"osVersion" : {
"train" : "macOS 12.6",
"build" : "21G115",
"releaseType" : "User"
},
"captureTime" : "2022-09-14 18:52:21.9313 +0100",
"incident" : "847CA124-6D1D-48CC-890A-B6C1304817AB",
"bug_type" : "309",
"pid" : 74950,
"procExitAbsTime" : 768127600830,
"translated" : false,
"cpuType" : "ARM-64",
"procName" : "Todo",
"procPath" : "\/Users\/USER\/Library\/Developer\/Xcode\/UserData\/Previews\/Simulator Devices\/8F1A7C45-18E3-4B74-9B33-C6D8B14F843B\/data\/Containers\/Bundle\/Application\/8B4F7BE1-580A-4D1E-89E2-BC6943B1D8DD\/Todo.app\/Todo",
"bundleInfo" : {"CFBundleShortVersionString":"1.0","CFBundleVersion":"1","CFBundleIdentifier":"com.stormacq.macos.Todo"},
"storeInfo" : {"deviceIdentifierForVendor":"3168FE19-0573-5307-89FF-013627B46561","thirdParty":true},
"parentProc" : "launchd_sim",
"parentPid" : 16089,
"coalitionName" : "com.apple.CoreSimulator.SimDevice.8F1A7C45-18E3-4B74-9B33-C6D8B14F843B",
"crashReporterKey" : "B7F3E64C-04FC-A43D-0780-40FE46E8E4ED",
"responsiblePid" : 9381,
"responsibleProc" : "SimulatorTrampoline",
"wakeTime" : 17054,
"sleepWakeUUID" : "E4D80986-5274-422B-B070-F1E0C3C0A5A4",
"sip" : "enabled",
"isCorpse" : 1,
"exception" : {"codes":"0x0000000000000001, 0x000000018bc585a0","rawCodes":[1,6639945120],"type":"EXC_BREAKPOINT","signal":"SIGTRAP"},
"termination" : {"flags":0,"code":5,"namespace":"SIGNAL","indicator":"Trace\/BPT trap: 5","byProc":"exc handler","byPid":74950},
"ktriageinfo" : "VM - pmap_enter failed with resource shortage\nVM - pmap_enter failed with resource shortage\nVM - pmap_enter failed with resource shortage\nVM - pmap_enter failed with resource shortage\n",
"extMods" : {"caller":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"system":{"thread_create":0,"thread_set_state":798,"task_for_pid":48},"targeted":{"thread_create":0,"thread_set_state":0,"task_for_pid":0},"warnings":0},
"faultingThread" : 0,
"threads" : [{"triggered":true,"id":815888,"threadState":{"x":[{"value":105553179331328},{"value":6642863464,"symbolLocation":0,"symbol":"_swift_release_"},{"value":7},{"value":6444061368,"symbolLocation":0,"symbol":"nanov2_free_definite_size"},{"value":14589075},{"value":19},{"value":32},{"value":272},{"value":105553179331336},{"value":8589934595},{"value":18446744065119617024},{"value":8589934595},{"value":3},{"value":2975948895},{"value":2978048000},{"value":92160},{"value":830472192},{"value":4},{"value":0},{"value":105553179331328},{"value":2},{"value":0},{"value":26},{"value":4336819120},{"value":17293822569102704749},{"value":4336818864},{"value":11},{"value":0},{"value":0}],"flavor":"ARM_THREAD_STATE64","lr":{"value":6639945120},"cpsr":{"value":1610616832},"fp":{"value":6133761232},"sp":{"value":6133761104},"esr":{"value":4060086273,"description":"(Breakpoint) brk 1"},"pc":{"value":6639945120,"matchesCrashFrame":1},"far":{"value":6136036312}},"queue":"com.apple.main-thread","frames":[{"imageOffset":189856,"symbol":"_assertionFailure(_:_:file:line:flags:)","symbolLocation":308,"imageIndex":0},{"imageOffset":189856,"symbol":"_assertionFailure(_:_:file:line:flags:)","symbolLocation":308,"imageIndex":0},{"imageOffset":256004,"symbol":"AuthCategory.plugin.getter","symbolLocation":1848,"imageIndex":1},{"imageOffset":247916,"symbol":"AuthCategory.signIn(username:password:options:listener:)","symbolLocation":236,"imageIndex":1},{"imageOffset":29228,"sourceLine":27,"sourceFile":"TodoApp.swift","symbol":"AppDelegate.signIn(username:password:)","imageIndex":1,"symbolLocation":376},{"imageOffset":8552,"sourceLine":22,"sourceFile":"ContentView.swift","symbol":"(1) suspend resume partial function for closure #2 in ContentView.__preview__body.getter","imageIndex":2,"symbolLocation":412},{"imageOffset":8813,"sourceFile":"<compiler-generated>","symbol":"(1) await resume partial function for partial apply for closure #2 in ContentView.__preview__body.getter","symbolLocation":1,"imageIndex":2},{"imageOffset":15095957,"imageIndex":3},{"imageOffset":15117733,"imageIndex":3},{"imageOffset":6176901,"imageIndex":3},{"imageOffset":6176877,"imageIndex":3},{"imageOffset":212237,"symbol":"completeTaskWithClosure(swift::AsyncContext*, swift::SwiftError*)","symbolLocation":1,"imageIndex":4}]},{"id":815895,"queue":"com.apple.root.utility-qos","frames":[{"imageOffset":3309700,"symbol":"getSuperclassForMaybeIncompleteMetadata(swift::TargetMetadata<swift::InProcess> const*, __swift::__runtime::llvm::Optional<swift::MetadataState>, bool)","symbolLocation":28,"imageIndex":0},{"imageOffset":3317104,"symbol":"swift_conformsToProtocolMaybeInstantiateSuperclasses(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, bool)::$_5::operator()((anonymous namespace)::ConformanceSection const&) const::'lambda'(swift::TargetProtocolConformanceDescriptor<swift::InProcess> const&)::operator()(swift::TargetProtocolConformanceDescriptor<swift::InProcess> const&) const","symbolLocation":256,"imageIndex":0},{"imageOffset":3317104,"symbol":"swift_conformsToProtocolMaybeInstantiateSuperclasses(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, bool)::$_5::operator()((anonymous namespace)::ConformanceSection const&) const::'lambda'(swift::TargetProtocolConformanceDescriptor<swift::InProcess> const&)::operator()(swift::TargetProtocolConformanceDescriptor<swift::InProcess> const&) const","symbolLocation":256,"imageIndex":0},{"imageOffset":3312596,"symbol":"swift_conformsToProtocolMaybeInstantiateSuperclasses(swift::TargetMetadata<swift::InProcess> const*, swift::TargetProtocolDescriptor<swift::InProcess> const*, bool)","symbolLocation":2436,"imageIndex":0},{"imageOffset":3309564,"symbol":"swift_conformsToProtocol","symbolLocation":100,"imageIndex":0},{"imageOffset":24096,"symbol":"AG::swift::metadata::equatable() const","symbolLocation":116,"imageIndex":5},{"imageOffset":108888,"symbol":"AG::LayoutDescriptor::Builder::visit_element(AG::swift::metadata const*, AG::swift::metadata::ref_kind, unsigned long)","symbolLocation":148,"imageIndex":5},{"imageOffset":26968,"symbol":"AG::swift::metadata_visitor::visit_field(AG::swift::metadata const*, AG::swift::field_record const&, unsigned long)","symbolLocation":100,"imageIndex":5},{"imageOffset":24876,"symbol":"AG::swift::metadata::visit(AG::swift::metadata_visitor&) const","symbolLocation":660,"imageIndex":5},{"imageOffset":112512,"symbol":"AG::LayoutDescriptor::make_layout(AG::swift::metadata const*, AGComparisonMode, AG::LayoutDescriptor::HeapMode)","symbolLocation":476,"imageIndex":5},{"imageOffset":117300,"symbol":"AG::(anonymous namespace)::LayoutCache::drain_queue(void*)","symbolLocation":148,"imageIndex":5},{"imageOffset":14184,"symbol":"_dispatch_client_callout","symbolLocation":16,"imageIndex":6},{"imageOffset":93268,"symbol":"_dispatch_root_queue_drain","symbolLocation":912,"imageIndex":6},{"imageOffset":95672,"symbol":"_dispatch_worker_thread2","symbolLocation":224,"imageIndex":6},{"imageOffset":15108,"symbol":"_pthread_wqthread","symbolLocation":224,"imageIndex":7},{"imageOffset":10500,"symbol":"start_wqthread","symbolLocation":8,"imageIndex":7}]},{"id":815896,"frames":[{"imageOffset":10492,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":7}]},{"id":815897,"frames":[{"imageOffset":10492,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":7}]},{"id":815898,"frames":[{"imageOffset":10492,"symbol":"start_wqthread","symbolLocation":0,"imageIndex":7}]},{"id":815899,"queue":"com.apple.libtrace.state.block-list","frames":[{"imageOffset":11732,"symbol":"__ulock_wait","symbolLocation":8,"imageIndex":8},{"imageOffset":16476,"symbol":"_dlock_wait","symbolLocation":52,"imageIndex":6},{"imageOffset":15884,"symbol":"_dispatch_thread_event_wait_slow","symbolLocation":52,"imageIndex":6},{"imageOffset":82456,"symbol":"__DISPATCH_WAIT_FOR_QUEUE__","symbolLocation":392,"imageIndex":6},{"imageOffset":81176,"symbol":"_dispatch_sync_f_slow","symbolLocation":160,"imageIndex":6},{"imageOffset":83512,"symbol":"___os_state_request_for_self_block_invoke","symbolLocation":348,"imageIndex":9},{"imageOffset":8100,"symbol":"_dispatch_call_block_and_release","symbolLocation":24,"imageIndex":6},{"imageOffset":14184,"symbol":"_dispatch_client_callout","symbolLocation":16,"imageIndex":6},{"imageOffset":47096,"symbol":"_dispatch_lane_serial_drain","symbolLocation":780,"imageIndex":6},{"imageOffset":50292,"symbol":"_dispatch_lane_invoke","symbolLocation":448,"imageIndex":6},{"imageOffset":99876,"symbol":"_dispatch_workloop_worker_thread","symbolLocation":772,"imageIndex":6},{"imageOffset":15168,"symbol":"_pthread_wqthread","symbolLocation":284,"imageIndex":7},{"imageOffset":10500,"symbol":"start_wqthread","symbolLocation":8,"imageIndex":7}]},{"id":815900,"name":"com.apple.uikit.eventfetch-thread","frames":[{"imageOffset":4044,"symbol":"mach_msg_trap","symbolLocation":8,"imageIndex":8},{"imageOffset":5168,"symbol":"mach_msg","symbolLocation":72,"imageIndex":8},{"imageOffset":542892,"symbol":"__CFRunLoopServiceMachPort","symbolLocation":156,"imageIndex":10},{"imageOffset":520180,"symbol":"__CFRunLoopRun","symbolLocation":1152,"imageIndex":10},{"imageOffset":517980,"symbol":"CFRunLoopRunSpecific","symbolLocation":584,"imageIndex":10},{"imageOffset":4980748,"symbol":"-[NSRunLoop(NSRunLoop) runMode:beforeDate:]","symbolLocation":208,"imageIndex":11},{"imageOffset":4981296,"symbol":"-[NSRunLoop(NSRunLoop) runUntilDate:]","symbolLocation":60,"imageIndex":11},{"imageOffset":11531988,"symbol":"-[UIEventFetcher threadMain]","symbolLocation":424,"imageIndex":12},{"imageOffset":5134808,"symbol":"__NSThread__start__","symbolLocation":704,"imageIndex":11},{"imageOffset":30408,"symbol":"_pthread_start","symbolLocation":116,"imageIndex":7},{"imageOffset":10512,"symbol":"thread_start","symbolLocation":8,"imageIndex":7}]}],
"usedImages" : [
{
"source" : "P",
"arch" : "arm64",
"base" : 6639755264,
"size" : 4681728,
"uuid" : "ad904577-c508-32a8-a605-2024b66b6f1b",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/swift\/libswiftCore.dylib",
"name" : "libswiftCore.dylib"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 4333109248,
"CFBundleShortVersionString" : "1.0",
"CFBundleIdentifier" : "com.stormacq.macos.Todo",
"size" : 3915776,
"uuid" : "3d745c02-747a-3b49-aecb-1d5f51883767",
"path" : "\/Users\/USER\/Library\/Developer\/Xcode\/UserData\/Previews\/Simulator Devices\/8F1A7C45-18E3-4B74-9B33-C6D8B14F843B\/data\/Containers\/Bundle\/Application\/8B4F7BE1-580A-4D1E-89E2-BC6943B1D8DD\/Todo.app\/Todo",
"name" : "Todo",
"CFBundleVersion" : "1"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 4578557952,
"size" : 16384,
"uuid" : "fb36d8cc-1bf0-3b7a-8bca-959f181466df",
"path" : "\/Users\/USER\/Library\/Developer\/Xcode\/DerivedData\/Todo-flaqjjkqnisigmcmrxluumrpbbxm\/Build\/Intermediates.noindex\/Previews\/Todo\/Intermediates.noindex\/Todo.build\/Debug-iphonesimulator\/Todo.build\/Objects-normal\/arm64\/ContentView.1.preview-thunk.dylib",
"name" : "ContentView.1.preview-thunk.dylib"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 4434444288,
"CFBundleShortVersionString" : "4.0.90.1.107",
"CFBundleIdentifier" : "com.apple.SwiftUI",
"size" : 21610496,
"uuid" : "60de498d-eca7-3dda-940d-f18f7994d103",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/Frameworks\/SwiftUI.framework\/SwiftUI",
"name" : "SwiftUI",
"CFBundleVersion" : "4.0.90.1.107"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 7217680384,
"size" : 286720,
"uuid" : "3f62c681-21f6-3041-ba80-3a7bdd83c25d",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/swift\/libswift_Concurrency.dylib",
"name" : "libswift_Concurrency.dylib"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 6908628992,
"CFBundleShortVersionString" : "4.0.27",
"CFBundleIdentifier" : "com.apple.AttributeGraph",
"size" : 249856,
"uuid" : "3b74b196-d6bf-3500-bc50-29e58c476423",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/PrivateFrameworks\/AttributeGraph.framework\/AttributeGraph",
"name" : "AttributeGraph",
"CFBundleVersion" : "4.0.27"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 6443704320,
"size" : 290816,
"uuid" : "1aea29ca-25c7-35f6-9ab3-9f033d76ee27",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/system\/libdispatch.dylib",
"name" : "libdispatch.dylib"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 7219818496,
"size" : 53244,
"uuid" : "6de4a53b-8d96-3c92-b3c9-4a5ed84776fb",
"path" : "\/usr\/lib\/system\/libsystem_pthread.dylib",
"name" : "libsystem_pthread.dylib"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 7219474432,
"size" : 221180,
"uuid" : "3f1dda9e-9999-35d8-9886-03267422f518",
"path" : "\/usr\/lib\/system\/libsystem_kernel.dylib",
"name" : "libsystem_kernel.dylib"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 6442848256,
"size" : 98304,
"uuid" : "d301f0cb-f60e-31d8-82b8-c15d4949a109",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/usr\/lib\/system\/libsystem_trace.dylib",
"name" : "libsystem_trace.dylib"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 6445514752,
"CFBundleShortVersionString" : "6.9",
"CFBundleIdentifier" : "com.apple.CoreFoundation",
"size" : 3846144,
"uuid" : "9a99211c-ca2a-39ef-a616-376268d7420c",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/Frameworks\/CoreFoundation.framework\/CoreFoundation",
"name" : "CoreFoundation",
"CFBundleVersion" : "1946.102"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 6449844224,
"CFBundleShortVersionString" : "6.9",
"CFBundleIdentifier" : "com.apple.Foundation",
"size" : 9134080,
"uuid" : "63a24bd8-44c3-36c4-adb8-42274fead2c0",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/Frameworks\/Foundation.framework\/Foundation",
"name" : "Foundation",
"CFBundleVersion" : "1946.102"
},
{
"source" : "P",
"arch" : "arm64",
"base" : 4370841600,
"CFBundleShortVersionString" : "1.0",
"CFBundleIdentifier" : "com.apple.UIKitCore",
"size" : 23707648,
"uuid" : "57d2c823-58a8-31e9-910f-a0148f0e2d7a",
"path" : "\/Applications\/Xcode.app\/Contents\/Developer\/Platforms\/iPhoneOS.platform\/Library\/Developer\/CoreSimulator\/Profiles\/Runtimes\/iOS.simruntime\/Contents\/Resources\/RuntimeRoot\/System\/Library\/PrivateFrameworks\/UIKitCore.framework\/UIKitCore",
"name" : "UIKitCore",
"CFBundleVersion" : "6092.1.111"
}
],
"sharedCache" : {
"base" : 6442450944,
"size" : 1325252608,
"uuid" : "d04b6ead-3edd-31e2-85bb-ad87e7f7b37b"
},
"vmSummary" : "ReadOnly portion of Libraries: Total=927.6M resident=0K(0%) swapped_out_or_unallocated=927.6M(100%)\nWritable regions: Total=1.1G written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=1.1G(100%)\n\n VIRTUAL REGION \nREGION TYPE SIZE COUNT (non-coalesced) \n=========== ======= ======= \nActivity Tracing 256K 1 \nColorSync 128K 5 \nCoreAnimation 32K 1 \nCoreUI image data 144K 1 \nFoundation 16K 1 \nKernel Alloc Once 32K 1 \nMALLOC 246.3M 41 \nMALLOC guard page 192K 12 \nMALLOC_MEDIUM (reserved) 480.0M 4 reserved VM address space (unallocated)\nMALLOC_NANO (reserved) 384.0M 1 reserved VM address space (unallocated)\nSTACK GUARD 56.1M 7 \nStack 11.2M 7 \nVM_ALLOCATE 1056K 2 \n__DATA 15.6M 546 \n__DATA_CONST 50.2M 541 \n__DATA_DIRTY 50K 10 \n__FONT_DATA 4K 1 \n__LINKEDIT 431.8M 76 \n__OBJC_RO 28.0M 1 \n__OBJC_RW 882K 1 \n__TEXT 495.8M 550 \ndyld private memory 1536K 3 \nmapped file 193.4M 11 \nshared memory 16K 1 \n=========== ======= ======= \nTOTAL 2.3G 1825 \nTOTAL, minus reserved VM space 1.5G 1825 \n",
"legacyInfo" : {
"threadTriggered" : {
"queue" : "com.apple.main-thread"
}
},
"trialInfo" : {
"rollouts" : [
{
"rolloutId" : "60f8ddccefea4203d95cbeef",
"factorPackIds" : {
},
"deploymentId" : 240000020
},
{
"rolloutId" : "5ffde50ce2aacd000d47a95f",
"factorPackIds" : {
},
"deploymentId" : 240000198
}
],
"experiments" : [
]
}
}
Model: MacBookPro18,1, BootROM 7459.141.1, proc 10:8:2 processors, 32 GB, SMC
Graphics: Apple M1 Pro, Apple M1 Pro, Built-In
Display: Color LCD, 3456 x 2234 Retina, Main, MirrorOff, Online
Memory Module: LPDDR5
AirPort: Wi-Fi, wl0: Apr 6 2022 05:55:54 version 20.90.45.0.8.7.118 FWID 01-e7138ff2
Bluetooth: Version (null), 0 services, 0 devices, 0 incoming serial ports
Network Service: Wi-Fi, AirPort, en0
USB Device: USB31Bus
USB Device: Yubikey 4 OTP+U2F
USB Device: USB31Bus
USB Device: USB31Bus
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.
Thunderbolt Bus: MacBook Pro, Apple Inc.
Is this a regression?
Yes
Regression additional context
Last time I tried this was in 2019 with this project. Preview worked https://amplify-ios-workshop.go-aws.com/
Device
n/a
iOS Version
n/a
Specific to simulators
n/a
Additional context
No response
This can be temporarily resolved in the following ways.
/* func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
do {
try Amplify.configure()
print("Amplify configured with API plugin")
} catch {
print("Failed to initialize Amplify with \(error)")
}
return true
} */
Comments were removed only when preview, and comments were processed during building. Anyway, this is an error that needs to be fixed.
I do not experience that. Commenting on the Amplify related code in the App Delegate application
method does not solve the problem on my sample project.
@sebsto Thanks for reporting this! We created a PR to fix the problem . The fix has been merged and will be included in our next release, which should be sometime next week. In the meantime, feel free to target the main branch to test the fix, and let us know if you have any further problems with it.
@ameter that fixed our issue, thanks so much!
Looks like this fixes the issue - thanks
@ameter do you know when / if these bug fixes are merged into dev-preview
banch ?
Never mind - I saw it was already done ! Thanks https://github.com/aws-amplify/amplify-ios/commit/6210a4dfa61584081b71238953a0bc1d614f4cb4
We use the following code to prevent crashes on SwiftUI previews
var isRunningForPreviews: Bool {
ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] != nil
}
if isRunningForPreviews {
// Do not invoke Amplify.configure()
return
}