diff options
-rw-r--r-- | Juick.xcodeproj/project.pbxproj | 116 | ||||
-rw-r--r-- | Juick/APIClient.m | 22 | ||||
-rw-r--r-- | Juick/Model/User.m | 4 | ||||
-rw-r--r-- | Juick/Supporting Files/Juick-Info.plist | 13 | ||||
-rw-r--r-- | Juick/Supporting Files/Local.xcconfig | 12 | ||||
-rw-r--r-- | Juick/Supporting Files/Production.xcconfig | 12 |
6 files changed, 167 insertions, 12 deletions
diff --git a/Juick.xcodeproj/project.pbxproj b/Juick.xcodeproj/project.pbxproj index f5d9575..faa7ccd 100644 --- a/Juick.xcodeproj/project.pbxproj +++ b/Juick.xcodeproj/project.pbxproj @@ -161,6 +161,8 @@ 77C6ADDD1F770EB2000AEA8C /* Main.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; }; 77C6ADE21F7717BC000AEA8C /* ThreadViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ThreadViewController.h; sourceTree = "<group>"; }; 77C6ADE31F7717BC000AEA8C /* ThreadViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ThreadViewController.m; sourceTree = "<group>"; }; + 77D40AB8218B5BD60074E14F /* Local.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Local.xcconfig; sourceTree = "<group>"; }; + 77D40ABB218B5CC90074E14F /* Production.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Production.xcconfig; sourceTree = "<group>"; }; 77E35A80189A5B5A00B2D216 /* LoginViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoginViewController.h; sourceTree = "<group>"; }; 77E35A81189A5B5A00B2D216 /* LoginViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LoginViewController.m; sourceTree = "<group>"; }; 77E61A5A1FD467FC00B4E304 /* QuoteView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = QuoteView.xib; sourceTree = "<group>"; }; @@ -168,6 +170,7 @@ 77E61A5D1FD4682B00B4E304 /* QuoteView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QuoteView.m; sourceTree = "<group>"; }; 77FCADDE1D6A50DA00CBA649 /* APIClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIClient.m; sourceTree = "<group>"; }; 77FCADE01D6A50EC00CBA649 /* APIClient.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = APIClient.h; sourceTree = "<group>"; }; + 93A66B462A2F0D663DFD7F9A /* Pods-Juick.debug (local).xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Juick.debug (local).xcconfig"; path = "Pods/Target Support Files/Pods-Juick/Pods-Juick.debug (local).xcconfig"; sourceTree = "<group>"; }; B3271B16DFB6247972806713 /* Pods-Juick.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Juick.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Juick/Pods-Juick.debug.xcconfig"; sourceTree = "<group>"; }; FE68EEE5B0A1ABE0D063F54A /* Pods-Juick.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Juick.release.xcconfig"; path = "Pods/Target Support Files/Pods-Juick/Pods-Juick.release.xcconfig"; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -269,6 +272,8 @@ 77317BB3181BBE8500D60005 /* Juick-Info.plist */, 77317BB9181BBE8500D60005 /* Juick-Prefix.pch */, 77317BB7181BBE8500D60005 /* main.m */, + 77D40AB8218B5BD60074E14F /* Local.xcconfig */, + 77D40ABB218B5CC90074E14F /* Production.xcconfig */, ); path = "Supporting Files"; sourceTree = "<group>"; @@ -367,6 +372,7 @@ children = ( B3271B16DFB6247972806713 /* Pods-Juick.debug.xcconfig */, FE68EEE5B0A1ABE0D063F54A /* Pods-Juick.release.xcconfig */, + 93A66B462A2F0D663DFD7F9A /* Pods-Juick.debug (local).xcconfig */, ); name = Pods; sourceTree = "<group>"; @@ -600,6 +606,7 @@ /* Begin XCBuildConfiguration section */ 77317BDB181BBE8500D60005 /* Debug */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 77D40ABB218B5CC90074E14F /* Production.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -654,6 +661,7 @@ }; 77317BDC181BBE8500D60005 /* Release */ = { isa = XCBuildConfiguration; + baseConfigurationReference = 77D40ABB218B5CC90074E14F /* Production.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -796,6 +804,111 @@ }; name = Release; }; + 77D40ABC218B70570074E14F /* Debug (local) */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 77D40AB8218B5BD60074E14F /* Local.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + 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 = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEVELOPMENT_TEAM = KH4MX79ZK7; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + }; + name = "Debug (local)"; + }; + 77D40ABD218B70570074E14F /* Debug (local) */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 93A66B462A2F0D663DFD7F9A /* Pods-Juick.debug (local).xcconfig */; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; + CODE_SIGN_ENTITLEMENTS = Juick/Juick.entitlements; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + DEVELOPMENT_TEAM = KH4MX79ZK7; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "Juick/Supporting Files/Juick-Prefix.pch"; + INFOPLIST_FILE = "Juick/Supporting Files/Juick-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 11.1; + PRODUCT_BUNDLE_IDENTIFIER = "com.juick.${PRODUCT_NAME:rfc1034identifier}"; + PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE = ""; + TARGETED_DEVICE_FAMILY = "1,2"; + WRAPPER_EXTENSION = app; + }; + name = "Debug (local)"; + }; + 77D40ABE218B70570074E14F /* Debug (local) */ = { + isa = XCBuildConfiguration; + buildSettings = { + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CODE_SIGN_IDENTITY = "iPhone Developer"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + CODE_SIGN_STYLE = Automatic; + DEBUG_INFORMATION_FORMAT = dwarf; + DEVELOPMENT_TEAM = KH4MX79ZK7; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + INFOPLIST_FILE = JuickPush/Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 12.0; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + PRODUCT_BUNDLE_IDENTIFIER = com.juick.Juick.JuickPush; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = "Debug (local)"; + }; /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ @@ -803,6 +916,7 @@ isa = XCConfigurationList; buildConfigurations = ( 77317BDB181BBE8500D60005 /* Debug */, + 77D40ABC218B70570074E14F /* Debug (local) */, 77317BDC181BBE8500D60005 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -812,6 +926,7 @@ isa = XCConfigurationList; buildConfigurations = ( 77317BDE181BBE8500D60005 /* Debug */, + 77D40ABD218B70570074E14F /* Debug (local) */, 77317BDF181BBE8500D60005 /* Release */, ); defaultConfigurationIsVisible = 0; @@ -821,6 +936,7 @@ isa = XCConfigurationList; buildConfigurations = ( 7761135E21790B0300D350CD /* Debug */, + 77D40ABE218B70570074E14F /* Debug (local) */, 7761135F21790B0300D350CD /* Release */, ); defaultConfigurationIsVisible = 0; diff --git a/Juick/APIClient.m b/Juick/APIClient.m index 5c21f19..6d9878d 100644 --- a/Juick/APIClient.m +++ b/Juick/APIClient.m @@ -27,7 +27,9 @@ -(id)init { if (self = [super init]) { - self.manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:@"https://api.juick.com"]]; + NSString *baseURLString = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"base_url"]; + NSLog(@"Initializing with %@ base URL", baseURLString); + self.manager = [[AFHTTPSessionManager alloc] initWithBaseURL:[NSURL URLWithString:baseURLString]]; self.manager.requestSerializer = [AFJSONRequestSerializer new]; [self.manager.requestSerializer setCachePolicy:NSURLRequestReloadIgnoringLocalCacheData]; self.backgroundQueue = [NSOperationQueue new]; @@ -65,7 +67,7 @@ -(void) postMessage:(NSString *)text result:(void (^)(Message *, NSError *))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; [self.backgroundQueue addOperationWithBlock:^{ - [manager POST:@"/post" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { + [manager POST:@"post" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { [formData appendPartWithFormData:[text dataUsingEncoding:NSUTF8StringEncoding] name:@"body"]; } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSLog(@"Success!"); @@ -85,7 +87,7 @@ -(void) postReplyToThread:(NSNumber *)mid inReplyTo:(NSNumber *)rid text:(NSString *)text result:(void(^)(Message *, NSError *))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; [self.backgroundQueue addOperationWithBlock:^{ - [manager POST:@"/comment" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { + [manager POST:@"comment" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { [formData appendPartWithFormData:[[mid stringValue] dataUsingEncoding:NSUTF8StringEncoding] name:@"mid"]; [formData appendPartWithFormData:[[NSString stringWithFormat:@"%d", [rid intValue]] dataUsingEncoding:NSUTF8StringEncoding] name:@"rid"]; [formData appendPartWithFormData:[text dataUsingEncoding:NSUTF8StringEncoding] name:@"body"]; @@ -106,7 +108,7 @@ -(void) postPMToUser:(NSString *)uname text:(NSString *)text result:(void (^)(NSError *))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; [self.backgroundQueue addOperationWithBlock:^{ - [manager POST:@"/pm" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { + [manager POST:@"pm" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> _Nonnull formData) { [formData appendPartWithFormData:[text dataUsingEncoding:NSUTF8StringEncoding] name:@"body"]; [formData appendPartWithFormData:[uname dataUsingEncoding:NSUTF8StringEncoding] name:@"uname"]; } progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { @@ -125,7 +127,7 @@ -(void) fetchChats:(void (^)(NSArray *, NSError *))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; [self.backgroundQueue addOperationWithBlock:^{ - [manager GET:@"/groups_pms" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + [manager GET:@"groups_pms" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSMutableArray *groups = [NSMutableArray new]; NSArray *pms = [(NSDictionary *)responseObject objectForKey:@"pms"]; [pms enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { @@ -146,7 +148,7 @@ AFHTTPSessionManager *manager = [APIClient sharedClient].manager; NSDictionary *params = @{@"uname": uname}; [self.backgroundQueue addOperationWithBlock:^{ - [manager GET:@"/pm" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + [manager GET:@"pm" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { NSMutableArray *messages = [NSMutableArray new]; NSArray *messagesList = (NSArray *)responseObject; [messagesList enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) { @@ -166,19 +168,19 @@ +(NSString *) messagesUrl { - return @"/messages"; + return @"messages"; } +(NSString *) discussionsUrl { - return @"/messages/discussions"; + return @"messages/discussions"; } +(NSString *) threadUrl { - return @"/thread"; + return @"thread"; } +(NSString *) feedUrl { - return @"/home"; + return @"home"; } @end diff --git a/Juick/Model/User.m b/Juick/Model/User.m index 1576a91..36a9b4c 100644 --- a/Juick/Model/User.m +++ b/Juick/Model/User.m @@ -32,7 +32,7 @@ +(void) checkIsValid:(void (^)(BOOL))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; [manager.requestSerializer setAuthorizationHeaderFieldWithUsername:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.username"] password:[[PDKeychainBindings sharedKeychainBindings] stringForKey:@"com.juick.password"]]; - [manager POST:@"/post" parameters:nil progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { + [manager POST:@"post" parameters:nil progress:nil success:nil failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { NSInteger statusCode = ((NSHTTPURLResponse *)task.response).statusCode; if (statusCode == 400) { callback(YES); @@ -45,7 +45,7 @@ +(void) get:(NSString *) name callback:(void(^)(User *))callback { AFHTTPSessionManager *manager = [APIClient sharedClient].manager; NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:name, @"uname", nil]; - [manager GET:@"/users" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { + [manager GET:@"users" parameters:params progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject) { callback([User yy_modelWithJSON:[(NSArray *)responseObject firstObject]]); } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) { callback(nil); diff --git a/Juick/Supporting Files/Juick-Info.plist b/Juick/Supporting Files/Juick-Info.plist index 3b9b7ba..5812a2d 100644 --- a/Juick/Supporting Files/Juick-Info.plist +++ b/Juick/Supporting Files/Juick-Info.plist @@ -2,6 +2,19 @@ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> + <key>NSAppTransportSecurity</key> + <dict> + <key>NSExceptionDomains</key> + <dict> + <key>localhost</key> + <dict> + <key>NSExceptionAllowsInsecureHTTPLoads</key> + <true/> + </dict> + </dict> + </dict> + <key>base_url</key> + <string>${API_BASE_URL}</string> <key>CFBundleDevelopmentRegion</key> <string>en</string> <key>CFBundleDisplayName</key> diff --git a/Juick/Supporting Files/Local.xcconfig b/Juick/Supporting Files/Local.xcconfig new file mode 100644 index 0000000..d3b0acc --- /dev/null +++ b/Juick/Supporting Files/Local.xcconfig @@ -0,0 +1,12 @@ +// +// localhost.xcconfig +// Juick +// +// Created by Vitaly Takmazov on 01/11/2018. +// Copyright © 2018 com.juick. All rights reserved. +// + +// Configuration settings file format documentation can be found at: +// https://help.apple.com/xcode/#/dev745c5c974 + +API_BASE_URL = http:/$()/localhost:8080/api diff --git a/Juick/Supporting Files/Production.xcconfig b/Juick/Supporting Files/Production.xcconfig new file mode 100644 index 0000000..a57b0ad --- /dev/null +++ b/Juick/Supporting Files/Production.xcconfig @@ -0,0 +1,12 @@ +// +// Production.xcconfig +// Juick +// +// Created by Vitaly Takmazov on 01/11/2018. +// Copyright © 2018 com.juick. All rights reserved. +// + +// Configuration settings file format documentation can be found at: +// https://help.apple.com/xcode/#/dev745c5c974 + +API_BASE_URL = https:/$()/api.juick.com |