diff --git a/ios-sample/MobileBackendIOS.xcodeproj/project.pbxproj b/ios-sample/MobileBackendIOS.xcodeproj/project.pbxproj index 7afccb0..75a00af 100644 --- a/ios-sample/MobileBackendIOS.xcodeproj/project.pbxproj +++ b/ios-sample/MobileBackendIOS.xcodeproj/project.pbxproj @@ -7,23 +7,24 @@ objects = { /* Begin PBXBuildFile section */ - 72413659445B9BA7FCF342B3 /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 461B1B27AA190C12EF8BE745 /* libPods.a */; }; + 002EEC35C77515961DF6EAD7 /* Pods_MobileBackendIOS.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CEBCA74CB1A447B61BDCDD95 /* Pods_MobileBackendIOS.framework */; }; CA66EDCF1BB84C6F00CDC29D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA66EDCE1BB84C6F00CDC29D /* AppDelegate.swift */; }; CA66EDD11BB84C6F00CDC29D /* AddNoteViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA66EDD01BB84C6F00CDC29D /* AddNoteViewController.swift */; }; CA66EDD41BB84C6F00CDC29D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CA66EDD21BB84C6F00CDC29D /* Main.storyboard */; }; CA66EDD61BB84C6F00CDC29D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = CA66EDD51BB84C6F00CDC29D /* Assets.xcassets */; }; CA66EDD91BB84C6F00CDC29D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = CA66EDD71BB84C6F00CDC29D /* LaunchScreen.storyboard */; }; - CA66EE111BB8776C00CDC29D /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA66EE101BB8776C00CDC29D /* Constants.swift */; settings = {ASSET_TAGS = (); }; }; + CA66EE111BB8776C00CDC29D /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = CA66EE101BB8776C00CDC29D /* Constants.swift */; }; CA66EE211BB8A60800CDC29D /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CA66EE201BB8A60800CDC29D /* MobileCoreServices.framework */; }; - CAA95B601BBDF69C00342450 /* APICreateNoteRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = CAA95B5D1BBDF69C00342450 /* APICreateNoteRequest.m */; settings = {ASSET_TAGS = (); }; }; - CAA95B611BBDF69C00342450 /* APICreateNoteResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = CAA95B5F1BBDF69C00342450 /* APICreateNoteResponse.m */; settings = {ASSET_TAGS = (); }; }; - CAE448EE1BBDC045006CE308 /* UploadPhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAE448ED1BBDC045006CE308 /* UploadPhotoViewController.swift */; settings = {ASSET_TAGS = (); }; }; - CAE4490E1BBDD955006CE308 /* APINotesApiClient.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE449051BBDD955006CE308 /* APINotesApiClient.m */; settings = {ASSET_TAGS = (); }; }; - CAEE1A151BBD02E0003A2A12 /* MobileBackendApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAEE1A141BBD02E0003A2A12 /* MobileBackendApi.swift */; settings = {ASSET_TAGS = (); }; }; + CAA95B601BBDF69C00342450 /* APICreateNoteRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = CAA95B5D1BBDF69C00342450 /* APICreateNoteRequest.m */; }; + CAA95B611BBDF69C00342450 /* APICreateNoteResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = CAA95B5F1BBDF69C00342450 /* APICreateNoteResponse.m */; }; + CAE448EE1BBDC045006CE308 /* UploadPhotoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAE448ED1BBDC045006CE308 /* UploadPhotoViewController.swift */; }; + CAE4490E1BBDD955006CE308 /* APINotesApiClient.m in Sources */ = {isa = PBXBuildFile; fileRef = CAE449051BBDD955006CE308 /* APINotesApiClient.m */; }; + CAEE1A151BBD02E0003A2A12 /* MobileBackendApi.swift in Sources */ = {isa = PBXBuildFile; fileRef = CAEE1A141BBD02E0003A2A12 /* MobileBackendApi.swift */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ - 461B1B27AA190C12EF8BE745 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 050B7092145822CCD9F20551 /* Pods-MobileBackendIOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobileBackendIOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MobileBackendIOS/Pods-MobileBackendIOS.debug.xcconfig"; sourceTree = ""; }; + 0EA59FDA55E8475A9C4113E3 /* Pods-MobileBackendIOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MobileBackendIOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-MobileBackendIOS/Pods-MobileBackendIOS.release.xcconfig"; sourceTree = ""; }; CA66EDCB1BB84C6F00CDC29D /* MobileBackendIOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MobileBackendIOS.app; sourceTree = BUILT_PRODUCTS_DIR; }; CA66EDCE1BB84C6F00CDC29D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; CA66EDD01BB84C6F00CDC29D /* AddNoteViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AddNoteViewController.swift; sourceTree = ""; }; @@ -42,6 +43,7 @@ CAE449041BBDD955006CE308 /* APINotesApiClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APINotesApiClient.h; sourceTree = ""; }; CAE449051BBDD955006CE308 /* APINotesApiClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APINotesApiClient.m; sourceTree = ""; }; CAEE1A141BBD02E0003A2A12 /* MobileBackendApi.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MobileBackendApi.swift; sourceTree = ""; }; + CEBCA74CB1A447B61BDCDD95 /* Pods_MobileBackendIOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MobileBackendIOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EF76C26D1FF479AE75BE622C /* Pods.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.release.xcconfig; path = "Pods/Target Support Files/Pods/Pods.release.xcconfig"; sourceTree = ""; }; F343C6EDC695BA46F497006E /* Pods.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = Pods.debug.xcconfig; path = "Pods/Target Support Files/Pods/Pods.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -52,7 +54,7 @@ buildActionMask = 2147483647; files = ( CA66EE211BB8A60800CDC29D /* MobileCoreServices.framework in Frameworks */, - 72413659445B9BA7FCF342B3 /* libPods.a in Frameworks */, + 002EEC35C77515961DF6EAD7 /* Pods_MobileBackendIOS.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -63,7 +65,7 @@ isa = PBXGroup; children = ( CA66EE201BB8A60800CDC29D /* MobileCoreServices.framework */, - 461B1B27AA190C12EF8BE745 /* libPods.a */, + CEBCA74CB1A447B61BDCDD95 /* Pods_MobileBackendIOS.framework */, ); name = Frameworks; sourceTree = ""; @@ -73,6 +75,8 @@ children = ( F343C6EDC695BA46F497006E /* Pods.debug.xcconfig */, EF76C26D1FF479AE75BE622C /* Pods.release.xcconfig */, + 050B7092145822CCD9F20551 /* Pods-MobileBackendIOS.debug.xcconfig */, + 0EA59FDA55E8475A9C4113E3 /* Pods-MobileBackendIOS.release.xcconfig */, ); name = Pods; sourceTree = ""; @@ -141,11 +145,12 @@ isa = PBXNativeTarget; buildConfigurationList = CA66EDDD1BB84C6F00CDC29D /* Build configuration list for PBXNativeTarget "MobileBackendIOS" */; buildPhases = ( + 20D0636CC65ABDFF7E6DCF2B /* [CP] Check Pods Manifest.lock */, 70A41046F43D89B486E2F581 /* Check Pods Manifest.lock */, CA66EDC71BB84C6F00CDC29D /* Sources */, CA66EDC81BB84C6F00CDC29D /* Frameworks */, CA66EDC91BB84C6F00CDC29D /* Resources */, - 5008BF2EDA7E7E2AB152CBA3 /* Copy Pods Resources */, + 78AA1A308544C795C63C73E5 /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -162,7 +167,7 @@ CA66EDC31BB84C6F00CDC29D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0940; ORGANIZATIONNAME = "Amazon Web Services"; TargetAttributes = { CA66EDCA1BB84C6F00CDC29D = { @@ -202,19 +207,22 @@ /* End PBXResourcesBuildPhase section */ /* Begin PBXShellScriptBuildPhase section */ - 5008BF2EDA7E7E2AB152CBA3 /* Copy Pods Resources */ = { + 20D0636CC65ABDFF7E6DCF2B /* [CP] Check Pods Manifest.lock */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; files = ( ); inputPaths = ( + "${PODS_PODFILE_DIR_PATH}/Podfile.lock", + "${PODS_ROOT}/Manifest.lock", ); - name = "Copy Pods Resources"; + name = "[CP] Check Pods Manifest.lock"; outputPaths = ( + "$(DERIVED_FILE_DIR)/Pods-MobileBackendIOS-checkManifestLockResult.txt", ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods/Pods-resources.sh\"\n"; + shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; 70A41046F43D89B486E2F581 /* Check Pods Manifest.lock */ = { @@ -232,6 +240,30 @@ shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n"; showEnvVarsInLog = 0; }; + 78AA1A308544C795C63C73E5 /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${SRCROOT}/Pods/Target Support Files/Pods-MobileBackendIOS/Pods-MobileBackendIOS-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/AWSAPIGateway/AWSAPIGateway.framework", + "${BUILT_PRODUCTS_DIR}/AWSCognito/AWSCognito.framework", + "${BUILT_PRODUCTS_DIR}/AWSCore/AWSCore.framework", + "${BUILT_PRODUCTS_DIR}/AWSS3/AWSS3.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSAPIGateway.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCognito.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSCore.framework", + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/AWSS3.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MobileBackendIOS/Pods-MobileBackendIOS-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -280,13 +312,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -313,6 +355,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -324,13 +367,23 @@ CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -349,13 +402,15 @@ IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_VERSION = 4.0; VALIDATE_PRODUCT = YES; }; name = Release; }; CA66EDDE1BB84C6F00CDC29D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = F343C6EDC695BA46F497006E /* Pods.debug.xcconfig */; + baseConfigurationReference = 050B7092145822CCD9F20551 /* Pods-MobileBackendIOS.debug.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = MobileBackendIOS/Info.plist; @@ -369,7 +424,7 @@ }; CA66EDDF1BB84C6F00CDC29D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = EF76C26D1FF479AE75BE622C /* Pods.release.xcconfig */; + baseConfigurationReference = 0EA59FDA55E8475A9C4113E3 /* Pods-MobileBackendIOS.release.xcconfig */; buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; INFOPLIST_FILE = MobileBackendIOS/Info.plist; diff --git a/ios-sample/MobileBackendIOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/ios-sample/MobileBackendIOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/ios-sample/MobileBackendIOS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/ios-sample/MobileBackendIOS/APINotesApiClient.h b/ios-sample/MobileBackendIOS/APINotesApiClient.h index 7c679b9..e6115c8 100755 --- a/ios-sample/MobileBackendIOS/APINotesApiClient.h +++ b/ios-sample/MobileBackendIOS/APINotesApiClient.h @@ -25,47 +25,6 @@ */ @interface APINotesApiClient: AWSAPIGatewayClient -/** - Returns the singleton service client. If the singleton object does not exist, the SDK instantiates the default service client with `defaultServiceConfiguration` from `[AWSServiceManager defaultServiceManager]`. The reference to this object is maintained by the SDK, and you do not need to retain it manually. - - If you want to enable AWS Signature, set the default service configuration in `- application:didFinishLaunchingWithOptions:` - - *Swift* - - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - let credentialProvider = AWSCognitoCredentialsProvider(regionType: .USEast1, identityPoolId: "YourIdentityPoolId") - let configuration = AWSServiceConfiguration(region: .USEast1, credentialsProvider: credentialProvider) - AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration - - return true - } - - *Objective-C* - - - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { - AWSCognitoCredentialsProvider *credentialsProvider = [[AWSCognitoCredentialsProvider alloc] initWithRegionType:AWSRegionUSEast1 - identityPoolId:@"YourIdentityPoolId"]; - AWSServiceConfiguration *configuration = [[AWSServiceConfiguration alloc] initWithRegion:AWSRegionUSEast1 - credentialsProvider:credentialsProvider]; - [AWSServiceManager defaultServiceManager].defaultServiceConfiguration = configuration; - - return YES; - } - - Then call the following to get the default service client: - - *Swift* - - let serviceClient = APINotesApiClient.defaultClient() - - *Objective-C* - - APINotesApiClient *serviceClient = [APINotesApiClient defaultClient]; - - @return The default service client. - */ -+ (instancetype)defaultClient; - /** Creates a service client with the given service configuration and registers it for the key. diff --git a/ios-sample/MobileBackendIOS/APINotesApiClient.m b/ios-sample/MobileBackendIOS/APINotesApiClient.m index 0d93228..ceb9762 100755 --- a/ios-sample/MobileBackendIOS/APINotesApiClient.m +++ b/ios-sample/MobileBackendIOS/APINotesApiClient.m @@ -63,7 +63,6 @@ @implementation APINotesApiClient static AWSSynchronizedMutableDictionary *_serviceClients = nil; - + (void)registerClientWithConfiguration:(AWSServiceConfiguration *)configuration forKey:(NSString *)key withUrl:(NSString*) url { static dispatch_once_t onceToken; @@ -101,8 +100,8 @@ - (instancetype)initWithConfiguration:(AWSServiceConfiguration *)configuration service:AWSServiceAPIGateway URL:[NSURL URLWithString:URLString]]; - AWSSignatureV4Signer *signer = [AWSSignatureV4Signer signerWithCredentialsProvider:_configuration.credentialsProvider - endpoint:_configuration.endpoint]; + AWSSignatureV4Signer *signer = [[AWSSignatureV4Signer alloc] initWithCredentialsProvider:_configuration.credentialsProvider + endpoint:_configuration.endpoint]; _configuration.baseURL = _configuration.endpoint.URL; _configuration.requestInterceptors = @[[AWSNetworkingRequestInterceptor new], signer]; diff --git a/ios-sample/MobileBackendIOS/AddNoteViewController.swift b/ios-sample/MobileBackendIOS/AddNoteViewController.swift index 7b786a5..2173b3a 100644 --- a/ios-sample/MobileBackendIOS/AddNoteViewController.swift +++ b/ios-sample/MobileBackendIOS/AddNoteViewController.swift @@ -19,7 +19,7 @@ class AddNoteViewController: UIViewController { @IBAction func saveNoteButtonPressed(sender: UIButton) { if(headlineTextField.text != nil && noteTextField.text != nil) { - MobileBackendApi.sharedInstance.postNote(headlineTextField.text!, text: noteTextField.text!) + MobileBackendApi.sharedInstance.postNote(headline: headlineTextField.text!, text: noteTextField.text!) headlineTextField.text = nil noteTextField.text = nil } else { diff --git a/ios-sample/MobileBackendIOS/AppDelegate.swift b/ios-sample/MobileBackendIOS/AppDelegate.swift index 7b758fd..ed2d30f 100644 --- a/ios-sample/MobileBackendIOS/AppDelegate.swift +++ b/ios-sample/MobileBackendIOS/AppDelegate.swift @@ -11,32 +11,32 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { - var mobileBackendService = MobileBackendApi.sharedInstance + public func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { + let mobileBackendService = MobileBackendApi.sharedInstance mobileBackendService.requestCognitoIdentity() return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/ios-sample/MobileBackendIOS/Base.lproj/Main.storyboard b/ios-sample/MobileBackendIOS/Base.lproj/Main.storyboard index 3effbd3..6292714 100644 --- a/ios-sample/MobileBackendIOS/Base.lproj/Main.storyboard +++ b/ios-sample/MobileBackendIOS/Base.lproj/Main.storyboard @@ -1,8 +1,13 @@ - - + + + + + - + + + @@ -14,48 +19,49 @@ - + - + + - + + - - + @@ -66,32 +72,32 @@ - + - + - + - + @@ -105,7 +111,6 @@ - @@ -124,25 +129,25 @@ - + - + - + @@ -160,7 +165,6 @@ - @@ -176,9 +180,8 @@ - - + @@ -188,7 +191,7 @@ - + diff --git a/ios-sample/MobileBackendIOS/MobileBackendApi.swift b/ios-sample/MobileBackendIOS/MobileBackendApi.swift index c98c04e..567b24e 100644 --- a/ios-sample/MobileBackendIOS/MobileBackendApi.swift +++ b/ios-sample/MobileBackendIOS/MobileBackendApi.swift @@ -14,50 +14,54 @@ class MobileBackendApi { init() { //Initialize the identity provider - self.awsCognitoCredentialsProvider = AWSCognitoCredentialsProvider.credentialsWithRegionType(CognitoRegionType, accountId: AWSAccountId, identityPoolId: CognitoIdentityPoolId, unauthRoleArn: CognitoUnauthenticatedRoleArn, authRoleArn: CognitoAuthenticatedRoleArn) + self.awsCognitoCredentialsProvider = AWSCognitoCredentialsProvider.init( + regionType: CognitoRegionType, + identityPoolId: CognitoIdentityPoolId, + unauthRoleArn: CognitoUnauthenticatedRoleArn, + authRoleArn: CognitoAuthenticatedRoleArn, + identityProviderManager: nil + ) } func requestCognitoIdentity() { - awsCognitoCredentialsProvider.getIdentityId().continueWithBlock() { (task) -> AnyObject! in + awsCognitoCredentialsProvider.getIdentityId().continueWith(block: { (task) -> Any? in if let error = task.error { - print("Error Requesting Unauthenticated user identity: \(error.userInfo)") + print("Error Requesting Unauthenticated user identity: \(error)") self.cognitoId = nil } else { self.cognitoId = self.awsCognitoCredentialsProvider.identityId } return nil - } + }) } func configureS3TransferManager() { let configuration = AWSServiceConfiguration(region: DefaultServiceRegionType, credentialsProvider: self.awsCognitoCredentialsProvider) - AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration - - AWSS3TransferManager.registerS3TransferManagerWithConfiguration(configuration, forKey: "USEast1AWSTransferManagerClient") + AWSServiceManager.default().defaultServiceConfiguration = configuration + if let configuration = configuration { + AWSS3TransferManager.register(with: configuration, forKey: "USEast1AWSTransferManagerClient") + } } func configureNoteApi() { let configuration = AWSServiceConfiguration(region: DefaultServiceRegionType, credentialsProvider: self.awsCognitoCredentialsProvider) - AWSServiceManager.defaultServiceManager().defaultServiceConfiguration = configuration + AWSServiceManager.default().defaultServiceConfiguration = configuration - APINotesApiClient.registerClientWithConfiguration(configuration, forKey: "USEast1NoteAPIManagerClient", withUrl: APIEndpointUrl) - APINotesApiClient(forKey: "USEast1NoteAPIManagerClient").APIKey = APIGatewayKey + APINotesApiClient.register(with: configuration, forKey: "USEast1NoteAPIManagerClient", withUrl: APIEndpointUrl) + APINotesApiClient(forKey: "USEast1NoteAPIManagerClient").apiKey = APIGatewayKey } func postNote(headline: String, text: String) { let noteRequest = APICreateNoteRequest() - noteRequest.headline = headline - noteRequest.text = text - noteRequest.noteId = NSUUID().UUIDString + noteRequest?.headline = headline + noteRequest?.text = text + noteRequest?.noteId = NSUUID().uuidString let noteApiClient = APINotesApiClient(forKey: "USEast1NoteAPIManagerClient") - noteApiClient.notesPost(noteRequest).continueWithBlock { (task) -> AnyObject! in + noteApiClient?.notesPost(noteRequest).continueWith(block: { (task) -> Any? in if let error = task.error { print("Failed creating note: [\(error)]") } - if let exception = task.exception { - print("Failed creating note: [\(exception)]") - } if let noteResponse = task.result as? APICreateNoteResponse { if((noteResponse.success) != nil) { print("Saved note successfully") @@ -66,21 +70,21 @@ class MobileBackendApi { } } return task - } + }) } func uploadImageToS3(localFilePath: String, localFileName: String) { let uploadRequest:AWSS3TransferManagerUploadRequest = AWSS3TransferManagerUploadRequest() uploadRequest.bucket = S3BucketName - uploadRequest.ACL = AWSS3ObjectCannedACL.PublicRead + uploadRequest.acl = AWSS3ObjectCannedACL.publicRead uploadRequest.contentType = "image/png" - uploadRequest.body = NSURL(fileURLWithPath: localFilePath) + uploadRequest.body = URL(fileURLWithPath: localFilePath) uploadRequest.key = localFileName - let s3TransferManager = AWSS3TransferManager.S3TransferManagerForKey("USEast1AWSTransferManagerClient") + let s3TransferManager = AWSS3TransferManager.s3TransferManager(forKey: "USEast1AWSTransferManagerClient") - s3TransferManager.upload(uploadRequest).continueWithBlock { (task) -> AnyObject! in - if let error = task.error { + s3TransferManager.upload(uploadRequest).continueWith(block: { (task) -> Any? in + if let error = task.error as NSError? { if error.domain == AWSS3TransferManagerErrorDomain as String { print("upload() failed: [\(error)]") } else { @@ -88,15 +92,11 @@ class MobileBackendApi { } } - if let exception = task.exception { - print("upload() failed: [\(exception)]") - } - if task.result != nil { print("Uploaded local file to S3: [\(localFileName)]") } return nil - } + }) } } diff --git a/ios-sample/MobileBackendIOS/UploadPhotoViewController.swift b/ios-sample/MobileBackendIOS/UploadPhotoViewController.swift index fdc7d32..79fb83f 100644 --- a/ios-sample/MobileBackendIOS/UploadPhotoViewController.swift +++ b/ios-sample/MobileBackendIOS/UploadPhotoViewController.swift @@ -14,21 +14,21 @@ class UploadPhotoViewController: UIViewController,UIImagePickerControllerDelegat @IBOutlet weak var uploadButton: UIButton! @IBOutlet weak var cameraButton: UIBarButtonItem! - private let documentsPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] as NSString - private let fileManager = NSFileManager.defaultManager() + private let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as NSString + private let fileManager = FileManager.default var imagePickerController:UIImagePickerController? override func viewDidLoad() { MobileBackendApi.sharedInstance.configureS3TransferManager() - uploadButton.enabled = false + uploadButton.isEnabled = false } @IBAction func uploadImageButtonPressed(sender: UIButton) { - let imgDirectoryPath = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)[0] - let fileName = NSProcessInfo.processInfo().globallyUniqueString.stringByAppendingString(".png") + let imgDirectoryPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] + let fileName = ProcessInfo.processInfo.globallyUniqueString.appendingFormat(".png") let fullyQualifiedPath = "\(imgDirectoryPath)/\(fileName)" - self.saveFileAndUpload(fullyQualifiedPath, imageName: fileName) + self.saveFileAndUpload(imagePath: fullyQualifiedPath, imageName: fileName) } @@ -40,52 +40,52 @@ class UploadPhotoViewController: UIViewController,UIImagePickerControllerDelegat imageController.delegate = self if isPhotoCameraAvailable() { - imageController.sourceType = .Camera + imageController.sourceType = .camera } else { - imageController.sourceType = UIImagePickerControllerSourceType.PhotoLibrary + imageController.sourceType = UIImagePickerControllerSourceType.photoLibrary } - presentViewController( imageController, animated: true, completion: nil) + present( imageController, animated: true, completion: nil) } } - - func imagePickerController(picker: UIImagePickerController, - didFinishPickingMediaWithInfo info: [String : AnyObject]){ + + func imagePickerController(_ picker: UIImagePickerController, + didFinishPickingMediaWithInfo info: [String : Any]) { - let mediaType:AnyObject? = info[UIImagePickerControllerMediaType] + let mediaType = info[UIImagePickerControllerMediaType] - if let currentMediaType:AnyObject = mediaType { + if let currentMediaType = mediaType { if currentMediaType is String { let imageType = currentMediaType as! String - if imageType == kUTTypeImage as NSString { + if imageType == (kUTTypeImage as NSString) as String { let image = info[ UIImagePickerControllerOriginalImage] as? UIImage if let currentImage = image{ //Process Image - let size = CGSizeApplyAffineTransform(currentImage.size, CGAffineTransformMakeScale(0.25, 0.25)) + let size = currentImage.size.applying(CGAffineTransform(scaleX: 0.25, y: 0.25)) let hasAlpha = false let scale: CGFloat = 0.0 // Automatically use scale factor of main screen UIGraphicsBeginImageContextWithOptions(size, !hasAlpha, scale) - currentImage.drawInRect(CGRect(origin: CGPointZero, size: size)) + currentImage.draw(in: CGRect(origin: .zero, size: size)) let scaledImage = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() //Save Image self.photoImageView.image = scaledImage - self.uploadButton.enabled = true + self.uploadButton.isEnabled = true } } } } - picker.dismissViewControllerAnimated( true, completion: nil) + picker.dismiss( animated: true, completion: nil) } - - func imagePickerControllerDidCancel(picker: UIImagePickerController) { + + func imagePickerControllerDidCancel(_ picker: UIImagePickerController) { print(" Picker was cancelled") - picker.dismissViewControllerAnimated( true, completion: nil) + picker.dismiss( animated: true, completion: nil) } func saveFileAndUpload(imagePath:String, imageName:String) { @@ -93,13 +93,13 @@ class UploadPhotoViewController: UIViewController,UIImagePickerControllerDelegat print("Error: Converting Image To Data") return } - if fileManager.createFileAtPath(imagePath, contents: data, attributes: nil){ - MobileBackendApi.sharedInstance.uploadImageToS3(imagePath,localFileName: imageName) + if fileManager.createFile(atPath: imagePath, contents: data, attributes: nil){ + MobileBackendApi.sharedInstance.uploadImageToS3(localFilePath: imagePath,localFileName: imageName) } } private func isPhotoCameraAvailable() -> Bool{ - return UIImagePickerController.isSourceTypeAvailable(.Camera) + return UIImagePickerController.isSourceTypeAvailable(.camera) } } diff --git a/ios-sample/Podfile b/ios-sample/Podfile index da2d00c..a65347c 100644 --- a/ios-sample/Podfile +++ b/ios-sample/Podfile @@ -1,6 +1,11 @@ source 'https://github.com/CocoaPods/Specs.git' -pod 'AWSCore' -pod 'AWSCognito' -pod 'AWSS3' -pod 'AWSAPIGateway', '~> 2.2.1' +platform :ios, '9.0' +use_frameworks! + +target 'MobileBackendIOS' do + pod 'AWSCore' + pod 'AWSCognito' + pod 'AWSS3' + pod 'AWSAPIGateway' +end