amplify-swift: 1.0.0-rc.1 crashes at runtime when APIPlugin is added but backend does not exist yet
Describe the bug
Amplify 1.0.0-rc.1
When the code adds the APIPlugin but the amplify push has not been made yet (there is no API / backend), the execution crashes.
To Reproduce Steps to reproduce the behavior:
- Create a new project, create the pod, create the DataStore schema and do a codegen
- Initialize amplify in your code with
do {
// Amplify.Logging.logLevel = .info
try Amplify.add(plugin: AWSAPIPlugin())
try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: AmplifyModels()))
try Amplify.configure()
print("Amplify initialized")
...
Expected behavior No crash
Screenshots If applicable, add screenshots to help explain your problem.
Environment(please complete the following information):
- Amplify Framework Version: 1.0.0-rc.1
- Dependency Manager: cocoapod 1.9.2
- Swift Version : 5.x
Device Information (please complete the following information):
- Device: simulator
- iOS Version: 13.x
- Specific to simulators:
Additional context Error in my console :
Amplify initialized
==HUB== HubPayload(eventName: "Amplify.configured", context: nil, data: nil)
Fatal error: API category is not configured. Call Amplify.configure() before using any methods on the category.: file /Users/stormacq/Documents/amazon/code/amplify/amplify-mobile-news-blog/amplify-lib-ios-demo/Pods/Amplify/Amplify/Categories/API/AmplifyAPICategory.swift, line 17
2020-05-22 21:18:04.867104+0200 amplify-lib-ios-demo[28171:4552336] Fatal error: API category is not configured. Call Amplify.configure() before using any methods on the category.: file /Users/stormacq/Documents/amazon/code/amplify/amplify-mobile-news-blog/amplify-lib-ios-demo/Pods/Amplify/Amplify/Categories/API/AmplifyAPICategory.swift, line 17
Line that causes the crash
#6 0x0000000101a6b2d0 in AmplifyAPICategory.plugin.getter at /Users/stormacq/Documents/amazon/code/amplify/amplify-mobile-news-blog/amplify-lib-ios-demo/Pods/Amplify/Amplify/Categories/API/AmplifyAPICategory.swift:17
Error message in the debugger :
Thread 5: Fatal error: API category is not configured. Call Amplify.configure() before using any methods on the category.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 19 (5 by maintainers)
I am afraid I can not help anymore. Wait for 1.0.0 to be released and try again with a fresh project and the updated CLI
I am writing a blog post for Amplify Mobile 1.0.0 launch, that will be the missing README 😃 It should not be very long anymore.
Can you check your Auth category is correctly configured ? (you have an
Authproperty inawsconfiguration.json? and a 'authproperty inamplify configuration.json` ?)This is my
amplifyconfiguration.json(notice theAuthfromawsconfiguration.jsonis duplicated there, this will be added automatically by amplify CLI when 1.0.0 will be released)Amplify 1.0.0-rc1 is unreleased yet, this is just a release candidate, the doc is not published yet.
You do not need to use
AWSMobileClientanymoreHave a look at my sample project at https://github.com/sebsto/amplify-mobile-news-blog