To initialize the Amplify Storage and Authentication categories, you are required to use the `Amplify.add()` method for each category you want. When you are done calling `add()` on each category, you finish configuring Amplify by calling `Amplify.configure()`.
**Add the following imports** to the top of your `AppDelegate.swift` file:
```swift
import Amplify
import AWSS3StoragePlugin
```
```swift
import Amplify
import AmplifyPlugins
```
**Add the following code**
Create a custom `AppDelegate`, and add to your `application:didFinishLaunchingWithOptions` method
```swift
class AppDelegate: NSObject, UIApplicationDelegate {
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
do {
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.add(plugin: AWSS3StoragePlugin())
try Amplify.configure()
print("Amplify configured with storage plugin")
} catch {
print("Failed to initialize Amplify with \(error)")
}
return true
}
}
```
Then in the `App` scene, use `UIApplicationDelegateAdaptor` property wrapper to use your custom `AppDelegate`
```swift
@main
struct MyAmplifyApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
```
Add to your AppDelegate's `application:didFinishLaunchingWithOptions` method
```swift
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
do {
try Amplify.add(plugin: AWSCognitoAuthPlugin())
try Amplify.add(plugin: AWSS3StoragePlugin())
try Amplify.configure()
print("Amplify configured with storage plugin")
} catch {
print("Failed to initialize Amplify with \(error)")
}
return true
}
```
Upon building and running this application you should see the following in your console window:
```console
Amplify configured with storage plugin
```