From 7e5223ed832964544375241ab0106352509173cb Mon Sep 17 00:00:00 2001 From: Michael Koukoullis Date: Sat, 7 Jul 2018 21:56:11 +1000 Subject: [PATCH] Swift 4.1 Upgrade --- .gitignore | 17 +- .gitmodules | 3 - .../project.pbxproj | 42 ++-- .../xcshareddata/IDEWorkspaceChecks.plist | 8 + .../PrimaryFlightDisplay-Mac.xcscheme | 2 +- .../PrimaryFlightDisplay-iOS.xcscheme | 2 +- README.md | 2 +- Resources/Info.plist | 2 +- Resources/xcconfigs/Base/Common.xcconfig | 221 ++++++++++++++++++ .../Base/Configurations/Debug.xcconfig | 51 ++++ .../Base/Configurations/Profile.xcconfig | 27 +++ .../Base/Configurations/Release.xcconfig | 37 +++ .../Base/Configurations/Test.xcconfig | 13 ++ .../Base/Targets/Application.xcconfig | 12 + .../xcconfigs/Base/Targets/Extension.xcconfig | 8 + .../xcconfigs/Base/Targets/Framework.xcconfig | 37 +++ .../Base/Targets/StaticLibrary.xcconfig | 32 +++ .../Mac OS X/Mac-Application.xcconfig | 21 ++ .../xcconfigs/Mac OS X/Mac-Base.xcconfig | 16 ++ .../Mac OS X/Mac-DynamicLibrary.xcconfig | 18 ++ .../xcconfigs/Mac OS X/Mac-Framework.xcconfig | 17 ++ .../Mac OS X/Mac-StaticLibrary.xcconfig | 11 + .../xcconfigs/Mac OS X/Mac-XCTest.xcconfig | 16 ++ Resources/xcconfigs/README.md | 13 ++ .../xcconfigs/iOS/iOS-Application.xcconfig | 11 + Resources/xcconfigs/iOS/iOS-Base.xcconfig | 18 ++ .../xcconfigs/iOS/iOS-Extension.xcconfig | 23 ++ .../xcconfigs/iOS/iOS-Framework.xcconfig | 11 + .../xcconfigs/iOS/iOS-StaticLibrary.xcconfig | 11 + Sources/Attitude.swift | 16 +- Sources/AttitudeReferenceIndex.swift | 38 +-- Sources/BankIndicator.swift | 44 ++-- Sources/CGFloat+Additions.swift | 4 +- Sources/Double+Additions.swift | 2 +- Sources/Horizon.swift | 8 +- Sources/PitchLadder.swift | 64 ++--- Sources/PrimaryFlightDisplay.swift | 26 +-- Sources/Settings.swift | 70 +++--- Sources/TapeCell.swift | 44 ++-- Sources/TapeCellContainer.swift | 56 ++--- Sources/TapeCellTriad.swift | 24 +- Sources/TapeIndicator.swift | 16 +- Sources/TapePointer.swift | 98 ++++---- Vendor/xcconfigs | 1 - 44 files changed, 920 insertions(+), 293 deletions(-) create mode 100644 PrimaryFlightDisplay.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100755 Resources/xcconfigs/Base/Common.xcconfig create mode 100755 Resources/xcconfigs/Base/Configurations/Debug.xcconfig create mode 100755 Resources/xcconfigs/Base/Configurations/Profile.xcconfig create mode 100755 Resources/xcconfigs/Base/Configurations/Release.xcconfig create mode 100755 Resources/xcconfigs/Base/Configurations/Test.xcconfig create mode 100755 Resources/xcconfigs/Base/Targets/Application.xcconfig create mode 100755 Resources/xcconfigs/Base/Targets/Extension.xcconfig create mode 100755 Resources/xcconfigs/Base/Targets/Framework.xcconfig create mode 100755 Resources/xcconfigs/Base/Targets/StaticLibrary.xcconfig create mode 100755 Resources/xcconfigs/Mac OS X/Mac-Application.xcconfig create mode 100755 Resources/xcconfigs/Mac OS X/Mac-Base.xcconfig create mode 100755 Resources/xcconfigs/Mac OS X/Mac-DynamicLibrary.xcconfig create mode 100755 Resources/xcconfigs/Mac OS X/Mac-Framework.xcconfig create mode 100755 Resources/xcconfigs/Mac OS X/Mac-StaticLibrary.xcconfig create mode 100755 Resources/xcconfigs/Mac OS X/Mac-XCTest.xcconfig create mode 100755 Resources/xcconfigs/README.md create mode 100755 Resources/xcconfigs/iOS/iOS-Application.xcconfig create mode 100755 Resources/xcconfigs/iOS/iOS-Base.xcconfig create mode 100755 Resources/xcconfigs/iOS/iOS-Extension.xcconfig create mode 100755 Resources/xcconfigs/iOS/iOS-Framework.xcconfig create mode 100755 Resources/xcconfigs/iOS/iOS-StaticLibrary.xcconfig delete mode 160000 Vendor/xcconfigs diff --git a/.gitignore b/.gitignore index 8e5f58e..d9aed85 100644 --- a/.gitignore +++ b/.gitignore @@ -19,12 +19,14 @@ xcuserdata/ ## Other *.moved-aside -*.xcuserstate +*.xccheckout *.xcscmblueprint ## Obj-C/Swift specific *.hmap *.ipa +*.dSYM.zip +*.dSYM ## Playgrounds timeline.xctimeline @@ -34,6 +36,8 @@ playground.xcworkspace # # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. # Packages/ +# Package.pins +# Package.resolved .build/ # CocoaPods @@ -43,6 +47,9 @@ playground.xcworkspace # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control # # Pods/ +# +# Add this line if you want to avoid checking in source code from the Xcode workspace +# *.xcworkspace # Carthage # @@ -53,10 +60,12 @@ Carthage/Build # fastlane # -# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the +# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the # screenshots whenever they are needed. # For more information about the recommended setup visit: -# https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md +# https://docs.fastlane.tools/best-practices/source-control/#source-control fastlane/report.xml -fastlane/screenshots +fastlane/Preview.html +fastlane/screenshots/**/*.png +fastlane/test_output \ No newline at end of file diff --git a/.gitmodules b/.gitmodules index 3eb60cc..e69de29 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +0,0 @@ -[submodule "Vendor/xcconfigs"] - path = Vendor/xcconfigs - url = https://github.com/jspahrsummers/xcconfigs.git diff --git a/PrimaryFlightDisplay.xcodeproj/project.pbxproj b/PrimaryFlightDisplay.xcodeproj/project.pbxproj index ec0c4eb..35187ba 100644 --- a/PrimaryFlightDisplay.xcodeproj/project.pbxproj +++ b/PrimaryFlightDisplay.xcodeproj/project.pbxproj @@ -43,6 +43,8 @@ 27B180261C844996006EEC9D /* TapeCellTriad.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27B180001C844973006EEC9D /* TapeCellTriad.swift */; }; 27B180271C844996006EEC9D /* TapeIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27B180011C844973006EEC9D /* TapeIndicator.swift */; }; 27B180281C844996006EEC9D /* TapePointer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27B180021C844973006EEC9D /* TapePointer.swift */; }; + 27EDC58D20F0B5EE00BB13A8 /* Release.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 27EDC58B20F0B5EE00BB13A8 /* Release.xcconfig */; }; + 27EDC58E20F0B5EE00BB13A8 /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 27EDC58C20F0B5EE00BB13A8 /* Debug.xcconfig */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -50,10 +52,6 @@ 27B17FC41C84309F006EEC9D /* PrimaryFlightDisplay.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PrimaryFlightDisplay.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 27B17FD01C843377006EEC9D /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = Resources/Info.plist; sourceTree = SOURCE_ROOT; }; 27B17FD91C843D73006EEC9D /* PrimaryFlightDisplay.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = PrimaryFlightDisplay.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 27B17FE81C8445C9006EEC9D /* Mac-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "Mac-Framework.xcconfig"; path = "Vendor/xcconfigs/Mac OS X/Mac-Framework.xcconfig"; sourceTree = ""; }; - 27B17FEA1C8445DD006EEC9D /* iOS-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "iOS-Framework.xcconfig"; path = "Vendor/xcconfigs/iOS/iOS-Framework.xcconfig"; sourceTree = ""; }; - 27B17FEC1C8445F6006EEC9D /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Vendor/xcconfigs/Base/Configurations/Debug.xcconfig; sourceTree = ""; }; - 27B17FEE1C844609006EEC9D /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Vendor/xcconfigs/Base/Configurations/Release.xcconfig; sourceTree = ""; }; 27B17FF01C844972006EEC9D /* Double+Additions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "Double+Additions.swift"; path = "Sources/Double+Additions.swift"; sourceTree = ""; }; 27B17FF11C844972006EEC9D /* Attitude.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Attitude.swift; path = Sources/Attitude.swift; sourceTree = ""; }; 27B17FF21C844972006EEC9D /* AttitudeReferenceIndex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = AttitudeReferenceIndex.swift; path = Sources/AttitudeReferenceIndex.swift; sourceTree = ""; }; @@ -71,6 +69,10 @@ 27B180001C844973006EEC9D /* TapeCellTriad.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TapeCellTriad.swift; path = Sources/TapeCellTriad.swift; sourceTree = ""; }; 27B180011C844973006EEC9D /* TapeIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TapeIndicator.swift; path = Sources/TapeIndicator.swift; sourceTree = ""; }; 27B180021C844973006EEC9D /* TapePointer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TapePointer.swift; path = Sources/TapePointer.swift; sourceTree = ""; }; + 27EDC58820F0B5A600BB13A8 /* iOS-Framework.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "iOS-Framework.xcconfig"; path = "Resources/xcconfigs/iOS/iOS-Framework.xcconfig"; sourceTree = SOURCE_ROOT; }; + 27EDC58A20F0B5D400BB13A8 /* Mac-Framework.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = "Mac-Framework.xcconfig"; path = "Resources/xcconfigs/Mac OS X/Mac-Framework.xcconfig"; sourceTree = SOURCE_ROOT; }; + 27EDC58B20F0B5EE00BB13A8 /* Release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Resources/xcconfigs/Base/Configurations/Release.xcconfig; sourceTree = SOURCE_ROOT; }; + 27EDC58C20F0B5EE00BB13A8 /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Resources/xcconfigs/Base/Configurations/Debug.xcconfig; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -96,7 +98,6 @@ children = ( 27B17FCF1C84335D006EEC9D /* Sources */, 27B17FC61C84309F006EEC9D /* Resources */, - 27B17FE71C8445A5006EEC9D /* Config */, 27B17FC51C84309F006EEC9D /* Products */, ); sourceTree = ""; @@ -113,6 +114,10 @@ 27B17FC61C84309F006EEC9D /* Resources */ = { isa = PBXGroup; children = ( + 27EDC58C20F0B5EE00BB13A8 /* Debug.xcconfig */, + 27EDC58B20F0B5EE00BB13A8 /* Release.xcconfig */, + 27EDC58A20F0B5D400BB13A8 /* Mac-Framework.xcconfig */, + 27EDC58820F0B5A600BB13A8 /* iOS-Framework.xcconfig */, 270D5FCF1C858D8700FB478A /* PrimaryFlightDisplay.h */, 27B17FD01C843377006EEC9D /* Info.plist */, ); @@ -141,17 +146,6 @@ name = Sources; sourceTree = ""; }; - 27B17FE71C8445A5006EEC9D /* Config */ = { - isa = PBXGroup; - children = ( - 27B17FEE1C844609006EEC9D /* Release.xcconfig */, - 27B17FEC1C8445F6006EEC9D /* Debug.xcconfig */, - 27B17FEA1C8445DD006EEC9D /* iOS-Framework.xcconfig */, - 27B17FE81C8445C9006EEC9D /* Mac-Framework.xcconfig */, - ); - name = Config; - sourceTree = ""; - }; 27B180351C857F84006EEC9D /* NumericExtensions */ = { isa = PBXGroup; children = ( @@ -261,6 +255,8 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 27EDC58E20F0B5EE00BB13A8 /* Debug.xcconfig in Resources */, + 27EDC58D20F0B5EE00BB13A8 /* Release.xcconfig in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -327,7 +323,7 @@ /* Begin XCBuildConfiguration section */ 27B17FCA1C84309F006EEC9D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 27B17FEC1C8445F6006EEC9D /* Debug.xcconfig */; + baseConfigurationReference = 27EDC58C20F0B5EE00BB13A8 /* Debug.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -369,6 +365,7 @@ ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -377,7 +374,7 @@ }; 27B17FCB1C84309F006EEC9D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 27B17FEE1C844609006EEC9D /* Release.xcconfig */; + baseConfigurationReference = 27EDC58B20F0B5EE00BB13A8 /* Release.xcconfig */; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; @@ -411,6 +408,7 @@ MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -420,7 +418,7 @@ }; 27B17FCD1C84309F006EEC9D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 27B17FEA1C8445DD006EEC9D /* iOS-Framework.xcconfig */; + baseConfigurationReference = 27EDC58820F0B5A600BB13A8 /* iOS-Framework.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; @@ -441,7 +439,7 @@ }; 27B17FCE1C84309F006EEC9D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 27B17FEA1C8445DD006EEC9D /* iOS-Framework.xcconfig */; + baseConfigurationReference = 27EDC58820F0B5A600BB13A8 /* iOS-Framework.xcconfig */; buildSettings = { CLANG_ENABLE_MODULES = YES; CODE_SIGN_IDENTITY = "iPhone Developer"; @@ -461,7 +459,7 @@ }; 27B17FDF1C843D73006EEC9D /* Debug */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 27B17FE81C8445C9006EEC9D /* Mac-Framework.xcconfig */; + baseConfigurationReference = 27EDC58A20F0B5D400BB13A8 /* Mac-Framework.xcconfig */; buildSettings = { CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; @@ -483,7 +481,7 @@ }; 27B17FE01C843D73006EEC9D /* Release */ = { isa = XCBuildConfiguration; - baseConfigurationReference = 27B17FE81C8445C9006EEC9D /* Mac-Framework.xcconfig */; + baseConfigurationReference = 27EDC58A20F0B5D400BB13A8 /* Mac-Framework.xcconfig */; buildSettings = { CODE_SIGN_IDENTITY = ""; COMBINE_HIDPI_IMAGES = YES; diff --git a/PrimaryFlightDisplay.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/PrimaryFlightDisplay.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/PrimaryFlightDisplay.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/PrimaryFlightDisplay.xcodeproj/xcshareddata/xcschemes/PrimaryFlightDisplay-Mac.xcscheme b/PrimaryFlightDisplay.xcodeproj/xcshareddata/xcschemes/PrimaryFlightDisplay-Mac.xcscheme index 3ce1a91..b907daa 100644 --- a/PrimaryFlightDisplay.xcodeproj/xcshareddata/xcschemes/PrimaryFlightDisplay-Mac.xcscheme +++ b/PrimaryFlightDisplay.xcodeproj/xcshareddata/xcschemes/PrimaryFlightDisplay-Mac.xcscheme @@ -1,6 +1,6 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.6.0 + 0.7.0 CFBundleSignature ???? CFBundleVersion diff --git a/Resources/xcconfigs/Base/Common.xcconfig b/Resources/xcconfigs/Base/Common.xcconfig new file mode 100755 index 0000000..9ae14eb --- /dev/null +++ b/Resources/xcconfigs/Base/Common.xcconfig @@ -0,0 +1,221 @@ +// +// This file defines common settings that should be enabled for every new +// project. Typically, you want to use Debug, Release, or a similar variant +// instead. +// + +// Disable legacy-compatible header searching +ALWAYS_SEARCH_USER_PATHS = NO + +// Architectures to build +ARCHS = $(ARCHS_STANDARD) + +// Whether to warn when a floating-point value is used as a loop counter +CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES + +// Whether to warn about use of rand() and random() being used instead of arc4random() +CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES + +// Whether to warn about strcpy() and strcat() +CLANG_ANALYZER_SECURITY_INSECUREAPI_STRCPY = YES + +// Whether to enable module imports +CLANG_ENABLE_MODULES = YES + +// Enable ARC +CLANG_ENABLE_OBJC_ARC = YES + +// Warn about block captures of implicitly autoreleasing parameters. +CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES + +// Warn about implicit conversions to boolean values that are suspicious. +// For example, writing 'if (foo)' with 'foo' being the name a function will trigger a warning. +CLANG_WARN_BOOL_CONVERSION = YES + +// Warn about suspicious uses of the comma operator. +CLANG_WARN_COMMA = YES + +// Warn about implicit conversions of constant values that cause the constant value to change, +// either through a loss of precision, or entirely in its meaning. +CLANG_WARN_CONSTANT_CONVERSION = YES + +// Whether to warn when overriding deprecated methods +CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES + +// Warn about direct accesses to the Objective-C 'isa' pointer instead of using a runtime API. +CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR + +// Warn about declaring the same method more than once within the same @interface. +CLANG_WARN__DUPLICATE_METHOD_MATCH = YES + +// Warn about loop bodies that are suspiciously empty. +CLANG_WARN_EMPTY_BODY = YES + +// Warn about implicit conversions between different kinds of enum values. +// For example, this can catch issues when using the wrong enum flag as an argument to a function or method. +CLANG_WARN_ENUM_CONVERSION = YES + +// Whether to warn on implicit conversions between signed/unsigned types +CLANG_WARN_IMPLICIT_SIGN_CONVERSION = NO + +// Warn about implicit conversions between pointers and integers. +// For example, this can catch issues when one incorrectly intermixes using NSNumbers and raw integers. +CLANG_WARN_INT_CONVERSION = YES + +// Warn about non-literal expressions that evaluate to zero being treated as a null pointer. +CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES + +// Warn about implicit capture of self (e.g. direct ivar access) +CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES + +// Warn about implicit conversions from Objective-C literals to values of incompatible type. +CLANG_WARN_OBJC_LITERAL_CONVERSION = YES + +// Don't warn about repeatedly using a weak reference without assigning the weak reference to a strong reference. Too many false positives. +CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = NO + +// Warn about classes that unintentionally do not subclass a root class (such as NSObject). +CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR + +// Warn about ranged-based for loops. +CLANG_WARN_RANGE_LOOP_ANALYSIS = YES + +// Whether to warn on suspicious implicit conversions +CLANG_WARN_SUSPICIOUS_IMPLICIT_CONVERSION = YES + +// Warn about non-prototype declarations. +CLANG_WARN_STRICT_PROTOTYPES = YES + +// Warn if an API that is newer than the deployment target is used without "if (@available(...))" guards. +CLANG_WARN_UNGUARDED_AVAILABILITY = YES + +// Warn about incorrect uses of nullable values +CLANG_WARN_NULLABLE_TO_NONNULL_CONVERSION = YES + +// Warn for missing nullability attributes +CLANG_ANALYZER_NONNULL = YES + +// Warn when a non-localized string is passed to a user-interface method expecting a localized string +CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES + +// Warn about potentially unreachable code +CLANG_WARN_UNREACHABLE_CODE = YES + +// The format of debugging symbols +DEBUG_INFORMATION_FORMAT = dwarf-with-dsym + +// Whether to compile assertions in +ENABLE_NS_ASSERTIONS = YES + +// Whether to require objc_msgSend to be cast before invocation +ENABLE_STRICT_OBJC_MSGSEND = YES + +// Which C variant to use +GCC_C_LANGUAGE_STANDARD = gnu99 + +// Whether to enable exceptions for Objective-C +GCC_ENABLE_OBJC_EXCEPTIONS = YES + +// Whether to generate debugging symbols +GCC_GENERATE_DEBUGGING_SYMBOLS = YES + +// Whether to precompile the prefix header (if one is specified) +GCC_PRECOMPILE_PREFIX_HEADER = YES + +// Whether to enable strict aliasing, meaning that two pointers of different +// types (other than void * or any id type) cannot point to the same memory +// location +GCC_STRICT_ALIASING = YES + +// Whether symbols not explicitly exported are hidden by default (this primarily +// only affects C++ code) +GCC_SYMBOLS_PRIVATE_EXTERN = NO + +// Whether static variables are thread-safe by default +GCC_THREADSAFE_STATICS = NO + +// Which compiler to use +GCC_VERSION = com.apple.compilers.llvm.clang.1_0 + +// Whether warnings are treated as errors +GCC_TREAT_WARNINGS_AS_ERRORS = YES +SWIFT_TREAT_WARNINGS_AS_ERRORS = YES + +// Whether to warn about 64-bit values being implicitly shortened to 32 bits +GCC_WARN_64_TO_32_BIT_CONVERSION = YES + +// Whether to warn about fields missing from structure initializers (only if +// designated initializers aren't used) +GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES + +// Whether to warn about missing function prototypes +GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO + +// Whether to warn about implicit conversions in the signedness of the type +// a pointer is pointing to (e.g., 'int *' getting converted to 'unsigned int *') +GCC_WARN_ABOUT_POINTER_SIGNEDNESS = YES + +// Whether to warn when the value returned from a function/method/block does not +// match its return type +GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR + +// Whether to warn on a class not implementing all the required methods of +// a protocol it declares conformance to +GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = YES + +// Whether to warn when switching on an enum value, and all possibilities are +// not accounted for +GCC_WARN_CHECK_SWITCH_STATEMENTS = YES + +// Whether to warn about the use of four-character constants +GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES + +// Whether to warn about an aggregate data type's initializer not being fully +// bracketed (e.g., array initializer syntax) +GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES + +// Whether to warn about missing braces or parentheses that make the meaning of +// the code ambiguous +GCC_WARN_MISSING_PARENTHESES = YES + +// Whether to warn about unsafe comparisons between values of different +// signedness +GCC_WARN_SIGN_COMPARE = YES + +// Whether to warn about the arguments to printf-style functions not matching +// the format specifiers +GCC_WARN_TYPECHECK_CALLS_TO_PRINTF = YES + +// Warn if a "@selector(...)" expression referring to an undeclared selector is found +GCC_WARN_UNDECLARED_SELECTOR = YES + +// Warn if a variable might be clobbered by a setjmp call or if an automatic variable is used without prior initialization. +GCC_WARN_UNINITIALIZED_AUTOS = YES + +// Whether to warn about static functions that are unused +GCC_WARN_UNUSED_FUNCTION = YES + +// Whether to warn about labels that are unused +GCC_WARN_UNUSED_LABEL = YES + +// Whether to warn about variables that are never used +GCC_WARN_UNUSED_VARIABLE = YES + +// Whether to run the static analyzer with every build +RUN_CLANG_STATIC_ANALYZER = YES + +// Don't treat unknown warnings as errors, and disable GCC compatibility warnings and unused static const variable warnings +WARNING_CFLAGS = -Wno-error=unknown-warning-option -Wno-gcc-compat -Wno-unused-const-variable + +// This setting is on for new projects as of Xcode ~6.3, though it is still not +// the default. It warns if the same variable is declared in two binaries that +// are linked together. +GCC_NO_COMMON_BLOCKS = YES + +// This warnings detects when a function will recursively call itself on every +// code path though that function. More information can be found here: +// http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20131216/096004.html +CLANG_WARN_INFINITE_RECURSION = YES + +// This warning detects suspicious uses of std::move. +CLANG_WARN_SUSPICIOUS_MOVE = YES diff --git a/Resources/xcconfigs/Base/Configurations/Debug.xcconfig b/Resources/xcconfigs/Base/Configurations/Debug.xcconfig new file mode 100755 index 0000000..65c62ab --- /dev/null +++ b/Resources/xcconfigs/Base/Configurations/Debug.xcconfig @@ -0,0 +1,51 @@ +// +// This file defines the base configuration for a Debug build of any project. +// This should be set at the project level for the Debug configuration. +// + +#include "../Common.xcconfig" + +// Whether to strip debugging symbols when copying resources (like included +// binaries) +COPY_PHASE_STRIP = NO + +// The optimization level (0, 1, 2, 3, s) for the produced binary +GCC_OPTIMIZATION_LEVEL = 0 + +// Preproccessor definitions to apply to each file compiled +GCC_PREPROCESSOR_DEFINITIONS = DEBUG=1 + +// Allow @testable imports +ENABLE_TESTABILITY = YES + +// Whether to enable link-time optimizations (such as inlining across translation +// units) +LLVM_LTO = NO + +// Whether to only build the active architecture +ONLY_ACTIVE_ARCH = YES + +// Other compiler flags +// +// These settings catch some errors in integer arithmetic +OTHER_CFLAGS = -ftrapv + +// Other flags to pass to the Swift compiler +// +// This enables conditional compilation with #if DEBUG +OTHER_SWIFT_FLAGS = -D DEBUG + +// Xcode 8 introduced a new flag for conditional compilation +// +// This enables conditional compilation with #if DEBUG +SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG + +// Whether to strip debugging symbols when copying the built product to its +// final installation location +STRIP_INSTALLED_PRODUCT = NO + +// The optimization level (-Onone, -O, -Osize) for the produced Swift binary +SWIFT_OPTIMIZATION_LEVEL = -Onone + +// Disable Developer ID timestamping +OTHER_CODE_SIGN_FLAGS = --timestamp=none diff --git a/Resources/xcconfigs/Base/Configurations/Profile.xcconfig b/Resources/xcconfigs/Base/Configurations/Profile.xcconfig new file mode 100755 index 0000000..0d01553 --- /dev/null +++ b/Resources/xcconfigs/Base/Configurations/Profile.xcconfig @@ -0,0 +1,27 @@ +// +// This file defines the base configuration for an optional profiling-specific +// build of any project. To use these settings, create a Profile configuration +// in your project, and use this file at the project level for the new +// configuration. +// + +// based on the Release configuration, with some stuff related to debugging +// symbols re-enabled +#include "Release.xcconfig" + +// Whether to strip debugging symbols when copying resources (like included +// binaries) +COPY_PHASE_STRIP = NO + +// Whether to only build the active architecture +ONLY_ACTIVE_ARCH = YES + +// Whether to strip debugging symbols when copying the built product to its +// final installation location +STRIP_INSTALLED_PRODUCT = NO + +// Whether to perform App Store validation checks +VALIDATE_PRODUCT = NO + +// Disable Developer ID timestamping +OTHER_CODE_SIGN_FLAGS = --timestamp=none diff --git a/Resources/xcconfigs/Base/Configurations/Release.xcconfig b/Resources/xcconfigs/Base/Configurations/Release.xcconfig new file mode 100755 index 0000000..f44f853 --- /dev/null +++ b/Resources/xcconfigs/Base/Configurations/Release.xcconfig @@ -0,0 +1,37 @@ +// +// This file defines the base configuration for a Release build of any project. +// This should be set at the project level for the Release configuration. +// + +#include "../Common.xcconfig" + +// Whether to strip debugging symbols when copying resources (like included +// binaries) +COPY_PHASE_STRIP = YES + +// The optimization level (0, 1, 2, 3, s) for the produced binary +GCC_OPTIMIZATION_LEVEL = s + +// Preproccessor definitions to apply to each file compiled +GCC_PREPROCESSOR_DEFINITIONS = NDEBUG=1 + +// Whether to enable link-time optimizations (such as inlining across translation +// units) +LLVM_LTO = NO + +// Whether to only build the active architecture +ONLY_ACTIVE_ARCH = NO + +// Whether to strip debugging symbols when copying the built product to its +// final installation location +STRIP_INSTALLED_PRODUCT = YES + +// The optimization level (-Onone, -O, -Osize) for the produced Swift binary +SWIFT_OPTIMIZATION_LEVEL = -O + +// Compilation mode (independent of optimization level) +SWIFT_COMPILATION_MODE = wholemodule + +// Whether to perform App Store validation checks +VALIDATE_PRODUCT = YES + diff --git a/Resources/xcconfigs/Base/Configurations/Test.xcconfig b/Resources/xcconfigs/Base/Configurations/Test.xcconfig new file mode 100755 index 0000000..bf17949 --- /dev/null +++ b/Resources/xcconfigs/Base/Configurations/Test.xcconfig @@ -0,0 +1,13 @@ +// +// This file defines the base configuration for a Test build of any project. +// This should be set at the project level for the Test configuration. +// + +#include "Debug.xcconfig" + +// Sandboxed apps can't be unit tested since they can't load some random +// external bundle. So we disable sandboxing for testing. +CODE_SIGN_ENTITLEMENTS = + +// Allow @testable imports +ENABLE_TESTABILITY = YES diff --git a/Resources/xcconfigs/Base/Targets/Application.xcconfig b/Resources/xcconfigs/Base/Targets/Application.xcconfig new file mode 100755 index 0000000..a91feca --- /dev/null +++ b/Resources/xcconfigs/Base/Targets/Application.xcconfig @@ -0,0 +1,12 @@ +// +// This file defines additional configuration options that are appropriate only +// for an application. Typically, you want to use a platform-specific variant +// instead. +// + +// Whether to strip out code that isn't called from anywhere +DEAD_CODE_STRIPPING = NO + +// Sets the @rpath for the application such that it can include frameworks in +// the application bundle (inside the "Frameworks" folder) +LD_RUNPATH_SEARCH_PATHS = @executable_path/../Frameworks @loader_path/../Frameworks @executable_path/Frameworks diff --git a/Resources/xcconfigs/Base/Targets/Extension.xcconfig b/Resources/xcconfigs/Base/Targets/Extension.xcconfig new file mode 100755 index 0000000..beb7990 --- /dev/null +++ b/Resources/xcconfigs/Base/Targets/Extension.xcconfig @@ -0,0 +1,8 @@ +// +// This file defines additional configuration options that are appropriate only +// for an extension embedded within an application. Typically, you want to use a +// platform-specific variant instead. +// + +// Whether to strip out code that isn't called from anywhere +DEAD_CODE_STRIPPING = NO diff --git a/Resources/xcconfigs/Base/Targets/Framework.xcconfig b/Resources/xcconfigs/Base/Targets/Framework.xcconfig new file mode 100755 index 0000000..c92f57f --- /dev/null +++ b/Resources/xcconfigs/Base/Targets/Framework.xcconfig @@ -0,0 +1,37 @@ +// +// This file defines additional configuration options that are appropriate only +// for a framework. Typically, you want to use a platform-specific variant +// instead. +// + +// Disable code signing for successful device builds with Xcode 8. Frameworks do +// need to be signed, but they don't need to be signed at compile time because +// they'll be re-signed when you include them in your app. +CODE_SIGNING_REQUIRED = NO +CODE_SIGN_IDENTITY = + +// Whether to strip out code that isn't called from anywhere +DEAD_CODE_STRIPPING = NO + +// Whether this framework should define an LLVM module +DEFINES_MODULE = YES + +// Whether function calls should be position-dependent (should always be +// disabled for library code) +GCC_DYNAMIC_NO_PIC = NO + +// Default frameworks to the name of the project, instead of any +// platform-specific target +PRODUCT_NAME = $(PROJECT_NAME) + +// Enables the framework to be included from any location as long as the +// loader’s runpath search paths includes it. For example from an application +// bundle (inside the "Frameworks" folder) or shared folder +INSTALL_PATH = @rpath +LD_DYLIB_INSTALL_NAME = @rpath/$(PRODUCT_NAME).$(WRAPPER_EXTENSION)/$(PRODUCT_NAME) +SKIP_INSTALL = YES + +// Disallows use of APIs that are not available +// to app extensions and linking to frameworks +// that have not been built with this setting enabled. +APPLICATION_EXTENSION_API_ONLY = YES diff --git a/Resources/xcconfigs/Base/Targets/StaticLibrary.xcconfig b/Resources/xcconfigs/Base/Targets/StaticLibrary.xcconfig new file mode 100755 index 0000000..b3b2b87 --- /dev/null +++ b/Resources/xcconfigs/Base/Targets/StaticLibrary.xcconfig @@ -0,0 +1,32 @@ +// +// This file defines additional configuration options that are appropriate only +// for a static library. Typically, you want to use a platform-specific variant +// instead. +// + +// Whether to strip out code that isn't called from anywhere +DEAD_CODE_STRIPPING = NO + +// Whether to strip debugging symbols when copying resources (like included +// binaries). +// +// Overrides Release.xcconfig when used at the target level. +COPY_PHASE_STRIP = NO + +// Whether function calls should be position-dependent (should always be +// disabled for library code) +GCC_DYNAMIC_NO_PIC = NO + +// Copy headers to "include/LibraryName" in the build folder by default. This +// lets consumers use #import syntax even for static +// libraries +PUBLIC_HEADERS_FOLDER_PATH = include/$PRODUCT_NAME + +// Don't include in an xcarchive +SKIP_INSTALL = YES + +// Disallows use of APIs that are not available +// to app extensions and linking to frameworks +// that have not been built with this setting enabled. +APPLICATION_EXTENSION_API_ONLY = YES + diff --git a/Resources/xcconfigs/Mac OS X/Mac-Application.xcconfig b/Resources/xcconfigs/Mac OS X/Mac-Application.xcconfig new file mode 100755 index 0000000..f2123e6 --- /dev/null +++ b/Resources/xcconfigs/Mac OS X/Mac-Application.xcconfig @@ -0,0 +1,21 @@ +// +// This file defines additional configuration options that are appropriate only +// for an application on Mac OS X. This should be set at the target level for +// each project configuration. +// + +// Import base application settings +#include "../Base/Targets/Application.xcconfig" + +// Apply common settings specific to Mac OS X +#include "Mac-Base.xcconfig" + +// Whether function calls should be position-dependent (should always be +// disabled for library code) +GCC_DYNAMIC_NO_PIC = YES + +// Where to find embedded frameworks +// Search `Frameworks` in the .app. +// If app is cli at `/usr/local/bin/foo`, `@executable_path/../Frameworks` +// means `/usr/local/Frameworks`. +LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../Frameworks diff --git a/Resources/xcconfigs/Mac OS X/Mac-Base.xcconfig b/Resources/xcconfigs/Mac OS X/Mac-Base.xcconfig new file mode 100755 index 0000000..58c92de --- /dev/null +++ b/Resources/xcconfigs/Mac OS X/Mac-Base.xcconfig @@ -0,0 +1,16 @@ +// +// This file defines additional configuration options that are appropriate only +// for Mac OS X. This file is not standalone -- it is meant to be included into +// a configuration file for a specific type of target. +// + +// Whether to combine multiple image resolutions into a multirepresentational +// TIFF +COMBINE_HIDPI_IMAGES = YES + +// The base SDK to use (if no version is specified, the latest version is +// assumed) +SDKROOT = macosx + +// Supported build architectures +VALID_ARCHS = x86_64 diff --git a/Resources/xcconfigs/Mac OS X/Mac-DynamicLibrary.xcconfig b/Resources/xcconfigs/Mac OS X/Mac-DynamicLibrary.xcconfig new file mode 100755 index 0000000..1e2a37c --- /dev/null +++ b/Resources/xcconfigs/Mac OS X/Mac-DynamicLibrary.xcconfig @@ -0,0 +1,18 @@ +// +// This file defines additional configuration options that are appropriate only +// for a dynamic library on Mac OS X. This should be set at the target level +// for each project configuration. +// + +// Import common settings specific to Mac OS X +#include "Mac-Base.xcconfig" + +// Whether to strip out code that isn't called from anywhere +DEAD_CODE_STRIPPING = NO + +// Whether function calls should be position-dependent (should always be +// disabled for library code) +GCC_DYNAMIC_NO_PIC = NO + +// Don't include in an xcarchive +SKIP_INSTALL = YES diff --git a/Resources/xcconfigs/Mac OS X/Mac-Framework.xcconfig b/Resources/xcconfigs/Mac OS X/Mac-Framework.xcconfig new file mode 100755 index 0000000..c0e0087 --- /dev/null +++ b/Resources/xcconfigs/Mac OS X/Mac-Framework.xcconfig @@ -0,0 +1,17 @@ +// +// This file defines additional configuration options that are appropriate only +// for a framework on OS X. This should be set at the target level for each +// project configuration. +// + +// Import base framework settings +#include "../Base/Targets/Framework.xcconfig" + +// Import common settings specific to Mac OS X +#include "Mac-Base.xcconfig" + +// Where to find embedded frameworks. +// First search `Frameworks` in the .framework, then one in the .app. +// If app is cli at `/usr/local/bin/foo`, `@executable_path/../Frameworks` +// means `/usr/local/Frameworks`. +LD_RUNPATH_SEARCH_PATHS = $(inherited) @loader_path/Frameworks @executable_path/../Frameworks diff --git a/Resources/xcconfigs/Mac OS X/Mac-StaticLibrary.xcconfig b/Resources/xcconfigs/Mac OS X/Mac-StaticLibrary.xcconfig new file mode 100755 index 0000000..97d0318 --- /dev/null +++ b/Resources/xcconfigs/Mac OS X/Mac-StaticLibrary.xcconfig @@ -0,0 +1,11 @@ +// +// This file defines additional configuration options that are appropriate only +// for a static library on Mac OS X. This should be set at the target level for +// each project configuration. +// + +// Import base static library settings +#include "../Base/Targets/StaticLibrary.xcconfig" + +// Apply common settings specific to Mac OS X +#include "Mac-Base.xcconfig" diff --git a/Resources/xcconfigs/Mac OS X/Mac-XCTest.xcconfig b/Resources/xcconfigs/Mac OS X/Mac-XCTest.xcconfig new file mode 100755 index 0000000..33207a8 --- /dev/null +++ b/Resources/xcconfigs/Mac OS X/Mac-XCTest.xcconfig @@ -0,0 +1,16 @@ +// +// This file defines additional configuration options that are appropriate only +// for an application on Mac OS X. This should be set at the target level for +// each project configuration. +// + +// Import base application settings +#include "../Base/Targets/Application.xcconfig" + +// Apply common settings specific to Mac OS X +#include "Mac-Base.xcconfig" + +// Whether function calls should be position-dependent (should always be +// disabled for library code) +GCC_DYNAMIC_NO_PIC = YES + diff --git a/Resources/xcconfigs/README.md b/Resources/xcconfigs/README.md new file mode 100755 index 0000000..8b69024 --- /dev/null +++ b/Resources/xcconfigs/README.md @@ -0,0 +1,13 @@ +This project intends to aggregate common or universal Xcode configuration settings, keeping them in hierarchial Xcode configuration files for easy modification and reuse. + +## License + +This is free and unencumbered software released into the public domain. + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. + +In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +For more information, please refer to [unlicense.org](http://unlicense.org). diff --git a/Resources/xcconfigs/iOS/iOS-Application.xcconfig b/Resources/xcconfigs/iOS/iOS-Application.xcconfig new file mode 100755 index 0000000..a700868 --- /dev/null +++ b/Resources/xcconfigs/iOS/iOS-Application.xcconfig @@ -0,0 +1,11 @@ +// +// This file defines additional configuration options that are appropriate only +// for an application on iOS. This should be set at the target level for each +// project configuration. +// + +// Import base application settings +#include "../Base/Targets/Application.xcconfig" + +// Apply common settings specific to iOS +#include "iOS-Base.xcconfig" diff --git a/Resources/xcconfigs/iOS/iOS-Base.xcconfig b/Resources/xcconfigs/iOS/iOS-Base.xcconfig new file mode 100755 index 0000000..f45f905 --- /dev/null +++ b/Resources/xcconfigs/iOS/iOS-Base.xcconfig @@ -0,0 +1,18 @@ +// +// This file defines additional configuration options that are appropriate only +// for iOS. This file is not standalone -- it is meant to be included into +// a configuration file for a specific type of target. +// + +// Xcode needs this to find archived headers if SKIP_INSTALL is set +HEADER_SEARCH_PATHS = $(OBJROOT)/UninstalledProducts/include + +// Where to find embedded frameworks +LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks @loader_path/Frameworks + +// The base SDK to use (if no version is specified, the latest version is +// assumed) +SDKROOT = iphoneos + +// Supported device families (1 is iPhone, 2 is iPad) +TARGETED_DEVICE_FAMILY = 1,2 diff --git a/Resources/xcconfigs/iOS/iOS-Extension.xcconfig b/Resources/xcconfigs/iOS/iOS-Extension.xcconfig new file mode 100755 index 0000000..c503845 --- /dev/null +++ b/Resources/xcconfigs/iOS/iOS-Extension.xcconfig @@ -0,0 +1,23 @@ +// +// This file defines additional configuration options that are appropriate only +// for an extension embedded within an application on iOS. This should be set at +// the target level for each project configuration. +// + +// Import base extension settings +#include "../Base/Targets/Extension.xcconfig" + +// Apply common settings specific to iOS +#include "iOS-Base.xcconfig" + +// Sets the @rpath for the application such that it can include frameworks in +// the application bundle two levels up, inside the "Frameworks" folder. +// +// Does not search the frameworks folder at the same level as the extension +// executable since extensions with their own embedded frameworks are rejected +// with the following error: +// +// > Invalid Bundle. The bundle at 'App.app/PlugIns/Extension.appex' contains +// > disallowed file 'Frameworks' +// +LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/../../Frameworks diff --git a/Resources/xcconfigs/iOS/iOS-Framework.xcconfig b/Resources/xcconfigs/iOS/iOS-Framework.xcconfig new file mode 100755 index 0000000..e538a7d --- /dev/null +++ b/Resources/xcconfigs/iOS/iOS-Framework.xcconfig @@ -0,0 +1,11 @@ +// +// This file defines additional configuration options that are appropriate only +// for a framework on iOS. This should be set at the target level for each +// project configuration. +// + +// Import base framework settings +#include "../Base/Targets/Framework.xcconfig" + +// Import common settings specific to iOS +#include "iOS-Base.xcconfig" diff --git a/Resources/xcconfigs/iOS/iOS-StaticLibrary.xcconfig b/Resources/xcconfigs/iOS/iOS-StaticLibrary.xcconfig new file mode 100755 index 0000000..7e3b507 --- /dev/null +++ b/Resources/xcconfigs/iOS/iOS-StaticLibrary.xcconfig @@ -0,0 +1,11 @@ +// +// This file defines additional configuration options that are appropriate only +// for a static library on iOS. This should be set at the target level for each +// project configuration. +// + +// Import base static library settings +#include "../Base/Targets/StaticLibrary.xcconfig" + +// Apply common settings specific to iOS +#include "iOS-Base.xcconfig" diff --git a/Sources/Attitude.swift b/Sources/Attitude.swift index 26d5155..d9bf13c 100644 --- a/Sources/Attitude.swift +++ b/Sources/Attitude.swift @@ -13,27 +13,27 @@ protocol AttitudeType { var pitchRadians: Double { get } func rollAction() -> SKAction - func pitchAction(sceneSize sceneSize: CGSize) -> SKAction - func pitchReverseAction(sceneSize sceneSize: CGSize) -> SKAction + func pitchAction(sceneSize: CGSize) -> SKAction + func pitchReverseAction(sceneSize: CGSize) -> SKAction } protocol AttitudeSettable { - func setAttitude(attitude: AttitudeType) + func setAttitude(_ attitude: AttitudeType) } extension AttitudeType { func rollAction() -> SKAction { - return SKAction.rotateToAngle(CGFloat(rollRadians), duration: 0.05, shortestUnitArc: true) + return SKAction.rotate(toAngle: CGFloat(rollRadians), duration: 0.05, shortestUnitArc: true) } - func pitchAction(sceneSize sceneSize: CGSize) -> SKAction { + func pitchAction(sceneSize: CGSize) -> SKAction { let displacement = CGFloat(pitchRadians) * -1 * sceneSize.pointsPerRadian - return SKAction.moveToY(displacement, duration: 0.05) + return SKAction.moveTo(y: displacement, duration: 0.05) } - func pitchReverseAction(sceneSize sceneSize: CGSize) -> SKAction { + func pitchReverseAction(sceneSize: CGSize) -> SKAction { let displacement = CGFloat(pitchRadians) * sceneSize.pointsPerRadian - return SKAction.moveToY(displacement, duration: 0.05) + return SKAction.moveTo(y: displacement, duration: 0.05) } } diff --git a/Sources/AttitudeReferenceIndex.swift b/Sources/AttitudeReferenceIndex.swift index f455701..d4e4c1e 100644 --- a/Sources/AttitudeReferenceIndex.swift +++ b/Sources/AttitudeReferenceIndex.swift @@ -16,8 +16,8 @@ class AttitudeReferenceIndex: SKNode { self.style = style super.init() - addChild(buildLeftBar(transform: CGAffineTransformMakeTranslation(CGFloat(-style.sideBarOffset), 0))) - addChild(buildLeftBar(transform: CGAffineTransformMake(-1, 0, 0, 1, CGFloat(style.sideBarOffset), 0))) + addChild(buildLeftBar(transform: CGAffineTransform(translationX: CGFloat(-style.sideBarOffset), y: 0))) + addChild(buildLeftBar(transform: CGAffineTransform(a: -1, b: 0, c: 0, d: 1, tx: CGFloat(style.sideBarOffset), ty: 0))) addChild(buildCenterBar()) } @@ -25,22 +25,22 @@ class AttitudeReferenceIndex: SKNode { fatalError("init(coder:) has not been implemented") } - private func buildLeftBar(transform transform: CGAffineTransform) -> SKShapeNode { + private func buildLeftBar(transform: CGAffineTransform) -> SKShapeNode { let width = CGFloat(style.sideBarWidth) let height = CGFloat(style.sideBarHeight) - let path = CGPathCreateMutable() - CGPathMoveToPoint(path, nil, -width, 2) - CGPathAddLineToPoint(path, nil, 0, 2) - CGPathAddLineToPoint(path, nil, 0, -height) - CGPathAddLineToPoint(path, nil, -4, -height) - CGPathAddLineToPoint(path, nil, -4, -2) - CGPathAddLineToPoint(path, nil, -width, -2) - CGPathCloseSubpath(path) + let path = CGMutablePath() + path.move(to: CGPoint(x: -width, y: 2)) + path.addLine(to: CGPoint(x: 0, y: 2)) + path.addLine(to: CGPoint(x: 0, y: -height)) + path.addLine(to: CGPoint(x: -4, y: -height)) + path.addLine(to: CGPoint(x: -4, y: -2)) + path.addLine(to: CGPoint(x: -width, y: -2)) + path.closeSubpath() var trans = transform - let transformedPath = withUnsafeMutablePointer(&trans) { - CGPathCreateMutableCopyByTransformingPath(path, $0) + let transformedPath = withUnsafeMutablePointer(to: &trans) { + path.mutableCopy(using: $0) } let shape = SKShapeNode(path: transformedPath!) @@ -51,12 +51,12 @@ class AttitudeReferenceIndex: SKNode { private func buildCenterBar() -> SKShapeNode { let halfWidth = CGFloat(style.centerBarWidth) / 2 - let path = CGPathCreateMutable() - CGPathMoveToPoint(path, nil, -halfWidth, 2) - CGPathAddLineToPoint(path, nil, halfWidth, 2) - CGPathAddLineToPoint(path, nil, halfWidth, -2) - CGPathAddLineToPoint(path, nil, -halfWidth, -2) - CGPathCloseSubpath(path) + let path = CGMutablePath() + path.move(to: CGPoint(x: -halfWidth, y: 2)) + path.addLine(to: CGPoint(x: halfWidth, y: 2)) + path.addLine(to: CGPoint(x: halfWidth, y: -2)) + path.addLine(to: CGPoint(x: -halfWidth, y: -2)) + path.closeSubpath() let shape = SKShapeNode(path: path) shape.fillColor = style.fillColor diff --git a/Sources/BankIndicator.swift b/Sources/BankIndicator.swift index 632ad58..ea1d120 100644 --- a/Sources/BankIndicator.swift +++ b/Sources/BankIndicator.swift @@ -27,8 +27,8 @@ class BankIndicator: SKNode { extension BankIndicator: AttitudeSettable { - func setAttitude(attitude: AttitudeType) { - bankArc.runAction(attitude.rollAction()) + func setAttitude(_ attitude: AttitudeType) { + bankArc.run(attitude.rollAction()) } } @@ -37,16 +37,16 @@ private class SkyPointer: SKNode { init(style: BankIndicatorStyleType) { super.init() - let path = CGPathCreateMutable() - CGPathMoveToPoint(path, nil, -CGFloat(style.skyPointerWidth)/2, 0) - CGPathAddLineToPoint(path, nil, CGFloat(style.skyPointerWidth)/2, 0) - CGPathAddLineToPoint(path, nil, 0, CGFloat(style.skyPointerHeight)) - CGPathCloseSubpath(path) + let path = CGMutablePath() + path.move(to: CGPoint(x: -CGFloat(style.skyPointerWidth)/2, y: 0)) + path.addLine(to: CGPoint(x: CGFloat(style.skyPointerWidth)/2, y: 0)) + path.addLine(to: CGPoint(x: 0, y: CGFloat(style.skyPointerHeight))) + path.closeSubpath() let shape = SKShapeNode(path: path) shape.fillColor = style.skyPointerFillColor shape.strokeColor = style.skyPointerFillColor - shape.lineJoin = .Miter + shape.lineJoin = .miter shape.position = CGPoint(x: 0, y: style.arcRadius - style.skyPointerHeight - style.arcLineWidth*2) addChild(shape) } @@ -58,7 +58,7 @@ private class SkyPointer: SKNode { private class BankArc: SKNode { - private let degreeValues = Array((-175).stride(to: 181, by: 5)) + private let degreeValues = Array(stride(from: -175, to: 181, by: 5)) private let style: BankIndicatorStyleType init(style: BankIndicatorStyleType) { @@ -79,7 +79,7 @@ private class BankArc: SKNode { let arc = SKShapeNode(circleOfRadius: CGFloat(style.arcRadius)) let cropNode = SKCropNode() let maskNodeEdgeSize = style.arcRadius * 2 + style.arcLineWidth - let maskNode = SKSpriteNode(color: SKColor.blackColor(), size: CGSize(width: maskNodeEdgeSize, height: maskNodeEdgeSize)) + let maskNode = SKSpriteNode(color: SKColor.black, size: CGSize(width: maskNodeEdgeSize, height: maskNodeEdgeSize)) let maxDegree = style.arcMaximumDisplayDegree arc.lineWidth = CGFloat(style.arcLineWidth) @@ -96,15 +96,15 @@ private class BankArc: SKNode { }.map { (degree: $0, displayText: "\(abs($0))") }.forEach { marker in - let type: BankArcMarkerType = marker.degree % 15 == 0 ? .Major : . Minor + let type: BankArcMarkerType = marker.degree % 15 == 0 ? .major : . minor addChild(BankArcMarker(marker: marker, type: type, style: style)) } } } private enum BankArcMarkerType { - case Major - case Minor + case major + case minor } private class BankArcMarker: SKNode { @@ -113,28 +113,28 @@ private class BankArcMarker: SKNode { super.init() let radians = marker.degree.radians - let rotateAction = SKAction.rotateByAngle(-radians, duration: 0) + let rotateAction = SKAction.rotate(byAngle: -radians, duration: 0) let moveAction = { (offset: CGFloat) -> SKAction in - SKAction.moveBy(CGVector(dx: offset * sin(radians), dy: offset * cos(radians)), duration: 0) + SKAction.move(by: CGVector(dx: offset * sin(radians), dy: offset * cos(radians)), duration: 0) } - let height = (type == .Major ? style.majorMarkerHeight : style.minorMarkerHeight) - let line = SKShapeNode(rectOfSize: CGSize(width: 0, height: height)) + let height = (type == .major ? style.majorMarkerHeight : style.minorMarkerHeight) + let line = SKShapeNode(rectOf: CGSize(width: 0, height: height)) line.strokeColor = style.arcStrokeColor line.fillColor = style.arcStrokeColor let offset = CGFloat(style.arcRadius + (height / 2)) - line.runAction(SKAction.sequence([rotateAction, moveAction(offset)])) - line.antialiased = true + line.run(SKAction.sequence([rotateAction, moveAction(offset)])) + line.isAntialiased = true addChild(line) - if type == .Major { + if type == .major { let label = SKLabelNode(text: marker.displayText) label.fontName = style.font.family label.fontSize = style.font.size label.fontColor = style.textColor let offset = CGFloat(style.arcRadius + style.markerTextOffset) - label.runAction(SKAction.sequence([rotateAction, moveAction(offset)])) + label.run(SKAction.sequence([rotateAction, moveAction(offset)])) addChild(label) } } @@ -142,4 +142,4 @@ private class BankArcMarker: SKNode { required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } -} \ No newline at end of file +} diff --git a/Sources/CGFloat+Additions.swift b/Sources/CGFloat+Additions.swift index a0ac11c..41c93f9 100644 --- a/Sources/CGFloat+Additions.swift +++ b/Sources/CGFloat+Additions.swift @@ -11,10 +11,10 @@ import SpriteKit extension CGFloat { static var degreesPerRadian: CGFloat { - return CGFloat(180.0 / M_PI) + return CGFloat(180.0 / .pi) } static var radiansPerDegree: CGFloat { - return CGFloat(M_PI / 180.0) + return CGFloat(.pi / 180.0) } } diff --git a/Sources/Double+Additions.swift b/Sources/Double+Additions.swift index 49d996f..467f0cc 100644 --- a/Sources/Double+Additions.swift +++ b/Sources/Double+Additions.swift @@ -8,7 +8,7 @@ extension Double { var compassValue: Double { - var value = self % 360 + var value = self.truncatingRemainder(dividingBy: 360) if value < 0 { value = 360 + value diff --git a/Sources/Horizon.swift b/Sources/Horizon.swift index 6aeb629..9337bcf 100644 --- a/Sources/Horizon.swift +++ b/Sources/Horizon.swift @@ -21,7 +21,7 @@ class Horizon: SKNode { self.sceneSize = sceneSize skyNode = SKSpriteNode(color: style.skyColor, size: CGSize(width: 100, height: 100)) groundNode = SKSpriteNode(color: style.groundColor, size: CGSize(width: 100, height: 100)) - zeroPitchLine = SKShapeNode(rectOfSize: CGSize(width: 2 * sceneSize.width, height: 1)) + zeroPitchLine = SKShapeNode(rectOf: CGSize(width: 2 * sceneSize.width, height: 1)) super.init() skyNode.size = CGSize(width: sceneSize.width * 2, height: sceneSize.height * 2) @@ -44,9 +44,9 @@ class Horizon: SKNode { extension Horizon: AttitudeSettable { - func setAttitude(attitude: AttitudeType) { - gimbalNode.runAction(attitude.pitchAction(sceneSize: sceneSize)) - runAction(attitude.rollAction()) + func setAttitude(_ attitude: AttitudeType) { + gimbalNode.run(attitude.pitchAction(sceneSize: sceneSize)) + run(attitude.rollAction()) } } diff --git a/Sources/PitchLadder.swift b/Sources/PitchLadder.swift index 445c61b..c886ea0 100644 --- a/Sources/PitchLadder.swift +++ b/Sources/PitchLadder.swift @@ -19,20 +19,20 @@ class PitchLadder: SKNode { let maskSize = CGSize( width: CGFloat(style.majorLineWidth) * 3.0, height: sceneSize.pointsPerDegree * (CGFloat(style.magnitudeDisplayDegree) + 4)) - self.maskNode = SKSpriteNode(color: SKColor.blackColor(), size: maskSize) + self.maskNode = SKSpriteNode(color: SKColor.black, size: maskSize) super.init() let builder = PitchLineBuilder(style: style) - let degreeValues = Array(5.stride(to: 91, by: 5)) + let degreeValues = Array(stride(from: 5, to: 91, by: 5)) let skyPitchLines = degreeValues.map { degree in - return (degree, (degree % 10 == 0) ? PitchLineType.Major : PitchLineType.Minor) + return (degree, (degree % 10 == 0) ? PitchLineType.major : PitchLineType.minor) } let pitchLines = skyPitchLines + skyPitchLines.map { ($0.0 * -1, $0.1) } for (degree, type) in pitchLines { cropNode.addChild(builder.pitchLine(sceneSize: sceneSize, degree: degree, type: type)) } - for (degree, type) in pitchLines.filter({ $1 == .Major }) { + for (degree, type) in pitchLines.filter({ $1 == .major }) { cropNode.addChild(builder.leftPitchLineLabel(sceneSize: sceneSize, degree: degree, type: type)) cropNode.addChild(builder.rightPitchLineLabel(sceneSize: sceneSize, degree: degree, type: type)) } @@ -48,35 +48,35 @@ class PitchLadder: SKNode { extension PitchLadder: AttitudeSettable { - func setAttitude(attitude: AttitudeType) { - cropNode.runAction(attitude.pitchAction(sceneSize: sceneSize)) - maskNode.runAction(attitude.pitchReverseAction(sceneSize: sceneSize)) - runAction(attitude.rollAction()) + func setAttitude(_ attitude: AttitudeType) { + cropNode.run(attitude.pitchAction(sceneSize: sceneSize)) + maskNode.run(attitude.pitchReverseAction(sceneSize: sceneSize)) + run(attitude.rollAction()) } } private enum PitchLineType { - case Major - case Minor + case major + case minor } private struct PitchLineBuilder { let style: PitchLadderStyleType - func pitchLine(sceneSize sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKShapeNode { + func pitchLine(sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKShapeNode { - let halfWidth = halfWidthForPitchLineType(type) - let path = CGPathCreateMutable() - CGPathMoveToPoint(path, nil, -halfWidth, 2) - CGPathAddLineToPoint(path, nil, halfWidth, 2) - CGPathAddLineToPoint(path, nil, halfWidth, -2) - CGPathAddLineToPoint(path, nil, -halfWidth, -2) - CGPathCloseSubpath(path) + let halfWidth = halfWidthForPitchLineType(type: type) + let path = CGMutablePath() + path.move(to: CGPoint(x: -halfWidth, y: 2)) + path.addLine(to: CGPoint(x: halfWidth, y: 2)) + path.addLine(to: CGPoint(x: halfWidth, y: -2)) + path.addLine(to: CGPoint(x: -halfWidth, y: -2)) + path.closeSubpath() - var transform = CGAffineTransformMakeTranslation(0, CGFloat(degree) * sceneSize.pointsPerDegree) - let transformedPath = withUnsafeMutablePointer(&transform) { - CGPathCreateMutableCopyByTransformingPath(path, $0) + var transform = CGAffineTransform(translationX: 0, y: CGFloat(degree) * sceneSize.pointsPerDegree) + let transformedPath = withUnsafeMutablePointer(to: &transform) { + path.mutableCopy(using: $0) } let line = SKShapeNode(path: transformedPath!) @@ -85,38 +85,38 @@ private struct PitchLineBuilder { return line } - func leftPitchLineLabel(sceneSize sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKLabelNode { + func leftPitchLineLabel(sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKLabelNode { let label = pitchLineLabel(sceneSize: sceneSize, degree: degree, type: type) - label.horizontalAlignmentMode = .Right - label.position.x = -halfWidthForPitchLineType(type) - CGFloat(style.markerTextOffset) + label.horizontalAlignmentMode = .right + label.position.x = -halfWidthForPitchLineType(type: type) - CGFloat(style.markerTextOffset) return label } - func rightPitchLineLabel(sceneSize sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKLabelNode { + func rightPitchLineLabel(sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKLabelNode { let label = pitchLineLabel(sceneSize: sceneSize, degree: degree, type: type) - label.horizontalAlignmentMode = .Left - label.position.x = halfWidthForPitchLineType(type) + CGFloat(style.markerTextOffset) + label.horizontalAlignmentMode = .left + label.position.x = halfWidthForPitchLineType(type: type) + CGFloat(style.markerTextOffset) return label } - private func pitchLineLabel(sceneSize sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKLabelNode { + private func pitchLineLabel(sceneSize: CGSize, degree: Int, type: PitchLineType) -> SKLabelNode { let label = SKLabelNode(text: "\(degree)") label.fontName = style.font.family label.fontSize = style.font.size label.fontColor = style.textColor - label.verticalAlignmentMode = .Center + label.verticalAlignmentMode = .center label.position.y = CGFloat(degree) * sceneSize.pointsPerDegree return label } private func widthForPitchLineType(type: PitchLineType) -> CGFloat { switch type { - case .Major: return CGFloat(style.majorLineWidth) - case .Minor: return CGFloat(style.minorLineWidth) + case .major: return CGFloat(style.majorLineWidth) + case .minor: return CGFloat(style.minorLineWidth) } } private func halfWidthForPitchLineType(type: PitchLineType) -> CGFloat { - return widthForPitchLineType(type) / 2 + return widthForPitchLineType(type: type) / 2 } } diff --git a/Sources/PrimaryFlightDisplay.swift b/Sources/PrimaryFlightDisplay.swift index a231e52..d2c839f 100644 --- a/Sources/PrimaryFlightDisplay.swift +++ b/Sources/PrimaryFlightDisplay.swift @@ -20,9 +20,9 @@ public class PrimaryFlightDisplayView: SKView { commonInit(settings: DefaultSettings()) } - private func commonInit(settings settings: SettingsType) { + private func commonInit(settings: SettingsType) { let scene = PrimaryFlightDisplayScene(size: bounds.size, settings: settings) - scene.scaleMode = .AspectFill + scene.scaleMode = .aspectFill scene.anchorPoint = CGPoint(x: 0.5, y: 0.5) presentScene(scene) @@ -30,25 +30,25 @@ public class PrimaryFlightDisplayView: SKView { ignoresSiblingOrder = true } - public func setHeadingDegree(degree: Double) { + public func setHeadingDegree(_ degree: Double) { if let scene = scene as? PrimaryFlightDisplayScene { scene.setHeadingDegree(degree) } } - public func setAirSpeed(airSpeed: Double) { + public func setAirSpeed(_ airSpeed: Double) { if let scene = scene as? PrimaryFlightDisplayScene { scene.setAirSpeed(airSpeed) } } - public func setAltitude(altitude: Double) { + public func setAltitude(_ altitude: Double) { if let scene = scene as? PrimaryFlightDisplayScene { scene.setAltitude(altitude) } } - public func setAttitude(rollRadians rollRadians: Double, pitchRadians: Double) { + public func setAttitude(rollRadians: Double, pitchRadians: Double) { if let scene = scene as? PrimaryFlightDisplayScene { scene.setAttitude(Attitude(pitchRadians: pitchRadians, rollRadians: rollRadians)) } @@ -80,8 +80,8 @@ class PrimaryFlightDisplayScene: SKScene { fatalError("init(coder:) has not been implemented") } - override func didMoveToView(view: SKView) { - scaleMode = .ResizeFill + override func didMove(to view: SKView) { + scaleMode = .resizeFill addChild(horizon) addChild(pitchLadder) addChild(attitudeReferenceIndex) @@ -91,7 +91,7 @@ class PrimaryFlightDisplayScene: SKScene { addChild(headingIndicator) } - override func didChangeSize(oldSize: CGSize) { + override func didChangeSize(_ oldSize: CGSize) { altimeter.position = CGPoint(x: size.width/2 - altimeter.style.size.width/2, y: 0) airSpeedIndicator.position = CGPoint(x: -size.width/2 + airSpeedIndicator.style.size.width/2, y: 0) headingIndicator.position = CGPoint(x: 0, y: size.height/2 - headingIndicator.style.size.height/2) @@ -103,22 +103,22 @@ class PrimaryFlightDisplayScene: SKScene { headingIndicator.recycleCells() } - func setHeadingDegree(degree: Double) { + func setHeadingDegree(_ degree: Double) { headingIndicator.value = degree } - func setAltitude(altitude: Double) { + func setAltitude(_ altitude: Double) { altimeter.value = altitude } - func setAirSpeed(airSpeed: Double) { + func setAirSpeed(_ airSpeed: Double) { airSpeedIndicator.value = airSpeed } } extension PrimaryFlightDisplayScene: AttitudeSettable { - func setAttitude(attitude: AttitudeType) { + func setAttitude(_ attitude: AttitudeType) { horizon.setAttitude(attitude) pitchLadder.setAttitude(attitude) bankIndicator.setAttitude(attitude) diff --git a/Sources/Settings.swift b/Sources/Settings.swift index da10460..519cb60 100644 --- a/Sources/Settings.swift +++ b/Sources/Settings.swift @@ -85,8 +85,8 @@ public protocol AttitudeReferenceIndexStyleType { } public struct DefaultAttitudeReferenceIndexStyle: AttitudeReferenceIndexStyleType { - public var fillColor = SKColor.whiteColor() - public var strokeColor = SKColor.blackColor() + public var fillColor = SKColor.white + public var strokeColor = SKColor.black public var centerBarWidth = 10 public var sideBarWidth = 120 public var sideBarHeight = 20 @@ -110,8 +110,8 @@ public protocol PitchLadderStyleType { public struct DefaultPitchLadderStyle: PitchLadderStyleType { public var fillColor = SKColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1) - public var strokeColor = SKColor.blackColor() - public var textColor = SKColor.whiteColor() + public var strokeColor = SKColor.black + public var textColor = SKColor.white public var font: FontType = DefaultFont() public var minorLineWidth = 20 public var majorLineWidth = 50 @@ -141,9 +141,9 @@ public protocol BankIndicatorStyleType { public struct DefaultBankIndicatorStyle: BankIndicatorStyleType { public var arcStrokeColor = SKColor(red: 0.8, green: 0.8, blue: 0.8, alpha: 1) - public var textColor = SKColor.whiteColor() + public var textColor = SKColor.white public var font: FontType = DefaultFont() - public var skyPointerFillColor = SKColor.whiteColor() + public var skyPointerFillColor = SKColor.white public var arcRadius = 180 public var arcMaximumDisplayDegree = 60 @@ -160,15 +160,15 @@ public struct DefaultBankIndicatorStyle: BankIndicatorStyleType { // MARK: TapeIndicator public enum TapeType { - case Compass - case Continuous + case compass + case continuous } public enum TapeMarkerJustification { - case Top - case Bottom - case Left - case Right + case top + case bottom + case left + case right } public typealias Legend = (key: String, value: String) @@ -194,20 +194,20 @@ public protocol TapeIndicatorStyleType { public struct DefaultAltimeterStyle: TapeIndicatorStyleType { public var size = CGSize(width: 60, height: 300) - public var type = TapeType.Continuous + public var type = TapeType.continuous public var backgroundColor = SKColor(red: 0, green: 0, blue: 0, alpha: 0.5) - public var pointerBackgroundColor = SKColor.blackColor() + public var pointerBackgroundColor = SKColor.black public var font: FontType = DefaultFont() - public var markerJustification = TapeMarkerJustification.Left + public var markerJustification = TapeMarkerJustification.left public var pointsPerUnitValue: UInt = 15 public var majorMarkerLength = 10 public var minorMarkerLength = 5 public var majorMarkerFrequency = 5 public var minorMarkerFrequency = 1 public var markerTextOffset = 20 - public var markerColor = SKColor.whiteColor() - public var markerTextColor = SKColor.whiteColor() + public var markerColor = SKColor.white + public var markerTextColor = SKColor.white public var legend: Legend? = (key: "ALT MSL", value: "METRES") public init() {} @@ -215,20 +215,20 @@ public struct DefaultAltimeterStyle: TapeIndicatorStyleType { public struct DefaultAirspeedIndicatorStyle: TapeIndicatorStyleType { public var size = CGSize(width: 60, height: 300) - public var type = TapeType.Continuous + public var type = TapeType.continuous public var backgroundColor = SKColor(red: 0, green: 0, blue: 0, alpha: 0.5) - public var pointerBackgroundColor = SKColor.blackColor() + public var pointerBackgroundColor = SKColor.black public var font: FontType = DefaultFont() - public var markerJustification = TapeMarkerJustification.Right + public var markerJustification = TapeMarkerJustification.right public var pointsPerUnitValue: UInt = 5 public var majorMarkerLength = 10 public var minorMarkerLength = 5 public var majorMarkerFrequency = 10 public var minorMarkerFrequency = 5 public var markerTextOffset = 20 - public var markerColor = SKColor.whiteColor() - public var markerTextColor = SKColor.whiteColor() + public var markerColor = SKColor.white + public var markerTextColor = SKColor.white public var legend: Legend? = (key: "AIR SPD", value: "MTR/SEC") public init() {} @@ -236,20 +236,20 @@ public struct DefaultAirspeedIndicatorStyle: TapeIndicatorStyleType { public struct DefaultHeadingIndicatorStyle: TapeIndicatorStyleType { public var size = CGSize(width: 400, height: 60) - public var type = TapeType.Compass + public var type = TapeType.compass public var backgroundColor = SKColor(red: 0, green: 0, blue: 0, alpha: 0.5) - public var pointerBackgroundColor = SKColor.blackColor() + public var pointerBackgroundColor = SKColor.black public var font: FontType = DefaultFont() - public var markerJustification = TapeMarkerJustification.Bottom + public var markerJustification = TapeMarkerJustification.bottom public var pointsPerUnitValue: UInt = 5 public var majorMarkerLength = 10 public var minorMarkerLength = 5 public var majorMarkerFrequency = 10 public var minorMarkerFrequency = 5 public var markerTextOffset = 22 - public var markerColor = SKColor.whiteColor() - public var markerTextColor = SKColor.whiteColor() + public var markerColor = SKColor.white + public var markerTextColor = SKColor.white public var legend: Legend? = nil public init() {} @@ -259,9 +259,9 @@ extension TapeIndicatorStyleType { public func labelForValue(value: Int) -> String { switch type { - case .Continuous: + case .continuous: return "\(value)" - case .Compass: + case .compass: let compassValue = Int(value.compassValue) let cardinalDirections = [0: "N", 45: "NE", 90: "E", 135: "SE", 180: "S", 225: "SW", 270: "W", 315: "NW"] @@ -275,23 +275,23 @@ extension TapeIndicatorStyleType { public var seedModel: TapeCellModelType { switch type { - case .Continuous: + case .continuous: return ContinuousTapeCellModel(lowerValue: 0, upperValue: optimalCellMagnitude) - case .Compass: + case .compass: return CompassTapeCellModel(lowerValue: 0, upperValue: optimalCellMagnitude) } } public var optimalCellMagnitude: Int { switch type { - case .Continuous: + case .continuous: switch markerJustification { - case .Bottom, .Top: + case .bottom, .top: return Int(round(size.width / CGFloat(pointsPerUnitValue))) - case .Left, .Right: + case .left, .right: return Int(round(size.height / CGFloat(pointsPerUnitValue))) } - case .Compass: + case .compass: return 120 } } diff --git a/Sources/TapeCell.swift b/Sources/TapeCell.swift index d71951d..d6d84c8 100644 --- a/Sources/TapeCell.swift +++ b/Sources/TapeCell.swift @@ -18,7 +18,7 @@ class TapeCell: SKNode { } var positionForZeroValue: CGPoint { - return positionForValue(0) + return positionForValue(value: 0) } private let style: TapeIndicatorStyleType @@ -37,44 +37,44 @@ class TapeCell: SKNode { private func positionForValue(value: Double) -> CGPoint { let valuePosition = (model.midValue - value) * Double(style.pointsPerUnitValue) switch style.markerJustification { - case .Top, .Bottom: + case .top, .bottom: return CGPoint(x: CGFloat(valuePosition), y: position.y) - case .Left, .Right: + case .left, .right: return CGPoint(x: position.x, y: CGFloat(valuePosition)) } } private func createMarkerNodes() { Array(model.lowerValue.. SKShapeNode { - let line = SKShapeNode(rectOfSize: marker.lineSize) + let line = SKShapeNode(rectOf: marker.lineSize) line.strokeColor = style.markerColor line.fillColor = style.markerColor switch style.markerJustification { - case .Top: + case .top: line.position = CGPoint( x: CGFloat(((marker.value - model.lowerValue) * Int(style.pointsPerUnitValue))) - (CGFloat(model.magnitude) * CGFloat(style.pointsPerUnitValue))/2, y: (style.size.height - CGFloat(marker.lineSize.height))/2) - case .Bottom: + case .bottom: line.position = CGPoint( x: CGFloat(((marker.value - model.lowerValue) * Int(style.pointsPerUnitValue))) - (CGFloat(model.magnitude) * CGFloat(style.pointsPerUnitValue))/2, y: (CGFloat(marker.lineSize.height) - style.size.height)/2) - case .Left: + case .left: line.position = CGPoint( x: (CGFloat(marker.lineSize.width) - style.size.width)/2, y: CGFloat(((marker.value - model.lowerValue) * Int(style.pointsPerUnitValue))) - (CGFloat(model.magnitude) * CGFloat(style.pointsPerUnitValue))/2) - case .Right: + case .right: line.position = CGPoint( x: (style.size.width - CGFloat(marker.lineSize.width))/2, y: CGFloat(((marker.value - model.lowerValue) * Int(style.pointsPerUnitValue))) - (CGFloat(model.magnitude) * CGFloat(style.pointsPerUnitValue))/2) @@ -84,7 +84,7 @@ class TapeCell: SKNode { } private func buildLabelNode(marker: CellMarker) -> SKLabelNode { - let label = SKLabelNode(text: style.labelForValue(marker.value)) + let label = SKLabelNode(text: style.labelForValue(value: marker.value)) label.fontName = style.font.family label.fontSize = style.font.size label.horizontalAlignmentMode = marker.labelAlignment.horizontal @@ -92,19 +92,19 @@ class TapeCell: SKNode { label.color = style.markerTextColor switch style.markerJustification { - case .Top: + case .top: label.position = CGPoint( x: CGFloat(((marker.value - model.lowerValue) * Int(style.pointsPerUnitValue))) - (CGFloat(model.magnitude) * CGFloat(style.pointsPerUnitValue))/2, y: style.size.height/2 - CGFloat(style.markerTextOffset)) - case .Bottom: + case .bottom: label.position = CGPoint( x: CGFloat(((marker.value - model.lowerValue) * Int(style.pointsPerUnitValue))) - (CGFloat(model.magnitude) * CGFloat(style.pointsPerUnitValue))/2, y: CGFloat(style.markerTextOffset) - style.size.height/2) - case .Left: + case .left: label.position = CGPoint( x: CGFloat(style.markerTextOffset) - style.size.width/2, y: CGFloat(((marker.value - model.lowerValue) * Int(style.pointsPerUnitValue))) - (CGFloat(model.magnitude) * CGFloat(style.pointsPerUnitValue))/2) - case .Right: + case .right: label.position = CGPoint( x: style.size.width/2 - CGFloat(style.markerTextOffset), y: CGFloat(((marker.value - model.lowerValue) * Int(style.pointsPerUnitValue))) - (CGFloat(model.magnitude) * CGFloat(style.pointsPerUnitValue))/2) @@ -131,15 +131,15 @@ private struct CellMarker { let length = isMajor ? style.majorMarkerLength : style.minorMarkerLength switch style.markerJustification { - case .Top, .Bottom: lineSize = CGSize(width: 0, height: length) - case .Left, .Right: lineSize = CGSize(width: length, height: 0) + case .top, .bottom: lineSize = CGSize(width: 0, height: length) + case .left, .right: lineSize = CGSize(width: length, height: 0) } switch style.markerJustification { - case .Top: labelAlignment = (horizontal: .Center, vertical: .Top) - case .Bottom: labelAlignment = (horizontal: .Center, vertical: .Bottom) - case .Left: labelAlignment = (horizontal: .Left, vertical: .Center) - case .Right: labelAlignment = (horizontal: .Right, vertical: .Center) + case .top: labelAlignment = (horizontal: .center, vertical: .top) + case .bottom: labelAlignment = (horizontal: .center, vertical: .bottom) + case .left: labelAlignment = (horizontal: .left, vertical: .center) + case .right: labelAlignment = (horizontal: .right, vertical: .center) } } } diff --git a/Sources/TapeCellContainer.swift b/Sources/TapeCellContainer.swift index 4fd2b52..1ad5a9f 100644 --- a/Sources/TapeCellContainer.swift +++ b/Sources/TapeCellContainer.swift @@ -13,8 +13,8 @@ class TapeCellContainer: SKNode { private let cellTriad: TapeCellTriad private let style: TapeIndicatorStyleType - enum Error: ErrorType { - case SeedModelLowerValueMustBeZero + enum Error: Swift.Error { + case seedModelLowerValueMustBeZero } init(seedModel: TapeCellModelType, style: TapeIndicatorStyleType) throws { @@ -26,7 +26,7 @@ class TapeCellContainer: SKNode { super.init() guard seedModel.lowerValue == 0 else { - throw Error.SeedModelLowerValueMustBeZero + throw Error.seedModelLowerValueMustBeZero } cellTriad.forEach { cell in @@ -41,28 +41,30 @@ class TapeCellContainer: SKNode { func actionForValue(value: Double) -> SKAction { switch style.type { - case .Continuous: - return SKAction.moveTo(positionForContinuousValue(value), duration: 0.05) - case .Compass: - return SKAction.moveTo(positionForCompassValue(value), duration: 0.2) + case .continuous: + return SKAction.move(to: positionForContinuousValue(value: value), duration: 0.05) + case .compass: + return SKAction.move(to: positionForCompassValue(compassValue: value), duration: 0.2) } } func recycleCells() { - let status = cellTriad.statusForValue(valueForPosition()) + guard let status = try? cellTriad.statusForValue(value: valueForPosition()) else { + return + } switch status { case ((true, let cell1), (false, _), (false, let cell3)): - recycleCell(cell3, model: cell1.model.previous()) + recycleCell(cell: cell3, model: cell1.model.previous()) break case ((false, let cell1), (false, _), (true, let cell3)): - recycleCell(cell1, model: cell3.model.next()) + recycleCell(cell: cell1, model: cell3.model.next()) break case ((false, let cell1), (false, let cell2), (false, let cell3)): - let model = modelForValue(valueForPosition(), fromModel: cell2.model) - recycleCell(cell1, model: model.previous()) - recycleCell(cell2, model: model) - recycleCell(cell3, model: model.next()) + let model = modelForValue(value: valueForPosition(), fromModel: cell2.model) + recycleCell(cell: cell1, model: model.previous()) + recycleCell(cell: cell2, model: model) + recycleCell(cell: cell3, model: model.next()) break default: break @@ -71,9 +73,9 @@ class TapeCellContainer: SKNode { private func valueForPosition() -> Double { switch style.type { - case .Continuous: + case .continuous: return continuousValueForPosition() - case .Compass: + case .compass: return continuousValueForPosition().compassValue } } @@ -82,31 +84,31 @@ class TapeCellContainer: SKNode { // TODO: Account for initial value let valuePosition = -value * Double(style.pointsPerUnitValue) switch style.markerJustification { - case .Top, .Bottom: + case .top, .bottom: return CGPoint(x: CGFloat(valuePosition), y: position.y) - case .Left, .Right: + case .left, .right: return CGPoint(x: position.x, y: CGFloat(valuePosition)) } } private func positionForCompassValue(compassValue: Double) -> CGPoint { - let left = leftwardValueDeltaFromCompassValue(continuousValueForPosition().compassValue, toCompassValue: compassValue) - let right = rightwardValueDeltaFromCompassValue(continuousValueForPosition().compassValue, toCompassValue: compassValue) + let left = leftwardValueDeltaFromCompassValue(fromCompassValue: continuousValueForPosition().compassValue, toCompassValue: compassValue) + let right = rightwardValueDeltaFromCompassValue(fromCompassValue: continuousValueForPosition().compassValue, toCompassValue: compassValue) if abs(left) < abs(right) { let newContinuousValue = continuousValueForPosition() + left - return positionForContinuousValue(newContinuousValue) + return positionForContinuousValue(value: newContinuousValue) } else { let newContinuousValue = continuousValueForPosition() + right - return positionForContinuousValue(newContinuousValue) + return positionForContinuousValue(value: newContinuousValue) } } private func continuousValueForPosition() -> Double { switch style.markerJustification { - case .Top, .Bottom: + case .top, .bottom: return -Double(position.x) / Double(style.pointsPerUnitValue) - case .Left, .Right: + case .left, .right: return -Double(position.y) / Double(style.pointsPerUnitValue) } } @@ -130,12 +132,12 @@ class TapeCellContainer: SKNode { } private func modelForValue(value: Double, fromModel model: TapeCellModelType) -> TapeCellModelType { - if model.containsValue(value) { + if model.containsValue(value: value) { return model } else if value < model.midValue { - return modelForValue(value, fromModel: model.previous()) + return modelForValue(value: value, fromModel: model.previous()) } else { - return modelForValue(value, fromModel: model.next()) + return modelForValue(value: value, fromModel: model.next()) } } diff --git a/Sources/TapeCellTriad.swift b/Sources/TapeCellTriad.swift index 3bb29f4..2c226ed 100644 --- a/Sources/TapeCellTriad.swift +++ b/Sources/TapeCellTriad.swift @@ -17,26 +17,16 @@ class TapeCellTriad { cells = [cell1, cell2, cell3] } - func statusForValue(value: Double) -> (TapeCellStatus, TapeCellStatus, TapeCellStatus) { - - let statusCells = cells - .sort { $0.0.model.midValue < $0.1.model.midValue } - .map { ($0.model.containsValue(value), $0) } + func statusForValue(value: Double) throws -> (TapeCellStatus, TapeCellStatus, TapeCellStatus) { + let statusCells = try cells + .sorted { (a, b) throws in a.model.midValue < b.model.midValue } + .map { ($0.model.containsValue(value: value), $0) } return (statusCells[0], statusCells[1], statusCells[2]) } } -extension TapeCellTriad: SequenceType { - - func generate() -> AnyGenerator { - var nextIndex = 0 - - return AnyGenerator { - guard nextIndex < self.cells.count else { return nil } - - let cell = self.cells[nextIndex] - nextIndex += 1 - return cell - } +extension TapeCellTriad : Sequence { + func makeIterator() -> Array.Iterator { + return cells.makeIterator() } } diff --git a/Sources/TapeIndicator.swift b/Sources/TapeIndicator.swift index 2feee62..3159518 100644 --- a/Sources/TapeIndicator.swift +++ b/Sources/TapeIndicator.swift @@ -18,19 +18,19 @@ class TapeIndicator: SKNode { var value: Double = 0 { didSet { - cellContainer.runAction(cellContainer.actionForValue(value)) + cellContainer.run(cellContainer.actionForValue(value: value)) pointer.value = Int(value) } } init(style: TapeIndicatorStyleType) { switch style.markerJustification { - case .Bottom, .Top: - if style.type == .Compass && (style.size.width / CGFloat(style.pointsPerUnitValue) > CGFloat(style.optimalCellMagnitude)) { + case .bottom, .top: + if style.type == .compass && (style.size.width / CGFloat(style.pointsPerUnitValue) > CGFloat(style.optimalCellMagnitude)) { fatalError("Invalid Compass style: Decrease width and / or increase pointsPerUnitValue") } - case .Left, .Right: - if style.type == .Compass && (style.size.height / CGFloat(style.pointsPerUnitValue) > CGFloat(style.optimalCellMagnitude)) { + case .left, .right: + if style.type == .compass && (style.size.height / CGFloat(style.pointsPerUnitValue) > CGFloat(style.optimalCellMagnitude)) { fatalError("Invalid Compass style: Decrease height and / or increase pointsPerUnitValue") } } @@ -45,9 +45,9 @@ class TapeIndicator: SKNode { pointer = TapePointer(initialValue: style.seedModel.lowerValue, style: style) super.init() - let backgroundShape = SKShapeNode(rectOfSize: style.size, cornerRadius: 2) + let backgroundShape = SKShapeNode(rectOf: style.size, cornerRadius: 2) backgroundShape.fillColor = style.backgroundColor - backgroundShape.strokeColor = SKColor.clearColor() + backgroundShape.strokeColor = SKColor.clear backgroundShape.zPosition = 0 cellContainer.zPosition = 1 @@ -56,7 +56,7 @@ class TapeIndicator: SKNode { cropNode.addChild(backgroundShape) cropNode.addChild(cellContainer) cropNode.addChild(pointer) - cropNode.maskNode = SKSpriteNode(color: SKColor.blackColor(), size: style.size) + cropNode.maskNode = SKSpriteNode(color: SKColor.black, size: style.size) addChild(cropNode) } diff --git a/Sources/TapePointer.swift b/Sources/TapePointer.swift index 4806105..a9a0d36 100644 --- a/Sources/TapePointer.swift +++ b/Sources/TapePointer.swift @@ -18,14 +18,14 @@ class TapePointer: SKNode { var value: Int { didSet { - valueLabel.text = style.labelForValue(value) + valueLabel.text = style.labelForValue(value: value) } } init(initialValue: Int, style: TapeIndicatorStyleType) { self.value = initialValue self.style = style - valueLabel = SKLabelNode(text: style.labelForValue(value)) + valueLabel = SKLabelNode(text: style.labelForValue(value: value)) if let legend = style.legend { legendKeyLabelNode = SKLabelNode(text: legend.key) legendValueLabelNode = SKLabelNode(text: legend.value) @@ -58,54 +58,54 @@ class TapePointer: SKNode { legendKeyLabelNode?.fontName = style.font.family legendKeyLabelNode?.fontSize = round(style.font.size * CGFloat(0.5)) - legendKeyLabelNode?.fontColor = style.markerTextColor.colorWithAlphaComponent(0.7) + legendKeyLabelNode?.fontColor = style.markerTextColor.withAlphaComponent(0.7) legendValueLabelNode?.fontName = style.font.family legendValueLabelNode?.fontSize = round(style.font.size * CGFloat(0.5)) - legendValueLabelNode?.fontColor = style.markerTextColor.colorWithAlphaComponent(0.7) + legendValueLabelNode?.fontColor = style.markerTextColor.withAlphaComponent(0.7) switch style.markerJustification { - case .Top: - valueLabel.horizontalAlignmentMode = .Center - valueLabel.verticalAlignmentMode = .Top + case .top: + valueLabel.horizontalAlignmentMode = .center + valueLabel.verticalAlignmentMode = .top valueLabel.position = CGPoint(x: 0, y: style.size.height/2 - CGFloat(style.markerTextOffset)) - case .Bottom: - valueLabel.horizontalAlignmentMode = .Center - valueLabel.verticalAlignmentMode = .Bottom + case .bottom: + valueLabel.horizontalAlignmentMode = .center + valueLabel.verticalAlignmentMode = .bottom valueLabel.position = CGPoint(x: 0, y: CGFloat(style.markerTextOffset) - style.size.height/2) - case .Left: - valueLabel.horizontalAlignmentMode = .Left - valueLabel.verticalAlignmentMode = .Center + case .left: + valueLabel.horizontalAlignmentMode = .left + valueLabel.verticalAlignmentMode = .center valueLabel.position = CGPoint( x: CGFloat(style.markerTextOffset) - style.size.width/2, y: 0) - legendKeyLabelNode?.horizontalAlignmentMode = .Left - legendKeyLabelNode?.verticalAlignmentMode = .Top + legendKeyLabelNode?.horizontalAlignmentMode = .left + legendKeyLabelNode?.verticalAlignmentMode = .top legendKeyLabelNode?.position = CGPoint( x: CGFloat(style.markerTextOffset) - style.size.width/2, y: backgroundShapeDimensions().thirdWidth) - legendValueLabelNode?.horizontalAlignmentMode = .Left - legendValueLabelNode?.verticalAlignmentMode = .Bottom + legendValueLabelNode?.horizontalAlignmentMode = .left + legendValueLabelNode?.verticalAlignmentMode = .bottom legendValueLabelNode?.position = CGPoint( x: CGFloat(style.markerTextOffset) - style.size.width/2, y: -backgroundShapeDimensions().thirdWidth) - case .Right: - valueLabel.horizontalAlignmentMode = .Right - valueLabel.verticalAlignmentMode = .Center + case .right: + valueLabel.horizontalAlignmentMode = .right + valueLabel.verticalAlignmentMode = .center valueLabel.position = CGPoint( x: style.size.width/2 - CGFloat(style.markerTextOffset), y: 0) - legendKeyLabelNode?.horizontalAlignmentMode = .Right - legendKeyLabelNode?.verticalAlignmentMode = .Top + legendKeyLabelNode?.horizontalAlignmentMode = .right + legendKeyLabelNode?.verticalAlignmentMode = .top legendKeyLabelNode?.position = CGPoint( x: style.size.width/2 - CGFloat(style.markerTextOffset), y: backgroundShapeDimensions().thirdWidth) - legendValueLabelNode?.horizontalAlignmentMode = .Right - legendValueLabelNode?.verticalAlignmentMode = .Bottom + legendValueLabelNode?.horizontalAlignmentMode = .right + legendValueLabelNode?.verticalAlignmentMode = .bottom legendValueLabelNode?.position = CGPoint( x: style.size.width/2 - CGFloat(style.markerTextOffset), y: -backgroundShapeDimensions().thirdWidth) @@ -114,39 +114,39 @@ class TapePointer: SKNode { private func buildBackgroundShape() -> SKShapeNode { let dimensions = backgroundShapeDimensions() - let path = CGPathCreateMutable() - CGPathMoveToPoint(path, nil, 0, 0) - CGPathAddLineToPoint(path, nil, dimensions.thirdWidth, dimensions.thirdWidth) - CGPathAddLineToPoint(path, nil, dimensions.width, dimensions.thirdWidth) - CGPathAddLineToPoint(path, nil, dimensions.width, -dimensions.thirdWidth) - CGPathAddLineToPoint(path, nil, dimensions.thirdWidth, -dimensions.thirdWidth) - CGPathCloseSubpath(path) + let path = CGMutablePath() + path.move(to: .zero) + path.addLine(to: CGPoint(x: dimensions.thirdWidth, y: dimensions.thirdWidth)) + path.addLine(to: CGPoint(x: dimensions.width, y: dimensions.thirdWidth)) + path.addLine(to: CGPoint(x: dimensions.width, y: -dimensions.thirdWidth)) + path.addLine(to: CGPoint(x: dimensions.thirdWidth, y: -dimensions.thirdWidth)) + path.closeSubpath() let translateTransform, rotateTransform: CGAffineTransform switch style.markerJustification { - case .Top: - translateTransform = CGAffineTransformMakeTranslation(-dimensions.halfWidth, 0) - rotateTransform = CGAffineTransformMakeRotation(CGFloat(-M_PI_2)) - case .Bottom: - translateTransform = CGAffineTransformMakeTranslation(-dimensions.halfWidth, 0) - rotateTransform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) - case .Left: - translateTransform = CGAffineTransformMakeTranslation(-dimensions.halfWidth, 0) - rotateTransform = CGAffineTransformIdentity - case .Right: - translateTransform = CGAffineTransformMakeTranslation(-dimensions.halfWidth, 0) - rotateTransform = CGAffineTransformMakeRotation(CGFloat(M_PI)) + case .top: + translateTransform = CGAffineTransform(translationX: -dimensions.halfWidth, y: 0) + rotateTransform = CGAffineTransform(rotationAngle: CGFloat.pi / -2) + case .bottom: + translateTransform = CGAffineTransform(translationX: -dimensions.halfWidth, y: 0) + rotateTransform = CGAffineTransform(rotationAngle: CGFloat.pi / -2) + case .left: + translateTransform = CGAffineTransform(translationX: -dimensions.halfWidth, y: 0) + rotateTransform = CGAffineTransform.identity + case .right: + translateTransform = CGAffineTransform(translationX: -dimensions.halfWidth, y: 0) + rotateTransform = CGAffineTransform(rotationAngle: CGFloat.pi) } - var transform = CGAffineTransformConcat(translateTransform, rotateTransform) - let transformedPath = withUnsafeMutablePointer(&transform) { - CGPathCreateMutableCopyByTransformingPath(path, $0) + var transform = translateTransform.concatenating(rotateTransform) + let transformedPath = withUnsafeMutablePointer(to: &transform) { + path.mutableCopy(using: $0) } let shape = SKShapeNode(path: transformedPath!) shape.fillColor = style.pointerBackgroundColor - shape.strokeColor = SKColor.whiteColor() + shape.strokeColor = SKColor.white return shape } @@ -154,11 +154,11 @@ class TapePointer: SKNode { let width, halfWidth, thirdWidth: CGFloat switch style.markerJustification { - case .Top, .Bottom: + case .top, .bottom: width = CGFloat(style.size.height) halfWidth = width / 2 thirdWidth = width / 3 - case .Left, .Right: + case .left, .right: width = style.size.width halfWidth = width / 2 thirdWidth = width / 3 diff --git a/Vendor/xcconfigs b/Vendor/xcconfigs deleted file mode 160000 index d78854b..0000000 --- a/Vendor/xcconfigs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d78854b22b9567e7f30d748bdd4966c86bcc93a5