Skip to content

Latest commit

 

History

History
195 lines (134 loc) · 10.4 KB

README.md

File metadata and controls

195 lines (134 loc) · 10.4 KB

Amplify Library for Swift

AWS Amplify

AWS Amplify provides a declarative and easy-to-use interface across different categories of cloud operations. Our default implementation works with Amazon Web Services (AWS), but AWS Amplify is designed to be open and pluggable for any custom backend or service.

The Amplify Library for Swift is layered on the AWS SDK for Swift. This allows for access to the AWS SDK for Swift for a breadth of service-centric APIs.

API Documentation

Getting Started Guide

CI/CD Codecov Discord

Features/APIs

  • Analytics - for logging metrics and understanding your users.
  • API (GraphQL) - for adding a GraphQL endpoint to your app.
  • API (REST) - for adding a REST endpoint to your app.
  • Authentication - for managing your users.
  • DataStore - for making it easier to program for a distributed data store for offline and online scenarios.
  • Geo - for adding location-based capabilities to your app.
  • Predictions - for connecting your app with machine learning services.
  • Push Notifications - for integrating push notifications in your app.
  • Storage - store complex objects like pictures and videos to the cloud.

Platform Support

Platform Versions Support Level
iOS 13+ GA
macOS 10.15+ GA
tvOS 13+ GA
watchOS 9+ GA
visionOS 1+ Preview*

Swift Version Support

The current minimum supported Swift language version is Swift 5.9.

Note

The minimum Swift language version supported by Amplify Swift matches the version included in the minimum Xcode version allowed by Apple to upload apps to App Store Connect. Historically, Apple updates the minimum allowed Xcode version in April each year. You can expect Amplify Swift to update the minimum supported Swift version within the following 60 days. This is done to ensure Amplify Swift can provide modern Swift APIs and take advantage of Swift language improvements.

Semantic versioning

We follow semantic versioning for our releases.

Semantic versioning and enumeration cases

When Amplify adds a new enumeration value, we will publish a new minor version of the library.

Applications that evaluate all members of an enumeration using a switch statement can add a default case to prevent new cases from causing compile warnings or errors.

Semantic versioning and dependencies update

We follow semantic versioning for updating our dependencies.

License

This library is licensed under the Apache 2.0 License.

Installation

Amplify requires Xcode 15.0 or later for all the supported platforms.

For more detailed instructions, follow the getting started guides in our documentation site

Swift Package Manager

  1. Swift Package Manager is distributed with Xcode. To start adding the Amplify Libraries to your iOS project, open your project in Xcode and select File > Add Packages.

    Add package dependency

  2. Enter the Amplify Library for Swift GitHub repo URL (https://github.com/aws-amplify/amplify-swift) into the search bar.

  3. You'll see the Amplify Library for Swift repository rules for which version of Amplify you want Swift Package Manager to install. Choose Up to Next Major Version and enter 2.0.0 as the minimum version for the Dependency Rule, then click Add Package.

    Dependency version options

  4. Choose which of the libraries you want added to your project. Always select the Amplify library. The "Plugin" to install depends on which categories you are using:

    • API: AWSAPIPlugin
    • Analytics: AWSPinpointAnalyticsPlugin
    • Auth: AWSCognitoAuthPlugin
    • DataStore: AWSDataStorePlugin
    • Geo: AWSLocationGeoPlugin
    • Storage: AWSS3StoragePlugin

    Select dependencies

    Select all that are appropriate, then click Add Package.

    You can always go back and modify which SPM packages are included in your project by opening the Package Dependencies tab for your project: Click on the Project file in the Xcode navigator, then click on your project under the Project section, then select the Package Dependencies tab.

  5. In your app code, explicitly import a plugin when you need to add a plugin to Amplify, access plugin options, or access a category escape hatch.

    import Amplify
    import AWSCognitoAuthPlugin
    import AWSAPIPlugin
    import AWSDataStorePlugin
    
    // ...
    
    func initializeAmplify() {
        do {
            try Amplify.add(plugin: AWSCognitoAuthPlugin())
            try Amplify.add(plugin: AWSAPIPlugin())
            try Amplify.add(plugin: AWSDataStorePlugin())
            // and so on ...
            try Amplify.configure()
        } catch {
            assertionFailure("Error initializing Amplify: \(error)")
        }
    }

    If you're just accessing Amplify category APIs (e.g., Auth.signIn() or Storage.uploadFile()), you only need to import Amplify:

    import Amplify
    
    // ...
    
    func signIn() async throws {
        let signInResult = try await Amplify.Auth.signIn(...)
        // ...
    }

Escape Hatch

All services and features not listed in the Features/API sections are supported via the Swift SDK or if supported by a category can be accessed via the Escape Hatch like below:

import Amplify
import AWSS3StoragePlugin
import AWSS3

// ...

guard let plugin = try Amplify.Storage.getPlugin(for: "awsS3StoragePlugin") as? AWSS3StoragePlugin else {
    print("Unable to to cast to AWSS3StoragePlugin")
    return
}

let awsS3 = plugin.getEscapeHatch()

let accelerateConfigInput = PutBucketAccelerateConfigurationInput()
do {
    let accelerateConfigOutput = try await awsS3.putBucketAccelerateConfiguration(
        input: accelerateConfigInput
    )
    print("putBucketAccelerateConfiguration output: \(accelerateConfigOutput)")
} catch {
    print("putBucketAccelerateConfiguration error: \(error)")
}

Describing use of required reason API

As required by the Apple App Store, we provide the new PrivacyInfo.xcprivacy file for describing use of required reason API, see Describing use of required reason API . You can also export the privacy report after archiving your App in Xcode, see Create your app’s privacy report.

The following Amplify targets have been identified to be using the User defaults APIs:

  • AWSCognitoAuthPlugin
  • AWSDataStorePlugin
  • AWSCloudWatchLoggingPlugin
  • InternalAWSPinpoint

Reporting Bugs/Feature Requests

Open Bugs Open Questions Feature Requests Closed Issues

We welcome you to use the GitHub issue tracker to report bugs or suggest features.

When filing an issue, please check existing open, or recently closed, issues to make sure somebody else hasn't already reported the issue. Please try to include as much information as you can. Details like these are incredibly useful:

  • Expected behavior and observed behavior
  • A reproducible test case or series of steps
  • The version of our code being used
  • Any modifications you've made relevant to the bug
  • Anything custom about your environment or deployment

Open Source Contributions

We welcome any and all contributions from the community! Make sure you read through our contribution guide here before submitting any PR's. Thanks! ♥️