AWS Amplify provides a declarative and easy-to-use interface across different categories of cloud operations. AWS Amplify goes well with any JavaScript based frontend workflow, and React Native for mobile developers.
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.
Storage - store complex objects like pictures and videos to the cloud.
All services and features not listed above are supported via the iOS SDK or if supported by a category can be accessed via the Escape Hatch like below:
guardlet predictionsPlugin =try Amplify.Predictions.getPlugin(for: "awsPredictionsPlugin") as? AWSPredictionsPlugin else {
print("Unable to cast to AWSPredictionsPlugin")
return
}
guardlet rekognitionService = predictionsPlugin.getEscapeHatch(key: .rekognition) as? AWSRekognition else {
print("Unable to get AWSRekognition")
return
}
let request =AWSRekognitionCreateCollectionRequest()
iflet request = request {
rekognitionService.createCollection(request)
}
Platform Support
Amplify supports iOS 11 and above and iOS 13 for certain categories such as Predictions and Geo. There are currently no plans to support Amplify on WatchOS, tvOS, or MacOS.
License
This library is licensed under the Apache 2.0 License.
Installation
Amplify requires Xcode 12 or higher to build.
For more detailed instructions, follow the getting started guides in our documentation site
Swift Package Manager
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 > Swift Packages > Add Package Dependency.
Enter the Amplify iOS GitHub repo URL (https://github.com/aws-amplify/amplify-ios) into the search bar and click Next.
You'll see the Amplify iOS repository rules for which version of Amplify you want Swift Package Manager to install. Choose the first rule, Version, as it will use the latest compatible version of the dependency that can be detected from the main branch, then click Next.
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
Storage: AWSS3StoragePlugin
Note: AWSPredictionsPlugin is not currently supported through Swift Package Manager due to different minimum iOS version requirements. Support for this will eventually be added.
Select all that are appropriate, then click Finish.
You can always go back and modify which SPM packages are included in your project by opening the Swift Packages tab for your project: Click on the Project file in the Xcode navigator, then click on your project's icon, then select the Swift Packages tab.
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.
importAmplifyimportAWSAPIPluginimportAWSDataStorePlugin// ... laterfuncinitializeAmplify() {
do {
try Amplify.add(AWSAPIPlugin())
// and so on ...
} catch {
assert(false, "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:
Amplify for iOS is available through CocoaPods. If you have not installed CocoaPods, install CocoaPods by running the command:
$ gem install cocoapods
$ pod setup
Depending on your system settings, you may have to use sudo for installing cocoapods as follows:
$ sudo gem install cocoapods
$ pod setup
In your project directory (the directory where your *.xcodeproj file is), type pod init and open the Podfile that was created. Add the Amplify pod and any plugins you would like to use. Below is an example of what a podfile might look like if you were going to use the Predictions plugin.
Open your project using ./YOUR-PROJECT-NAME.xcworkspace file. Remember to always use ./YOUR-PROJECT-NAME.xcworkspace to open your Xcode project from now on.
Reporting Bugs/Feature Requests
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! ♥️
请发表评论