How to set up AWS mobile SDK in iOS project in Xcode

509 views Asked by At

The aws docs for this are really confusing. Following the steps from here https://docs.aws.amazon.com/aws-mobile/latest/developerguide/getting-started.html#ios-swift , I created the awsconfiguration.json using amplify, but it seems to be empty, it looks like this:

   {
    "UserAgent": "aws-amplify/cli",
    "Version": "0.1.0",
    "IdentityManager": {
        "Default": {}
    }
}

I dragged that json into the root of my xcode project, but when I run the project trying to call an aws api (specifically rekognition), I get this error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The service configuration is nil. You need to configure awsconfiguration.json, Info.plist or set defaultServiceConfiguration before using this method.'

I don't know if that's because the json isn't being read properly, or because it's empty, or what. This whole setup just seems to be a mess.

1

There are 1 answers

0
God Himself On

I did a hacky solution, I made a new app in mobile hub, downloaded the aws config json from there, added

 "Rekognition": {
        "Default": {
            "Region": "eu-west-1"
        }
    } 

to the json, gave permissions to the role created by mobile hub in the IAM dashboard to use rekognition, and it worked. Horrible solution.

Also this helped explain a lot of my concerns: https://aws.amazon.com/blogs/mobile/how-amazon-cognito-keeps-mobile-app-users-data-safe/