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.
- API Documentation https://docs.amplify.aws/start/q/integration/ios
- 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 - to detect text, images, and more!
- 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:
guard let predictionsPlugin = try Amplify.Predictions.getPlugin(for: "awsPredictionsPlugin") as? AWSPredictionsPlugin else {
print("Unable to cast to AWSPredictionsPlugin")
return
}
guard let rekognitionService = predictionsPlugin.getEscapeHatch(key: .rekognition) as? AWSRekognition else {
print("Unable to get AWSRekognition")
return
}
let request = AWSRekognitionCreateCollectionRequest()
if let request = request {
rekognitionService.createCollection(request)
}
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.
This library is licensed under the Apache 2.0 License.
Amplify requires Xcode 12 or higher to build.
For more detailed instructions, follow the getting started guides in our documentation site |
---|
-
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.
import Amplify import AWSAPIPlugin import AWSDataStorePlugin // ... later func initializeAmplify() { 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()
orStorage.uploadFile()
), you only need to import Amplify:import Amplify // ... later func doUpload() { Amplify.Storage.uploadFile(...) }
-
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 installingcocoapods
as follows:$ sudo gem install cocoapods $ pod setup
-
In your project directory (the directory where your
*.xcodeproj
file is), typepod init
and open the Podfile that was created. Add theAmplify
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.source 'https://github.com/CocoaPods/Specs.git' platform :ios, '13.0' use_frameworks! target :'YourTarget' do pod 'Amplify' pod 'AmplifyPlugins/AWSCognitoAuthPlugin' pod 'AWSPredictionsPlugin' pod 'CoreMLPredictionsPlugin' end
-
Then run the following command:
$ pod install
-
Open up
*.xcworkspace
with Xcode and start using Amplify.Note: Do NOT use
*.xcodeproj
. If you open up a project file instead of a workspace, you will receive an error. -
In your app code, import
AmplifyPlugins
when you need to add a plugin to Amplify, access plugin options, or access a category escape hatch.import Amplify import AmplifyPlugins // ... later func initializeAmplify() { 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()
orStorage.uploadFile()
), you only need to import Amplify:import Amplify // ... later func doUpload() { Amplify.Storage.uploadFile(...) }
Development Pods
You can manually install the library by cloning this repo and creating a Podfile that references your local clone of it like below:
pod 'Amplify', :path => '~/amplify-ios'
pod 'AWSPluginsCore', :path => '~/amplify-ios'
pod 'CoreMLPredictionsPlugin', :path => '~/amplify-ios'
pod 'AWSPredictionsPlugin', :path => '~/amplify-ios'
pod 'AmplifyPlugins/AWSAPIPlugin', :path => '~/amplify-ios'
Then, install the dependencies:
pod install
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.
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
We welcome any and all contributions from the community! Make sure you read through our contribution guide here before submitting any PR's. Thanks!