From abfe91829faef766e8a7b6cfc5c6689bbc9b8f96 Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Mon, 31 Oct 2016 20:27:48 +1100 Subject: [PATCH 1/4] Update lib/STURITemplate (13063406..10568e4e) +10568e4e Reorganise, mark up for nullability +eba23438 Enable strict selector matching +fbd0e06c Rationalise deployment target configuration, raise to macOS10.10 +4c2ee98c Use Xcode8 on Travis +6b5f14f9 Adopt Xcode8.1's recommendations --- lib/STURITemplate | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/STURITemplate b/lib/STURITemplate index 1306340..10568e4 160000 --- a/lib/STURITemplate +++ b/lib/STURITemplate @@ -1 +1 @@ -Subproject commit 13063406428dfd2ef4491f505aad6a3bf5c1665a +Subproject commit 10568e4ee1cb43715d79f2894e9f6c819d79e23e From c0621d99f539fce21da13eb60e7d2ca6021ac639 Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Mon, 31 Oct 2016 20:30:44 +1100 Subject: [PATCH 2/4] Adopt Xcode8.1's recommendations --- STHAL.xcodeproj/project.pbxproj | 29 +++++++++++++------ .../xcshareddata/xcschemes/STHAL-ios.xcscheme | 13 +++++---- .../xcschemes/STHAL-mac-framework.xcscheme | 13 +++++---- .../xcshareddata/xcschemes/STHAL-mac.xcscheme | 13 +++++---- STHAL/Info.plist | 2 +- STHALTests/Info.plist | 2 +- 6 files changed, 46 insertions(+), 26 deletions(-) diff --git a/STHAL.xcodeproj/project.pbxproj b/STHAL.xcodeproj/project.pbxproj index e3f577d..391126b 100644 --- a/STHAL.xcodeproj/project.pbxproj +++ b/STHAL.xcodeproj/project.pbxproj @@ -408,7 +408,7 @@ 2C384C8019AF31EB00A2B2E8 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0640; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = "Scott Talbot"; TargetAttributes = { 2C21BFCD19B315E8003E6622 = { @@ -651,7 +651,6 @@ "DEBUG=1", "$(inherited)", ); - IPHONEOS_DEPLOYMENT_TARGET = 5.0; MTL_ENABLE_DEBUG_INFO = YES; OTHER_LDFLAGS = ""; PRODUCT_NAME = STHAL; @@ -665,7 +664,6 @@ isa = XCBuildConfiguration; baseConfigurationReference = FD6E885319ECB2FA001020E1 /* STHAL-ios.xcconfig */; buildSettings = { - IPHONEOS_DEPLOYMENT_TARGET = 5.0; MTL_ENABLE_DEBUG_INFO = NO; OTHER_LDFLAGS = ""; PRODUCT_NAME = STHAL; @@ -688,9 +686,10 @@ "$(inherited)", ); INFOPLIST_FILE = STHALTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = YES; + PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; @@ -705,9 +704,10 @@ "$(inherited)", ); INFOPLIST_FILE = STHALTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 5.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; + PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = "iphonesimulator iphoneos"; @@ -730,19 +730,23 @@ CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; CURRENT_PROJECT_VERSION = 1; ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; GCC_C_LANGUAGE_STANDARD = gnu11; GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", @@ -763,8 +767,8 @@ "$(EGG_HEADER_SEARCH_PATHS)", "$(SRCROOT)/lib/STURITemplate", ); - IPHONEOS_DEPLOYMENT_TARGET = 6.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_LDFLAGS = ( "$(inherited)", "$(EGG_OTHER_LDFLAGS)", @@ -795,12 +799,14 @@ CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; CLANG_WARN_IMPLICIT_SIGN_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_IMPLICIT_ATOMIC_PROPERTIES = YES; CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = YES; @@ -809,6 +815,7 @@ ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; GCC_PREPROCESSOR_DEFINITIONS = "NDEBUG=1"; GCC_TREAT_WARNINGS_AS_ERRORS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -824,8 +831,8 @@ "$(EGG_HEADER_SEARCH_PATHS)", "$(SRCROOT)/lib/STURITemplate", ); - IPHONEOS_DEPLOYMENT_TARGET = 6.0; - MACOSX_DEPLOYMENT_TARGET = 10.9; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MACOSX_DEPLOYMENT_TARGET = 10.10; OTHER_LDFLAGS = ( "$(inherited)", "$(EGG_OTHER_LDFLAGS)", @@ -854,6 +861,7 @@ INFOPLIST_FILE = STHAL/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = STHAL; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -874,6 +882,7 @@ INFOPLIST_FILE = STHAL/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = STHAL; SDKROOT = macosx; SKIP_INSTALL = YES; @@ -895,6 +904,7 @@ ); INFOPLIST_FILE = STHALTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SUPPORTED_PLATFORMS = macosx; @@ -911,6 +921,7 @@ ); INFOPLIST_FILE = STHALTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = "org.chikachow.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = macosx; SUPPORTED_PLATFORMS = macosx; diff --git a/STHAL.xcodeproj/xcshareddata/xcschemes/STHAL-ios.xcscheme b/STHAL.xcodeproj/xcshareddata/xcschemes/STHAL-ios.xcscheme index eec7622..e78f866 100644 --- a/STHAL.xcodeproj/xcshareddata/xcschemes/STHAL-ios.xcscheme +++ b/STHAL.xcodeproj/xcshareddata/xcschemes/STHAL-ios.xcscheme @@ -1,6 +1,6 @@ + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -58,15 +58,18 @@ ReferencedContainer = "container:STHAL.xcodeproj"> + + + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -72,15 +72,18 @@ ReferencedContainer = "container:STHAL.xcodeproj"> + + + shouldUseLaunchSchemeArgsEnv = "YES"> @@ -58,15 +58,18 @@ ReferencedContainer = "container:STHAL.xcodeproj"> + + CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.chikachow.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName diff --git a/STHALTests/Info.plist b/STHALTests/Info.plist index d11ecc9..ba72822 100644 --- a/STHALTests/Info.plist +++ b/STHALTests/Info.plist @@ -7,7 +7,7 @@ CFBundleExecutable $(EXECUTABLE_NAME) CFBundleIdentifier - org.chikachow.$(PRODUCT_NAME:rfc1034identifier) + $(PRODUCT_BUNDLE_IDENTIFIER) CFBundleInfoDictionaryVersion 6.0 CFBundleName From dcfba5be7bb65432ec82106273250ca1cdbe9744 Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Mon, 31 Oct 2016 20:31:24 +1100 Subject: [PATCH 3/4] Use Xcode8 on Travis --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b0264b2..ee34d0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ +osx_image: xcode8 language: objective-c xcode_project: STHAL.xcodeproj matrix: @@ -12,4 +13,5 @@ branches: only: - master before_script: - - brew update && brew upgrade xctool + - gem install xcpretty +script: xcodebuild -project ${TRAVIS_XCODE_PROJECT} -scheme ${TRAVIS_XCODE_SCHEME} -sdk ${TRAVIS_XCODE_SDK} | xcpretty From ee499756edc13e8ca70efdfad7d3b406191d79ce Mon Sep 17 00:00:00 2001 From: Scott Talbot Date: Mon, 27 Feb 2017 20:08:45 +1100 Subject: [PATCH 4/4] Mark up with generics, designated initialisers --- STHAL/STHALEmbeddedResources.h | 2 +- STHAL/STHALLinks.h | 13 ++++++-- STHAL/STHALLinks.m | 20 +++++-------- STHAL/STHALResource.h | 55 +++++++++++++++++----------------- STHAL/STHALResource.m | 11 +++---- 5 files changed, 53 insertions(+), 48 deletions(-) diff --git a/STHAL/STHALEmbeddedResources.h b/STHAL/STHALEmbeddedResources.h index d5b2e8e..c9506ca 100644 --- a/STHAL/STHALEmbeddedResources.h +++ b/STHAL/STHALEmbeddedResources.h @@ -8,6 +8,6 @@ @interface STHALEmbeddedResources : NSObject -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options; +- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options NS_DESIGNATED_INITIALIZER; - (NSDictionary *)dictionaryRepresentationWithOptions:(STHALResourceWritingOptions)options; @end diff --git a/STHAL/STHALLinks.h b/STHAL/STHALLinks.h index d912047..00e6a6a 100644 --- a/STHAL/STHALLinks.h +++ b/STHAL/STHALLinks.h @@ -7,8 +7,15 @@ #import +@interface STHALLink : NSObject +- (instancetype __nullable)initWithDictionary:(NSDictionary * __nonnull)dict baseURL:(NSURL * __nullable)baseURL options:(STHALResourceReadingOptions)options; +- (id __nonnull)dictionaryRepresentationWithOptions:(STHALResourceWritingOptions)options; +@end + + @interface STHALLinks : NSObject -+ (NSArray *)linksForRelationNamed:(NSString *)name inDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options; -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options; -- (NSDictionary *)dictionaryRepresentationWithOptions:(STHALResourceWritingOptions)options; ++ (NSArray * __nullable)linksForRelationNamed:(NSString * __nonnull)name inDictionary:(NSDictionary * __nonnull)dict baseURL:(NSURL * __nullable)baseURL options:(STHALResourceReadingOptions)options; +- (instancetype __null_unspecified)init NS_UNAVAILABLE; +- (instancetype __nullable)initWithDictionary:(NSDictionary * __nonnull)dict baseURL:(NSURL * __nullable)baseURL options:(STHALResourceReadingOptions)options NS_DESIGNATED_INITIALIZER; +- (NSDictionary * __nonnull)dictionaryRepresentationWithOptions:(STHALResourceWritingOptions)options; @end diff --git a/STHAL/STHALLinks.m b/STHAL/STHALLinks.m index 4d46248..31babdc 100644 --- a/STHAL/STHALLinks.m +++ b/STHAL/STHALLinks.m @@ -11,12 +11,6 @@ #import -@interface STHALLink : NSObject -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options; -- (id)dictionaryRepresentationWithOptions:(STHALResourceWritingOptions)options; -@end - - @implementation STHALLinks { @private NSDictionary *_links; @@ -69,10 +63,11 @@ + (NSArray *)linksFromLinkJSONObject:(id)object baseURL:(NSURL *)baseURL options return linksForName.copy; } -- (id)init { - return [self initWithDictionary:nil baseURL:nil options:0]; +- (instancetype)init { + [self doesNotRecognizeSelector:_cmd]; + return nil; } -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options { +- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options { NSParameterAssert(dict); if (![dict isKindOfClass:[NSDictionary class]]) { return nil; @@ -148,10 +143,11 @@ @implementation STHALLink { NSURL *_baseURL; } -- (id)init { - return [self initWithDictionary:nil baseURL:nil options:0]; +- (instancetype)init { + [self doesNotRecognizeSelector:_cmd]; + return nil; } -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions __unused)options { +- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions __unused)options { NSParameterAssert(dict); if (![dict isKindOfClass:[NSDictionary class]]) { return nil; diff --git a/STHAL/STHALResource.h b/STHAL/STHALResource.h index bbc6cb4..9a90363 100644 --- a/STHAL/STHALResource.h +++ b/STHAL/STHALResource.h @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // -// Copyright (c) 2014 Scott Talbot. +// Copyright (c) 2014-2016 Scott Talbot. #import @@ -10,35 +10,35 @@ @protocol STHALLinks; @protocol STHALEmbeddedResources; @protocol STHALResource -@property (nonatomic,strong,readonly) id links; -@property (nonatomic,copy,readonly) NSDictionary *payload; -@property (nonatomic,strong,readonly) id embeddedResources; +@property (nonatomic,strong,nullable,readonly) id links; +@property (nonatomic,copy,nonnull,readonly) NSDictionary *payload; +@property (nonatomic,strong,nullable,readonly) id embeddedResources; @end @protocol STHALLink; @protocol STHALLinks -@property (nonatomic,copy,readonly) NSArray *relationNames; -- (id)linkForRelationNamed:(NSString *)name; -- (NSArray *)linksForRelationNamed:(NSString *)name; -- (id)objectForKeyedSubscript:(NSString *)name; +@property (nonatomic,copy,nonnull,readonly) NSArray *relationNames; +- (id __nullable)linkForRelationNamed:(NSString * __nonnull)name; +- (NSArray> * __nullable)linksForRelationNamed:(NSString * __nonnull)name; +- (id __nullable)objectForKeyedSubscript:(NSString * __nonnull)name; @end @protocol STHALLink -@property (nonatomic,copy,readonly) NSString *name; -@property (nonatomic,copy,readonly) NSString *title; -@property (nonatomic,copy,readonly) NSString *type; -@property (nonatomic,copy,readonly) NSString *hreflang; -@property (nonatomic,copy,readonly) NSArray *templateVariableNames; -@property (nonatomic,copy,readonly) NSURL *url; -- (NSURL *)urlWithVariables:(NSDictionary *)variables; -@property (nonatomic,copy,readonly) NSURL *deprecation; +@property (nonatomic,copy,nonnull,readonly) NSString *name; +@property (nonatomic,copy,nullable,readonly) NSString *title; +@property (nonatomic,copy,nullable,readonly) NSString *type; +@property (nonatomic,copy,nullable,readonly) NSString *hreflang; +@property (nonatomic,copy,nonnull,readonly) NSArray *templateVariableNames; +@property (nonatomic,copy,nullable,readonly) NSURL *url; +- (NSURL * __nullable)urlWithVariables:(NSDictionary * __nullable)variables; +@property (nonatomic,copy,nullable,readonly) NSString *deprecation; @end @protocol STHALEmbeddedResources -@property (nonatomic,copy,readonly) NSArray *resourceNames; -- (id)resourceNamed:(NSString *)name; -- (NSArray *)resourcesNamed:(NSString *)name; -- (id)objectForKeyedSubscript:(NSString *)name; +@property (nonatomic,copy,nonnull,readonly) NSArray *resourceNames; +- (id __nullable)resourceNamed:(NSString * __nullable)name; +- (NSArray * __nullable)resourcesNamed:(NSString * __nullable)name; +- (id __nullable)objectForKeyedSubscript:(NSString * __nullable)name; @end @@ -54,11 +54,12 @@ typedef NS_OPTIONS(NSUInteger, STHALResourceWritingOptions) { }; @interface STHALResource : NSObject -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL; -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options; -@property (nonatomic,strong,readonly) id links; -@property (nonatomic,copy,readonly) NSDictionary *payload; -@property (nonatomic,strong,readonly) id embeddedResources; -- (NSDictionary *)dictionaryRepresentation; -- (NSDictionary *)dictionaryRepresentationWithOptions:(STHALResourceWritingOptions)options; +- (instancetype __null_unspecified)init NS_UNAVAILABLE; +- (instancetype __nonnull)initWithDictionary:(NSDictionary * __nonnull)dict baseURL:(NSURL * __nullable)baseURL; +- (instancetype __nonnull)initWithDictionary:(NSDictionary * __nonnull)dict baseURL:(NSURL * __nullable)baseURL options:(STHALResourceReadingOptions)options NS_DESIGNATED_INITIALIZER; +@property (nonatomic,strong,nullable,readonly) id links; +@property (nonatomic,copy,nonnull,readonly) NSDictionary *payload; +@property (nonatomic,strong,nullable,readonly) id embeddedResources; +- (NSDictionary * __nonnull)dictionaryRepresentation; +- (NSDictionary * __nonnull)dictionaryRepresentationWithOptions:(STHALResourceWritingOptions)options; @end diff --git a/STHAL/STHALResource.m b/STHAL/STHALResource.m index 3020337..4eec5ac 100644 --- a/STHAL/STHALResource.m +++ b/STHAL/STHALResource.m @@ -2,7 +2,7 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this // file, You can obtain one at http://mozilla.org/MPL/2.0/. // -// Copyright (c) 2014 Scott Talbot. +// Copyright (c) 2014-2016 Scott Talbot. #import @@ -18,13 +18,14 @@ @implementation STHALResource { STHALEmbeddedResources *_embedded; } -- (id)init { - return [self initWithDictionary:nil baseURL:nil options:0]; +- (instancetype)init { + [self doesNotRecognizeSelector:_cmd]; + return nil; } -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL { +- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL { return [self initWithDictionary:dict baseURL:baseURL options:0]; } -- (id)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options { +- (instancetype)initWithDictionary:(NSDictionary *)dict baseURL:(NSURL *)baseURL options:(STHALResourceReadingOptions)options { NSParameterAssert(dict); if (![dict isKindOfClass:[NSDictionary class]]) { return nil;