aws-amplify / aws-sdk-ios

AWS SDK for iOS. For more information, see our web site:
https://aws-amplify.github.io/docs
Other
1.68k stars 885 forks source link

AWS 2.4.9 and deploying iOS SDK from API Gateway console #484

Closed carlhunterroach closed 8 years ago

carlhunterroach commented 8 years ago

How do I deploy an IOS SDK for my app that is compatible with a specific AWS SDK version?

I'm trying to use AWS 2.4.9 buy Xcode complains that my Client API is missing members. E.g., Value of type 'XxClient' has no member 'invokeHHTPRequest' E.g., Cannot assign to property: 'configuration' is a get-only property

karthiksaligrama commented 8 years ago

are you using objective C or swift? I believe its swift. Can you make sure you have followed readme instructions?

Dashon commented 8 years ago

I'm having the same issue with Swift 3 Xcode 8 IOS10. Following the README instructions for the Framework implementation. Do you guys have an updated version of the generated SDK for IOS10?

jhewitt commented 8 years ago

I am having the same issue with Swift 3, Xcode 8 and iOS10. I have Embedded the Binaries for AWSCore.framework and AWSAPIGateway.framework and added the Script Phase after the Embed Frameworks phase. The value of type xxClient has no member 'invokeHTTPRequest'.

carlhunterroach commented 8 years ago

Yes @karthiksaligrama I'm using Swift. I've followed the instructions.

The file generated by AWS Gateway API as part of my iOS deployment includes two imports:

`import AWSCore
import AWSAPIGateway`

But it just looks like the AWS deployment is writing out older code and is not compatible with AWS 2.4.9.

E.g.,

`   init(configuration: AWSServiceConfiguration) {
    super.init()

    self.configuration = configuration
    var URLString: String = "https://########.execute-api.us-east-1.amazonaws.com/dev"
    if URLString.hasSuffix("/") {
        URLString = URLString.substringToIndex(URLString.startIndex.advancedBy(URLString.lengthOfBytesUsingEncoding(NSUTF8StringEncoding) - 1))
    }
    self.configuration.endpoint = AWSEndpoint(region: configuration.regionType, service: .APIGateway, URL: NSURL(string: URLString)!)
    let signer: AWSSignatureV4Signer = AWSSignatureV4Signer(credentialsProvider: configuration.credentialsProvider, endpoint: configuration.endpoint)
    self.configuration.baseURL = configuration.endpoint.URL
    self.configuration.requestInterceptors = [AWSNetworkingRequestInterceptor(), signer]
}`

In 2.4.9 self.configuration and self.configuration.endpoint are both defined as readonly by 2.4.9 -- so why is Gateway API deployment writing code that tries to set them?

Shouldn't Gateway API be writing code such as:

`AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration`

I don't know how endpoiint would be set but setting this will also need to be updated.

carlhunterroach commented 8 years ago

Undocumented but the clue is in the filename chosen by AWS: AWSApiGatewayBridge.h.

In your "projectname-Bridging-Header.h" file add this line: #import "AWSApiGatewayBridge.h"

Sorted!

karthiksaligrama commented 8 years ago

it is infact documented in the README that comes with the downloaded zip. Here is the part that calls out the bridging header setting

1. Add all files (`*.swift` and `*.h` files) under the `generated-src` directory to your Xcode project. The generated-src already includes the Bridging header file (Bridging_Header.h), include that file in your build settings for xcode target. If you already have a bridging header then add 

        #import "AWSApiGatewayBridge.h"

to your list of imports in the bridging header.
carlhunterroach commented 8 years ago

thanks for replying @karthiksaligrama apologies for overlooking this -- I must be downloading a different version. I went to https://github.com/aws/aws-sdk-ios and clicked "Clone or download > Download ZIP" I'm then looking at README.md in the root of the zip file. It has no mention of 'bridge'.

karthiksaligrama commented 8 years ago

I'm talking about the README that comes with the downloaded zip from API gateway not github

carlhunterroach commented 8 years ago

Sorted. I'll switch from github for AWS code and stick to your API gateway. thank!