Describe the bug
The app is crashing with a message
Fatal error: API category is not configured. Call Amplify.configure() before using any methods on the category.: file /Users/aftabahmed/Desktop/PROJECTS/Bala_Try/AWSDataStore_2/Pods/Amplify/Amplify/Categories/API/AmplifyAPICategory.swift, line 18
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Supposed to save data in the Datastore and fetch the data from the DataStore.
Screenshots



Desktop (please complete the following information):
Additional context
I tried AWS Storage. It worked fine
This is the code.
Hey @aftabahmed1286!
Did you manage to make it work in the end? I have the same issue with both existing projects and new ones (both Storyboard based and SwiftUI).
I'm having this same issue. I configure Amplify within the AppDelegate.swift
let storagePlugin = AWSS3StoragePlugin()
do {
try Amplify.add(plugin: storagePlugin)
try Amplify.configure()
print("Amplify configured with storage plugin")
} catch {
print("Failed to initialize Amplify with \(error)")
}
I receive no errors here
But as soon as I try and upload/download I get the error -
"Thread 1: Fatal error: Storage category is not configured. Call Amplify.configure() before using any methods on the category."
I tried to call the code in AppDelegate.swift again right before making a method call just to experiment with it but it gave me an error saying that it is already configured before giving me the crash again...
Perhaps there is a stable version before the latest that may not have this particular issue?
Thanks for reporting this issue and providing all the details. I'm reviewing our "Getting Started" guide for iOS and will keep you updated with my findings.
@patrickridd I tried to reproduce your error and I could only get the "Storage category is not configured" when the config files (amplifyconfiguration.json and awsconfiguration.json) were not added to Xcode, but in that case I could also see the "Failed to initialize Amplify with (error)" message in AppDelegate.
When did you create your project? Can you cleanup the local pods (delete both Pods/ and Podfile.lock) and reinstall them?
During this test I was able to identify several improvements we can make to our docs and I'll follow up with the team so we make them before the official release.
@aftabahmed1286 @raduoprea I used the attached project and indeed there's a configuration logic problem on Amplify when the AWSDataStorePlugin is configured but the AWSAPIPlugin is not. Without API, DataStore is meant to be use the local storage mechanism only, however that's not happening.
I'll work on a fix and follow-up with you.
Hi @drochetti , I'm facing the same problem. Have you been able to fix the configuration logic issue in Amplify?
Hi @drochetti , I'm facing the same problem. Have you been able to fix the configuration logic issue in Amplify?
Hi @Maybelline can you share your configuration code with me? Are you configuring both AWSDataStorePlugin and AWSAPIPlugin?
@drochetti,
Here the AppDelegate.swift file
import UIKit
import Amplify
import AmplifyPlugins
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
do {
try Amplify.add(plugin: AWSDataStorePlugin(modelRegistration: AmplifyModels()))
// add after all other plugins
try Amplify.configure()
} catch {
print("An error occurred setting up Amplify: (error)")
}
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
amplifyxc.config file:
push=false
modelgen=true
profile=default
envName=amplify
Both awsconfiguration.json and amplifyconfiguration.json files have just empty curly brackets.
Thanks in advance.
@aftabahmed1286 @Maybelline @patrickridd @raduoprea
We just went GA with Amplify iOS, v1.0.0 is officially out. Can you try the new DataStore tutorial and see if the latest version fix things for you?
I appreciate your patience in trying our preview and providing valuable feedback through this issue report.
We also launched a Discord community, feel free to join us there and hit me up if you have feedback, I would love to hear more about your use-cases. https://discord.gg/amplify
Closing this issue. Feel free to open a new one if you have problems with the stable version of Amplify.
idk why this is closed. I have the same issue right now.
since setting up the project, I find a different issue all the time.
All I am doing after I set up the project is change models. I am very disappointed. :|
Having similar problem. "Storage category is not configured."
I am experiencing the same problem after following RESTAPI tutorial tutorial. Has anyone figured out an solution. None of the amazon ios-SDKs seem to work as advertised right out of the box.
Using AWSAmplify tutorial, can confirm still broke.
Why was this closed? It's still clearly not working.
Most helpful comment
Why was this closed? It's still clearly not working.