diff --git a/.swiftlint.yml b/.swiftlint.yml new file mode 100644 index 0000000..c4bc412 --- /dev/null +++ b/.swiftlint.yml @@ -0,0 +1,28 @@ +disabled_rules: # rule identifiers to exclude from running +- force_cast +- trailing_whitespace +- control_statement +- type_name +- variable_name +- force_try +# Find all the available rules by running: +# swiftlint rules + +included: # paths to include during linting. `--path` is ignored if present. + + +excluded: # paths to ignore during linting. Takes precedence over `included`. + +# parameterized rules can be customized from this configuration file +line_length: 256 + +function_parameter_count: +- 30 +- 40 + +# parameterized rules are first parameterized as a warning level, then error level. +type_body_length: +- 500 # warning +- 1000 # error + +#reporter: "csv" # reporter type (xcode, json, csv, checkstyle) diff --git a/.travis.yml b/.travis.yml index ae647ae..935c277 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: objective-c -osx_image: xcode7.3 +osx_image: xcode8 script: fastlane test diff --git a/CHANGELOG.md b/CHANGELOG.md index decd5e0..214f59b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,13 +1,22 @@ # Change Log #### 1.x Releases - +- `1.x.x` Releases - [1.4.0](#140) - `1.3.x` Releases - [1.3.0](#130) - `1.2.x` Releases - [1.2.0](#120) - `1.1.x` Releases - [1.1.0](#110) - `1.0.x` Releases - [1.0.0](#100) --- +## [1.4.0](https://github.com/mtynior/Felucia/releases/tag/1.4.0) +Released on 2016-11-01. + +#### Added +- Support for Swift Package Manager + +#### Updated +- Source code to Swift 3.0 +- Project to Xcode 8 ## [1.3.0](https://github.com/mtynior/Felucia/releases/tag/1.3.0) Released on 2016-06-29. diff --git a/Felucia.xcodeproj/project.pbxproj b/Felucia.xcodeproj/project.pbxproj index 2c38754..f0d108c 100644 --- a/Felucia.xcodeproj/project.pbxproj +++ b/Felucia.xcodeproj/project.pbxproj @@ -7,20 +7,20 @@ objects = { /* Begin PBXBuildFile section */ - 900EE6CB1CAFF015004AF16A /* Felucia.h in Headers */ = {isa = PBXBuildFile; fileRef = 9061C9271BD5602900A191B7 /* Felucia.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 900EE6DD1CAFF134004AF16A /* Felucia.h in Headers */ = {isa = PBXBuildFile; fileRef = 9061C9271BD5602900A191B7 /* Felucia.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 900EE6E01CAFF239004AF16A /* Felucia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9061C93E1BD5604C00A191B7 /* Felucia.swift */; }; - 900EE6E11CAFF23E004AF16A /* Felucia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9061C93E1BD5604C00A191B7 /* Felucia.swift */; }; 900FFDBB1C0E1B6200B0A2B5 /* Helpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 900FFDBA1C0E1B6200B0A2B5 /* Helpers.swift */; }; 900FFDBD1C135BCE00B0A2B5 /* FeluciaTestsHSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = 900FFDBC1C135BCE00B0A2B5 /* FeluciaTestsHSL.swift */; }; - 9061C9281BD5602900A191B7 /* Felucia.h in Headers */ = {isa = PBXBuildFile; fileRef = 9061C9271BD5602900A191B7 /* Felucia.h */; settings = {ATTRIBUTES = (Public, ); }; }; 9061C92F1BD5602900A191B7 /* Felucia.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9061C9241BD5602900A191B7 /* Felucia.framework */; }; 9061C9341BD5602900A191B7 /* FeluciaTestsRGBAInteger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9061C9331BD5602900A191B7 /* FeluciaTestsRGBAInteger.swift */; }; - 9061C93F1BD5604C00A191B7 /* Felucia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9061C93E1BD5604C00A191B7 /* Felucia.swift */; }; 90651C471BDEB18D00835B06 /* FeluciaTestsCMYK.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90651C461BDEB18D00835B06 /* FeluciaTestsCMYK.swift */; }; 90651C491BDEB85B00835B06 /* FeluciaTestsUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90651C481BDEB85B00835B06 /* FeluciaTestsUtils.swift */; }; 907063921BD6D81000C0B134 /* FeluciaTestsRGBAFloat.swift in Sources */ = {isa = PBXBuildFile; fileRef = 907063911BD6D81000C0B134 /* FeluciaTestsRGBAFloat.swift */; }; 90A1781A1C0BB4F30096F9BE /* FeluciaTestsHexColor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90A178191C0BB4F30096F9BE /* FeluciaTestsHexColor.swift */; }; + 90F8147D1D23B22700583FA0 /* Felucia.h in Headers */ = {isa = PBXBuildFile; fileRef = 90F814781D23B22700583FA0 /* Felucia.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 90F814821D23B23700583FA0 /* Felucia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90F814791D23B22700583FA0 /* Felucia.swift */; }; + 90F814831D23B23B00583FA0 /* Felucia.h in Headers */ = {isa = PBXBuildFile; fileRef = 90F814781D23B22700583FA0 /* Felucia.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 90F814841D23B24200583FA0 /* Felucia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90F814791D23B22700583FA0 /* Felucia.swift */; }; + 90F814851D23B24700583FA0 /* Felucia.h in Headers */ = {isa = PBXBuildFile; fileRef = 90F814781D23B22700583FA0 /* Felucia.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 90F814881D23B30100583FA0 /* Felucia.swift in Sources */ = {isa = PBXBuildFile; fileRef = 90F814791D23B22700583FA0 /* Felucia.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -35,22 +35,26 @@ /* Begin PBXFileReference section */ 900EE6C31CAFEFF9004AF16A /* Felucia.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Felucia.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 900EE6CC1CAFF06E004AF16A /* Info-iOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = ""; }; - 900EE6CD1CAFF06E004AF16A /* Info-watchOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-watchOS.plist"; sourceTree = ""; }; 900EE6D51CAFF124004AF16A /* Felucia.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Felucia.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 900EE6DE1CAFF159004AF16A /* Info-tvOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-tvOS.plist"; sourceTree = ""; }; 900FFDBA1C0E1B6200B0A2B5 /* Helpers.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Helpers.swift; sourceTree = ""; }; 900FFDBC1C135BCE00B0A2B5 /* FeluciaTestsHSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeluciaTestsHSL.swift; sourceTree = ""; }; + 901927F91DCA1741000481D7 /* .swiftlint.yml */ = {isa = PBXFileReference; lastKnownFileType = text; path = .swiftlint.yml; sourceTree = ""; }; + 901927FE1DCA1A90000481D7 /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = CHANGELOG.md; sourceTree = ""; }; + 901927FF1DCA1A90000481D7 /* Felucia.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Felucia.podspec; sourceTree = ""; }; + 901928001DCA1A90000481D7 /* LICENSE.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = LICENSE.md; sourceTree = ""; }; + 901928011DCA1A90000481D7 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 9061C9241BD5602900A191B7 /* Felucia.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Felucia.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 9061C9271BD5602900A191B7 /* Felucia.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Felucia.h; sourceTree = ""; }; 9061C92E1BD5602900A191B7 /* FeluciaTests_iOS.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = FeluciaTests_iOS.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 9061C9331BD5602900A191B7 /* FeluciaTestsRGBAInteger.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FeluciaTestsRGBAInteger.swift; sourceTree = ""; }; 9061C9351BD5602900A191B7 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 9061C93E1BD5604C00A191B7 /* Felucia.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Felucia.swift; sourceTree = ""; }; 90651C461BDEB18D00835B06 /* FeluciaTestsCMYK.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeluciaTestsCMYK.swift; sourceTree = ""; }; 90651C481BDEB85B00835B06 /* FeluciaTestsUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeluciaTestsUtils.swift; sourceTree = ""; }; 907063911BD6D81000C0B134 /* FeluciaTestsRGBAFloat.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeluciaTestsRGBAFloat.swift; sourceTree = ""; }; 90A178191C0BB4F30096F9BE /* FeluciaTestsHexColor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeluciaTestsHexColor.swift; sourceTree = ""; }; + 90F814781D23B22700583FA0 /* Felucia.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Felucia.h; sourceTree = ""; }; + 90F814791D23B22700583FA0 /* Felucia.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Felucia.swift; sourceTree = ""; }; + 90F8147A1D23B22700583FA0 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 90F814861D23B2DD00583FA0 /* Package.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -89,7 +93,13 @@ 9061C91A1BD5602900A191B7 = { isa = PBXGroup; children = ( - 9061C9261BD5602900A191B7 /* Felucia */, + 901927FE1DCA1A90000481D7 /* CHANGELOG.md */, + 901927FF1DCA1A90000481D7 /* Felucia.podspec */, + 901928001DCA1A90000481D7 /* LICENSE.md */, + 901928011DCA1A90000481D7 /* README.md */, + 901927F91DCA1741000481D7 /* .swiftlint.yml */, + 90F814861D23B2DD00583FA0 /* Package.swift */, + 90F814771D23B22700583FA0 /* Source */, 9061C9321BD5602900A191B7 /* FeluciaTests */, 9061C9251BD5602900A191B7 /* Products */, ); @@ -106,18 +116,6 @@ name = Products; sourceTree = ""; }; - 9061C9261BD5602900A191B7 /* Felucia */ = { - isa = PBXGroup; - children = ( - 900EE6DE1CAFF159004AF16A /* Info-tvOS.plist */, - 900EE6CC1CAFF06E004AF16A /* Info-iOS.plist */, - 900EE6CD1CAFF06E004AF16A /* Info-watchOS.plist */, - 9061C9271BD5602900A191B7 /* Felucia.h */, - 9061C93E1BD5604C00A191B7 /* Felucia.swift */, - ); - path = Felucia; - sourceTree = ""; - }; 9061C9321BD5602900A191B7 /* FeluciaTests */ = { isa = PBXGroup; children = ( @@ -133,6 +131,16 @@ path = FeluciaTests; sourceTree = ""; }; + 90F814771D23B22700583FA0 /* Source */ = { + isa = PBXGroup; + children = ( + 90F814781D23B22700583FA0 /* Felucia.h */, + 90F814791D23B22700583FA0 /* Felucia.swift */, + 90F8147A1D23B22700583FA0 /* Info.plist */, + ); + path = Source; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -140,7 +148,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 900EE6CB1CAFF015004AF16A /* Felucia.h in Headers */, + 90F814831D23B23B00583FA0 /* Felucia.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -148,7 +156,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 900EE6DD1CAFF134004AF16A /* Felucia.h in Headers */, + 90F814851D23B24700583FA0 /* Felucia.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -156,7 +164,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - 9061C9281BD5602900A191B7 /* Felucia.h in Headers */, + 90F8147D1D23B22700583FA0 /* Felucia.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -171,6 +179,7 @@ 900EE6BF1CAFEFF9004AF16A /* Frameworks */, 900EE6C01CAFEFF9004AF16A /* Headers */, 900EE6C11CAFEFF9004AF16A /* Resources */, + 901927FC1DCA1794000481D7 /* ShellScript */, ); buildRules = ( ); @@ -189,6 +198,7 @@ 900EE6D11CAFF124004AF16A /* Frameworks */, 900EE6D21CAFF124004AF16A /* Headers */, 900EE6D31CAFF124004AF16A /* Resources */, + 901927FD1DCA17A1000481D7 /* ShellScript */, ); buildRules = ( ); @@ -207,6 +217,7 @@ 9061C9201BD5602900A191B7 /* Frameworks */, 9061C9211BD5602900A191B7 /* Headers */, 9061C9221BD5602900A191B7 /* Resources */, + 901927FB1DCA1780000481D7 /* ShellScript */, ); buildRules = ( ); @@ -241,12 +252,13 @@ 9061C91B1BD5602900A191B7 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0710; + LastUpgradeCheck = 0810; ORGANIZATIONNAME = "Michał Tynior"; TargetAttributes = { 900EE6C21CAFEFF9004AF16A = { CreatedOnToolsVersion = 7.3; DevelopmentTeam = SGZ6FVQB6B; + LastSwiftMigration = 0800; }; 900EE6D41CAFF124004AF16A = { CreatedOnToolsVersion = 7.3; @@ -254,10 +266,12 @@ }; 9061C9231BD5602900A191B7 = { CreatedOnToolsVersion = 7.1; + LastSwiftMigration = 0810; }; 9061C92D1BD5602900A191B7 = { CreatedOnToolsVersion = 7.1; DevelopmentTeam = SGZ6FVQB6B; + LastSwiftMigration = 0810; }; }; }; @@ -312,12 +326,54 @@ }; /* End PBXResourcesBuildPhase section */ +/* Begin PBXShellScriptBuildPhase section */ + 901927FB1DCA1780000481D7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + }; + 901927FC1DCA1794000481D7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + }; + 901927FD1DCA17A1000481D7 /* ShellScript */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint\"\nfi"; + }; +/* End PBXShellScriptBuildPhase section */ + /* Begin PBXSourcesBuildPhase section */ 900EE6BE1CAFEFF9004AF16A /* Sources */ = { isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 900EE6E01CAFF239004AF16A /* Felucia.swift in Sources */, + 90F814821D23B23700583FA0 /* Felucia.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -325,7 +381,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 900EE6E11CAFF23E004AF16A /* Felucia.swift in Sources */, + 90F814841D23B24200583FA0 /* Felucia.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -333,7 +389,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( - 9061C93F1BD5604C00A191B7 /* Felucia.swift in Sources */, + 90F814881D23B30100583FA0 /* Felucia.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -372,7 +428,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Felucia/Info-watchOS.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tynior.Felucia; @@ -394,13 +450,14 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "Felucia/Info-watchOS.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tynior.Felucia; PRODUCT_NAME = Felucia; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 2.0; }; @@ -415,7 +472,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Felucia/Info-tvOS.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tynior.Felucia; @@ -436,13 +493,14 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Felucia/Info-tvOS.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tynior.Felucia; PRODUCT_NAME = Felucia; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -461,8 +519,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -510,8 +570,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -548,7 +610,7 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Felucia/Info-iOS.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tynior.Felucia; @@ -567,12 +629,13 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Felucia/Info-iOS.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tynior.Felucia; PRODUCT_NAME = Felucia; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -593,6 +656,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.tynior.FeluciaTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; diff --git a/Felucia.xcodeproj/xcshareddata/xcschemes/Felucia-iOS.xcscheme b/Felucia.xcodeproj/xcshareddata/xcschemes/Felucia-iOS.xcscheme index 84438ca..d416b40 100644 --- a/Felucia.xcodeproj/xcshareddata/xcschemes/Felucia-iOS.xcscheme +++ b/Felucia.xcodeproj/xcshareddata/xcschemes/Felucia-iOS.xcscheme @@ -1,6 +1,6 @@ - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - NSPrincipalClass - - - diff --git a/Felucia/Info-watchOS.plist b/Felucia/Info-watchOS.plist deleted file mode 100644 index d3de8ee..0000000 --- a/Felucia/Info-watchOS.plist +++ /dev/null @@ -1,26 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - FMWK - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - $(CURRENT_PROJECT_VERSION) - NSPrincipalClass - - - diff --git a/FeluciaTests/FeluciaTestsCMYK.swift b/FeluciaTests/FeluciaTestsCMYK.swift index 6e6c0d0..f5a6f74 100644 --- a/FeluciaTests/FeluciaTestsCMYK.swift +++ b/FeluciaTests/FeluciaTestsCMYK.swift @@ -12,8 +12,8 @@ import XCTest class FeluciaTestsCMYK: XCTestCase { func test_ShouldCreateColorFromCMYK() { - let expectedTuple : (r: Float, g:Float, b:Float, a:Float) = (0.5, 0.25, 0.125, 1.0) - let accuracy:Float = 0.005 + let expectedTuple : (r: Float, g: Float, b: Float, a: Float) = (0.5, 0.25, 0.125, 1.0) + let accuracy: Float = 0.005 let color = UIColor(cyan: 0, magneta: 0.5, yellow: 0.75, black: 0.498) @@ -23,8 +23,8 @@ class FeluciaTestsCMYK: XCTestCase { } func test_ShouldReturnTupleWithCMYKCompoments() { - let expectedTuple : (c: Float, m:Float, y:Float, k:Float) = (0, 0.5, 0.75, 0.498) - let accuracy:Float = 0.001 + let expectedTuple : (c: Float, m: Float, y: Float, k: Float) = (0, 0.5, 0.75, 0.498) + let accuracy: Float = 0.001 let color = UIColor(cyan: 0, magneta: 0.5, yellow: 0.75, black: 0.498) @@ -34,8 +34,8 @@ class FeluciaTestsCMYK: XCTestCase { } func test_ShouldReturnTupleWithCMYKCompomentsFromRGBAColor() { - let expectedTuple : (c: Float, m:Float, y:Float, k:Float) = (0.711, 0.533, 0.0, 0.118) - let accuracy:Float = 0.001 + let expectedTuple : (c: Float, m: Float, y: Float, k: Float) = (0.711, 0.533, 0.0, 0.118) + let accuracy: Float = 0.001 let color = UIColor(r: 65, g: 105, b: 225, a: 255) @@ -45,8 +45,8 @@ class FeluciaTestsCMYK: XCTestCase { } func test_ShouldReturnArrayWithCMYKCompoments() { - let expectedArray:[Float] = [0, 0.5, 0.75, 0.498] - let accuracy:Float = 0.001 + let expectedArray: [Float] = [0, 0.5, 0.75, 0.498] + let accuracy: Float = 0.001 let color = UIColor(cyan: 0, magneta: 0.5, yellow: 0.75, black: 0.498) diff --git a/FeluciaTests/FeluciaTestsHSL.swift b/FeluciaTests/FeluciaTestsHSL.swift index a2e9eb2..f0658e7 100644 --- a/FeluciaTests/FeluciaTestsHSL.swift +++ b/FeluciaTests/FeluciaTestsHSL.swift @@ -14,8 +14,7 @@ import XCTest class FeluciaTestsHSL: XCTestCase { func test_ShouldCreateColorFromNormalizedHSLCompoents() { - - let expectedColor = UIColor(hexARGBString: "#64A089")! + let expectedColor = UIColor(hexARGB: "#64A089")! let actualColor = UIColor(h: 157.0/360.0, s: 0.24, l: 0.51) @@ -25,8 +24,7 @@ class FeluciaTestsHSL: XCTestCase { } func test_ShouldCreateColorFromHSLCompoents() { - - let expectedColor = UIColor(hexARGBString: "#64A089")! + let expectedColor = UIColor(hexARGB: "#64A089")! let actualColor = UIColor(h: 157.0, s: 24, l: 51) @@ -39,7 +37,7 @@ class FeluciaTestsHSL: XCTestCase { func test_ShouldReturnHSLComponents() { let expectedComponents: (Float, Float, Float, Float) = (157.0/360.0, 0.24, 0.51, 1.0) - let actualCompoents = UIColor(hexARGBString: "#64A089")!.hsla() + let actualCompoents = UIColor(hexARGB: "#64A089")!.hsla() AssertEqualWithAccuracy(actualCompoents, expectedComponents, 0.001, "Should return HSL components") } @@ -48,7 +46,7 @@ class FeluciaTestsHSL: XCTestCase { func test_ShouldReturnArrayOfHSLComponents() { let expectedComponents: [Float] = [157.0/360.0, 0.24, 0.51, 1.0] - let actualCompoents = UIColor(hexARGBString: "#64A089")!.hslaArray() + let actualCompoents = UIColor(hexARGB: "#64A089")!.hslaArray() AssertEqualWithAccuracy(actualCompoents, expectedComponents, 0.001, "Should return HSL components") } diff --git a/FeluciaTests/FeluciaTestsHexColor.swift b/FeluciaTests/FeluciaTestsHexColor.swift index 1d9a6a3..6acff0c 100644 --- a/FeluciaTests/FeluciaTestsHexColor.swift +++ b/FeluciaTests/FeluciaTestsHexColor.swift @@ -14,37 +14,37 @@ class FeluciaTestsHexColor: XCTestCase { func test_ShouldCreateColorFromHex3String() { let expectedColor = UIColor(r: 255, g: 187, b: 204, a: 255) - let actualColor = UIColor(hexARGBString: "#FBC") + let actualColor = UIColor(hexARGB: "#FBC") - XCTAssertEqual(actualColor, expectedColor, "Should create from hex3 ARGB String") + XCTAssertEqual(actualColor, expectedColor, "Should create from hex3 ARGB String") } func test_ShouldCreateColorFromHex6String() { let expectedColor = UIColor(r: 255, g: 128, b: 64, a: 255) - let actualColor = UIColor(hexARGBString: "#FF8040") + let actualColor = UIColor(hexARGB: "#FF8040") - XCTAssertEqual(actualColor, expectedColor, "Should create from hex6 ARGB String") + XCTAssertEqual(actualColor, expectedColor, "Should create from hex6 ARGB String") } func test_ShouldCreateColorFromHex8String() { let expectedColor = UIColor(r: 255, g: 187, b: 204, a: 128) - let actualColor = UIColor(hexARGBString: "#80FFBBCC") + let actualColor = UIColor(hexARGB: "#80FFBBCC") - XCTAssertEqual(actualColor, expectedColor, "Should create from hex8 ARGB String") + XCTAssertEqual(actualColor, expectedColor, "Should create from hex8 ARGB String") } func test_ShouldCreateColorForHexWithoutLeadingHash() { let expectedColor = UIColor(r: 255, g: 187, b: 204, a: 128) - let actualColor = UIColor(hexARGBString: "80FFBBCC") + let actualColor = UIColor(hexARGB: "80FFBBCC") - XCTAssertEqual(actualColor, expectedColor, "Should create color for hex without leading hash") + XCTAssertEqual(actualColor, expectedColor, "Should create color for hex without leading hash") } func test_ShouldReturnNilForInvalidHexString() { - let actualColor = UIColor(hexARGBString: "#FBCFBCFBCFCB") + let actualColor = UIColor(hexARGB: "#FBCFBCFBCFCB") XCTAssertNil(actualColor, "Should return nil for invalid ARGB String") } diff --git a/FeluciaTests/FeluciaTestsRGBAFloat.swift b/FeluciaTests/FeluciaTestsRGBAFloat.swift index 88e6bff..a9ef2ba 100644 --- a/FeluciaTests/FeluciaTestsRGBAFloat.swift +++ b/FeluciaTests/FeluciaTestsRGBAFloat.swift @@ -12,7 +12,7 @@ import XCTest class FeluciaTestsRGBAFloat: XCTestCase { func test_ShouldReturnTupleWithRGBACompoments() { - let expectedTuple : (r: Float, g:Float, b:Float, a:Float) = (1.0, 0.75, 0.5, 0.25) + let expectedTuple: (r: Float, g: Float, b: Float, a: Float) = (1.0, 0.75, 0.5, 0.25) let color = UIColor(red: 1.0, green: 0.75, blue: 0.5, alpha: 0.25) let actualTuple = color.rgbaf() @@ -22,7 +22,7 @@ class FeluciaTestsRGBAFloat: XCTestCase { } func test_ShouldReturnArrayWithRGBACompoments() { - let expectedArray : [Float] = [1.0, 0.75, 0.5, 0.25] + let expectedArray: [Float] = [1.0, 0.75, 0.5, 0.25] let color = UIColor(red: 1.0, green: 0.75, blue: 0.5, alpha: 0.25) let actualArray = color.rgbafArray() diff --git a/FeluciaTests/FeluciaTestsUtils.swift b/FeluciaTests/FeluciaTestsUtils.swift index 11bf017..81c1bbb 100644 --- a/FeluciaTests/FeluciaTestsUtils.swift +++ b/FeluciaTests/FeluciaTestsUtils.swift @@ -13,7 +13,7 @@ import XCTest class FeluciaTestsUtils: XCTestCase { func test_ShouldCreateGrayscaleFromOtherColor() { - let expectedComponents: (r:Int, g:Int, b:Int, a:Int) = (106, 106, 106, 255) + let expectedComponents: (r: Int, g: Int, b: Int, a: Int) = (106, 106, 106, 255) let grayscaleColor = UIColor(r: 67, g: 122, b: 134).grayscale() let actualComponents = grayscaleColor.rgba() @@ -35,9 +35,9 @@ class FeluciaTestsUtils: XCTestCase { extension FeluciaTestsUtils { func test_ShouldLightenColorWithDefaultValue() { - let expectedColor = UIColor(hexARGBString: "#ff3333")! + let expectedColor = UIColor(hexARGB: "#ff3333")! - let lightenColor = UIColor(hexARGBString:"#f00")!.lighten() + let lightenColor = UIColor(hexARGB:"#f00")!.lighten() let areEqual = expectedColor == lightenColor @@ -45,9 +45,9 @@ extension FeluciaTestsUtils { } func test_ColorLightenBy100PercentShouldBecomeWhite() { - let expectedColor = UIColor.whiteColor() + let expectedColor = UIColor.white - let lightenColor = UIColor(hexARGBString:"#f00")!.lighten(1.0) + let lightenColor = UIColor(hexARGB:"#f00")!.lighten(percentage: 1.0) let areEqual = expectedColor == lightenColor @@ -55,9 +55,9 @@ extension FeluciaTestsUtils { } func test_ShouldDarkenColorWithDefaultValue() { - let expectedColor = UIColor(hexARGBString: "#cc0000")! + let expectedColor = UIColor(hexARGB: "#cc0000")! - let darkenColor = UIColor(hexARGBString:"#f00")!.darken() + let darkenColor = UIColor(hexARGB:"#f00")!.darken() let areEqual = expectedColor == darkenColor @@ -65,9 +65,9 @@ extension FeluciaTestsUtils { } func test_ColorDarkenBy100PercentShouldBecomeBlack() { - let expectedColor = UIColor.blackColor() + let expectedColor = UIColor.black - let darkenColor = UIColor(hexARGBString:"#f00")!.darken(1.0) + let darkenColor = UIColor(hexARGB:"#f00")!.darken(percentage: 1.0) let areEqual = expectedColor == darkenColor @@ -81,7 +81,7 @@ extension FeluciaTestsUtils { func test_ShouldReturnWhiteAsComplementaryColorToBlack() { let expectedComponents = (r: 255, g: 255, b: 255, a: 255) // expected color is white - let invertedColor = UIColor.blackColor().complementaryColor() + let invertedColor = UIColor.black.complementaryColor() let actualComponents = invertedColor.rgba() let areTuplesEquels = actualComponents == expectedComponents @@ -91,7 +91,7 @@ extension FeluciaTestsUtils { func test_ShouldReturnBlackAsComplementaryColorToWhite() { let expectedComponents = (r: 0, g: 0, b: 0, a: 255) // expected color is black - let invertedColor = UIColor.whiteColor().complementaryColor() + let invertedColor = UIColor.white.complementaryColor() let actualComponents = invertedColor.rgba() let areTuplesEquels = actualComponents == expectedComponents @@ -103,7 +103,7 @@ extension FeluciaTestsUtils { extension FeluciaTestsUtils { func test_IsLightShouldReturnTrueForWhiteColor() { - let color = UIColor.whiteColor() + let color = UIColor.white let actualResult = color.isLight() @@ -111,7 +111,7 @@ extension FeluciaTestsUtils { } func test_IsLightShouldReturnFalseForBlackColor() { - let color = UIColor.blackColor() + let color = UIColor.black let actualResult = color.isLight() @@ -119,7 +119,7 @@ extension FeluciaTestsUtils { } func test_IsDarkShouldReturnTrueForBlackColor() { - let color = UIColor.blackColor() + let color = UIColor.black let actualResult = color.isDark() @@ -127,7 +127,7 @@ extension FeluciaTestsUtils { } func test_IsDarkShouldReturnFalseForWhiteColor() { - let color = UIColor.whiteColor() + let color = UIColor.white let actualResult = color.isDark() diff --git a/FeluciaTests/Helpers.swift b/FeluciaTests/Helpers.swift index 156fc75..5597ecb 100644 --- a/FeluciaTests/Helpers.swift +++ b/FeluciaTests/Helpers.swift @@ -9,7 +9,7 @@ import Foundation import XCTest -func AssertEqualWithAccuracy(expression1:(T, T, T, T), _ expression2:(T, T, T, T), _ accuracy: T, _ message: String = "", file: StaticString = #file, line: UInt = #line) { +public func AssertEqualWithAccuracy(_ expression1: (T, T, T, T), _ expression2: (T, T, T, T), _ accuracy: T, _ message: String = "", _ file: StaticString = #file, _ line: UInt = #line) { XCTAssertEqualWithAccuracy(expression1.0, expression2.0, accuracy: accuracy, message, file:file, line:line) XCTAssertEqualWithAccuracy(expression1.1, expression2.1, accuracy: accuracy, message, file:file, line:line) @@ -17,7 +17,7 @@ func AssertEqualWithAccuracy(expression1:(T, T, T, T), _ ex XCTAssertEqualWithAccuracy(expression1.3, expression2.3, accuracy: accuracy, message, file:file, line:line) } -func AssertEqualWithAccuracy(expression1:[T], _ expression2:[T], _ accuracy: T, _ message: String = "", file: StaticString = #file, line: UInt = #line) { +public func AssertEqualWithAccuracy(_ expression1: [T], _ expression2: [T], _ accuracy: T, _ message: String = "", _ file: StaticString = #file, _ line: UInt = #line) { guard expression1.count == expression2.count else { XCTFail(message) @@ -25,6 +25,6 @@ func AssertEqualWithAccuracy(expression1:[T], _ expression2 } for i in 0.. +@import Foundation; //! Project version number for Felucia. FOUNDATION_EXPORT double FeluciaVersionNumber; diff --git a/Felucia/Felucia.swift b/Source/Felucia.swift similarity index 67% rename from Felucia/Felucia.swift rename to Source/Felucia.swift index df820db..a1e164f 100644 --- a/Felucia/Felucia.swift +++ b/Source/Felucia.swift @@ -10,7 +10,7 @@ import UIKit // MARK: - Eqauality operators -public func ==(lhs:UIColor, rhs:UIColor) -> Bool { +public func == (lhs: UIColor, rhs: UIColor) -> Bool { let lhsRGBA = lhs.rgba() let rhsRGBA = rhs.rgba() @@ -20,7 +20,7 @@ public func ==(lhs:UIColor, rhs:UIColor) -> Bool { && lhsRGBA.a == rhsRGBA.a } -public func !=(lhs:UIColor, rhs:UIColor) -> Bool { +public func != (lhs: UIColor, rhs: UIColor) -> Bool { return !(lhs == rhs) } @@ -28,19 +28,19 @@ public func !=(lhs:UIColor, rhs:UIColor) -> Bool { extension UIColor { - public convenience init(r:Int, g:Int, b:Int, a:Int = 255) { - let ratioRed = Float(UIColor.clamp(r, minValue: 0, maxValue: 255)) / 255.0 - let ratioGreen = Float(UIColor.clamp(g, minValue: 0, maxValue: 255)) / 255.0 - let ratioBlue = Float(UIColor.clamp(b, minValue: 0, maxValue: 255)) / 255.0 - let ratioAlpha = Float(UIColor.clamp(a, minValue: 0, maxValue: 255)) / 255.0 - + public convenience init(r: Int, g: Int, b: Int, a: Int = 255) { + let ratioRed = Float(UIColor.clamp(value: r, minValue: 0, maxValue: 255)) / 255.0 + let ratioGreen = Float(UIColor.clamp(value: g, minValue: 0, maxValue: 255)) / 255.0 + let ratioBlue = Float(UIColor.clamp(value: b, minValue: 0, maxValue: 255)) / 255.0 + let ratioAlpha = Float(UIColor.clamp(value: a, minValue: 0, maxValue: 255)) / 255.0 + self.init(colorLiteralRed: ratioRed, green: ratioGreen, blue: ratioBlue, alpha: ratioAlpha) } - public func rgba() -> (r:Int, g:Int, b:Int, a:Int) { - var fRed : CGFloat = 0 - var fGreen : CGFloat = 0 - var fBlue : CGFloat = 0 + public func rgba() -> (r: Int, g: Int, b: Int, a: Int) { + var fRed: CGFloat = 0 + var fGreen: CGFloat = 0 + var fBlue: CGFloat = 0 var fAlpha: CGFloat = 0 self.getRed(&fRed, green: &fGreen, blue: &fBlue, alpha: &fAlpha) @@ -48,7 +48,7 @@ extension UIColor { let iGreen = Int(round(fGreen * 255.0)) let iBlue = Int(round(fBlue * 255.0)) let iAlpha = Int(round(fAlpha * 255.0)) - + return (iRed, iGreen, iBlue, iAlpha) } @@ -57,44 +57,41 @@ extension UIColor { return [components.r, components.g, components.b, components.a] } - private class func clamp(value:Int, minValue:Int, maxValue:Int) -> Int { + private class func clamp(value: Int, minValue: Int, maxValue: Int) -> Int { return max(minValue, min(value, maxValue)) } } -// MARK: - Hex color +// MARK: - Hex color extension UIColor { - public convenience init?(hexARGBString:String) { + public convenience init?(hexARGB: String) { let hex3 = "^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$" let hex6 = "^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$" let hex8 = "^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$" - if let comp = UIColor.getComponents(hexARGBString, pattern: hex3) { + if let comp = UIColor.getComponents(hex: hexARGB, pattern: hex3) { let r = Int(comp[0] + comp[0], radix:16)! let g = Int(comp[1] + comp[1], radix:16)! let b = Int(comp[2] + comp[2], radix:16)! self.init(r:r, g:g, b:b) - } - else if let comp = UIColor.getComponents(hexARGBString, pattern: hex6) { + } else if let comp = UIColor.getComponents(hex: hexARGB, pattern: hex6) { let r = Int(comp[0], radix:16)! let g = Int(comp[1], radix:16)! let b = Int(comp[2], radix:16)! self.init(r:r, g:g, b:b) - } - else if let comp = UIColor.getComponents(hexARGBString, pattern: hex8) { + } else if let comp = UIColor.getComponents(hex: hexARGB, pattern: hex8) { let a = Int(comp[0], radix:16)! let r = Int(comp[1], radix:16)! let g = Int(comp[2], radix:16)! let b = Int(comp[3], radix:16)! self.init(r:r, g:g, b:b, a:a) - - } - else { + + } else { // Failable initializer must set all stored propertied before returning nil :( // In conveniece initializer we have to call designated initializer before returning nil, // otherwise we will get BAD_ACCESS. @@ -103,16 +100,16 @@ extension UIColor { } } - private class func getComponents(hexString: String, pattern: String) -> [String]? { - let regex = try! NSRegularExpression(pattern: pattern, options: .CaseInsensitive) + private class func getComponents(hex: String, pattern: String) -> [String]? { + let regex = try! NSRegularExpression(pattern: pattern, options: .caseInsensitive) - guard let match = regex.firstMatchInString(hexString, options:[], range:NSMakeRange(0, hexString.characters.count)) else { + guard let match = regex.firstMatch(in: hex, options: [], range: NSRange(location: 0, length: hex.characters.count)) else { return nil } var components = [String]() for index in 1 ..< match.numberOfRanges { - let component: String = (hexString as NSString).substringWithRange(match.rangeAtIndex(index)) + let component: String = (hex as NSString).substring(with: match.rangeAt(index)) components.append(component) } @@ -125,14 +122,14 @@ extension UIColor { extension UIColor { - public convenience init(red: Float, green: Float, blue: Float){ + public convenience init(red: Float, green: Float, blue: Float) { self.init(colorLiteralRed: red, green: green, blue: blue, alpha: 1.0) } - public func rgbaf() -> (r:Float, g:Float, b:Float, a:Float) { - var fRed : CGFloat = 0 - var fGreen : CGFloat = 0 - var fBlue : CGFloat = 0 + public func rgbaf() -> (r: Float, g: Float, b: Float, a: Float) { + var fRed: CGFloat = 0 + var fGreen: CGFloat = 0 + var fBlue: CGFloat = 0 var fAlpha: CGFloat = 0 self.getRed(&fRed, green: &fGreen, blue: &fBlue, alpha: &fAlpha) @@ -150,10 +147,10 @@ extension UIColor { extension UIColor { - public func hsba() -> (h:Float, s:Float, b:Float, a:Float) { - var hue : CGFloat = 0 - var saturation : CGFloat = 0 - var brightness : CGFloat = 0 + public func hsba() -> (h: Float, s: Float, b: Float, a: Float) { + var hue: CGFloat = 0 + var saturation: CGFloat = 0 + var brightness: CGFloat = 0 var alpha: CGFloat = 0 self.getHue(&hue, saturation: &saturation, brightness: &brightness, alpha: &alpha) @@ -173,64 +170,63 @@ extension UIColor { extension UIColor { - public convenience init(h:Float, s:Float, l:Float, a:Float = 1.0) { - var r:Float - var g:Float - var b:Float + public convenience init(h: Float, s: Float, l: Float, a: Float = 1.0) { + var r: Float + var g: Float + var b: Float let normalizedH = (h > 1) ? (h / 360.0) : h let normalizedS = (s > 1) ? (s / 100.0) : s let normalizedL = (l > 1) ? (l / 100.0) : l - - - if(s == 0){ + + + if(s == 0) { r = l // achromatic g = l b = l - } else{ - let q = (normalizedL < 0.5) ? (normalizedL * (1 + normalizedS)) : (normalizedL + normalizedS - normalizedL * normalizedS); - let p = 2 * normalizedL - q; - r = UIColor.hue2rgb(p, q: q, t1: normalizedH + 1.0/3.0); - g = UIColor.hue2rgb(p, q: q, t1: normalizedH); - b = UIColor.hue2rgb(p, q: q, t1: normalizedH - 1.0/3.0); + } else { + let q = (normalizedL < 0.5) ? (normalizedL * (1 + normalizedS)) : (normalizedL + normalizedS - normalizedL * normalizedS) + let p = 2 * normalizedL - q + r = UIColor.hue2rgb(p: p, q: q, t1: normalizedH + 1.0/3.0) + g = UIColor.hue2rgb(p: p, q: q, t1: normalizedH) + b = UIColor.hue2rgb(p: p, q: q, t1: normalizedH - 1.0/3.0) } - + self.init(colorLiteralRed: r, green: g, blue: b, alpha: a) } - class func hue2rgb(p:Float, q:Float, t1:Float) -> Float { + class func hue2rgb(p: Float, q: Float, t1: Float) -> Float { var t = t1 if(t < 0) {t += 1} if(t > 1) {t -= 1} if(t < 1.0/6.0) { return p + (q - p) * 6.0 * t } if(t < 1.0/2.0) { return q } if(t < 2.0/3.0) { return p + (q - p) * (2.0/3.0 - t) * 6.0 } - return p; + return p } - public func hsla() -> (h:Float, s:Float, l:Float, a:Float) { + public func hsla() -> (h: Float, s: Float, l: Float, a: Float) { let components = rgbaf() let minComponent = min(components.r, components.g, components.b) let maxComponent = max(components.r, components.g, components.b) - var h:Float = 0.0 - var s:Float = 0.0 - let l:Float = (minComponent + maxComponent) / 2.0 + var h: Float = 0.0 + var s: Float = 0.0 + let l: Float = (minComponent + maxComponent) / 2.0 if(minComponent == maxComponent) { h = 0.0 s = 0.0 - } - else { + } else { let d: Float = maxComponent - minComponent s = l > 0.5 ? d / Float(2.0 - maxComponent - minComponent) : d / Float((maxComponent + minComponent)) switch(maxComponent) { - case components.r: h = (components.g - components.b) / d + (components.g < components.b ? 6.0 : 0.0) - case components.g: h = (components.b - components.r) / d + 2.0 - case components.b: h = (components.r - components.g) / d + 4.0 - default: h = 0.0 + case components.r: h = (components.g - components.b) / d + (components.g < components.b ? 6.0 : 0.0) + case components.g: h = (components.b - components.r) / d + 2.0 + case components.b: h = (components.r - components.g) / d + 4.0 + default: h = 0.0 } - h /= 6.0; + h /= 6.0 } return (h, s, l, components.a) @@ -247,7 +243,7 @@ extension UIColor { extension UIColor { - public convenience init(cyan: Float, magneta: Float, yellow: Float, black: Float) { + public convenience init(cyan: Float, magneta: Float, yellow: Float, black: Float) { let red = (1 - cyan) * (1 - black) let green = (1 - magneta) * (1 - black) let blue = (1 - yellow) * (1 - black) @@ -256,13 +252,13 @@ extension UIColor { } - public func cmyk() -> (c:Float, m:Float, y:Float, k:Float) { + public func cmyk() -> (c: Float, m: Float, y: Float, k: Float) { let components = rgbaf() let black = 1 - max(components.r, components.g, components.b) let cyan = (1 - components.r - black) / (1 - black) let magneta = (1 - components.g - black) / (1 - black) let yellow = (1 - components.b - black) / (1 - black) - + return (cyan, magneta, yellow, black) } @@ -280,12 +276,12 @@ extension UIColor { let components = rgbaf() return UIColor(red: CGFloat(1.0 - components.r), - green: CGFloat(1.0 - components.g), - blue: CGFloat(1.0 - components.b), - alpha: CGFloat(components.a)) - + green: CGFloat(1.0 - components.g), + blue: CGFloat(1.0 - components.b), + alpha: CGFloat(components.a)) + } - + public func lighten(percentage: Float = 0.1) -> UIColor { var components = hsla() @@ -309,8 +305,8 @@ extension UIColor { // https://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale var lumaComponent = Float(components.r) * 0.3 - lumaComponent += Float(components.g) * 0.59 - lumaComponent += Float(components.b) * 0.11 + lumaComponent += Float(components.g) * 0.59 + lumaComponent += Float(components.b) * 0.11 let grayComponent = Int(lumaComponent) @@ -324,17 +320,17 @@ extension UIColor { public func isDark() -> Bool { // YIQ equation from http://24ways.org/2010/calculating-color-contrast let components = rgba() - let yiq = (components.r * 299 + components.g * 587 + components.b * 114) / 1000; - return yiq < 128; + let yiq = (components.r * 299 + components.g * 587 + components.b * 114) / 1000 + return yiq < 128 } public class func randomColor() -> UIColor { // Inspired by https://gist.github.com/kylefox/1689973 - let hue : CGFloat = CGFloat(arc4random() % 256) / 256 // use 256 to get full range from 0.0 to 1.0 - let saturation : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from white - let brightness : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from black + let hue: CGFloat = CGFloat(arc4random() % 256) / 256 // use 256 to get full range from 0.0 to 1.0 + let saturation: CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from white + let brightness: CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from black return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: 1) } -} \ No newline at end of file +} diff --git a/Felucia/Info-iOS.plist b/Source/Info.plist similarity index 100% rename from Felucia/Info-iOS.plist rename to Source/Info.plist diff --git a/fastlane/Fastfile b/fastlane/Fastfile index edae42e..cab6a68 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -6,21 +6,14 @@ platform :ios do desc "Runs all the tests" lane :test do - xctest( - scheme: 'Felucia-iOS', - destination: "platform=iOS Simulator,name=iPhone 6,OS=9.3", - reports: [ - { - report: "html", - output: "build/reports/unit-tests.html" - }, - { - report: "junit", - output: "build/reports/unit-tests.xml" - } - ], - clean: nil - ) + scan( + project: "Felucia.xcodeproj", + scheme: "Felucia-iOS", + devices: ["iPhone 6s"], + clean: true, + output_directory: "build/reports", + output_types: "html, junit", + ) end end