From 6bae31e2be9bd116a4888fb727cec9cb59bf17ed Mon Sep 17 00:00:00 2001 From: Bart Jochems Date: Mon, 3 Jun 2019 18:21:15 +0200 Subject: [PATCH] Swift 5 support (#51) * Swift 5 support * Update tests and travis configuration * Update swift version in podspec --- .travis.yml | 4 ++-- ContextMenu.podspec | 2 +- ContextMenu.xcodeproj/project.pbxproj | 12 +++++------ .../ContextMenu+HapticFeedbackStyle.swift | 2 +- ContextMenuTests/CGRect_AreaTests.swift | 21 ++++++++++--------- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/.travis.yml b/.travis.yml index 733ef83..193ec7a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: swift -osx_image: xcode9.3 +osx_image: xcode10.2 script: - - xcodebuild clean -project ContextMenu.xcodeproj -scheme ContextMenu -destination "platform=iOS Simulator,name=iPhone X,OS=11.3" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet + - xcodebuild clean -project ContextMenu.xcodeproj -scheme ContextMenu -destination "platform=iOS Simulator,name=iPhone X,OS=12.2" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO -quiet diff --git a/ContextMenu.podspec b/ContextMenu.podspec index 7d825bf..add6a01 100644 --- a/ContextMenu.podspec +++ b/ContextMenu.podspec @@ -8,5 +8,5 @@ Pod::Spec.new do |spec| spec.source = { :git => 'https://github.com/GitHawkApp/ContextMenu.git', :tag => spec.version.to_s } spec.source_files = 'ContextMenu/*.swift' spec.platform = :ios, '9.0' - spec.swift_version = '4.2' + spec.swift_version = '5.0' end diff --git a/ContextMenu.xcodeproj/project.pbxproj b/ContextMenu.xcodeproj/project.pbxproj index fb98028..bba47bb 100644 --- a/ContextMenu.xcodeproj/project.pbxproj +++ b/ContextMenu.xcodeproj/project.pbxproj @@ -208,12 +208,12 @@ TargetAttributes = { 2971CE712054539900342296 = { CreatedOnToolsVersion = 9.2; - LastSwiftMigration = 0920; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; 2991418320BC757000B63A3B = { CreatedOnToolsVersion = 9.3; - LastSwiftMigration = 1000; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; }; @@ -437,7 +437,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -461,7 +461,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; @@ -479,7 +479,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.whoisryannystrom.ContextMenuTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Debug; @@ -497,7 +497,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.whoisryannystrom.ContextMenuTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; TARGETED_DEVICE_FAMILY = "1,2"; }; name = Release; diff --git a/ContextMenu/ContextMenu+HapticFeedbackStyle.swift b/ContextMenu/ContextMenu+HapticFeedbackStyle.swift index 56763b2..6df21b3 100644 --- a/ContextMenu/ContextMenu+HapticFeedbackStyle.swift +++ b/ContextMenu/ContextMenu+HapticFeedbackStyle.swift @@ -10,7 +10,7 @@ import Foundation public extension ContextMenu { /// Haptic Feedback types. - public enum HapticFeedbackStyle: Int { + enum HapticFeedbackStyle: Int { case light, medium, heavy } diff --git a/ContextMenuTests/CGRect_AreaTests.swift b/ContextMenuTests/CGRect_AreaTests.swift index 3dec2d5..e8f50ec 100644 --- a/ContextMenuTests/CGRect_AreaTests.swift +++ b/ContextMenuTests/CGRect_AreaTests.swift @@ -12,19 +12,20 @@ import XCTest class CGRect_AreaTests: XCTestCase { let rect = CGRect(x: 0, y: 0, width: 100, height: 100) - + func test_whenCornersHavePadding() { - XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 10, y: 10), position: .topLeft)), 100) - XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 90, y: 10), position: .topRight)), 100) - XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 90, y: 90), position: .bottomRight)), 100) - XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 10, y: 90), position: .bottomLeft)), 100) + + XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 10, y: 10, width: 0, height: 0), position: .topLeft)), 100) + XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 90, y: 10, width: 0, height: 0), position: .topRight)), 100) + XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 90, y: 90, width: 0, height: 0), position: .bottomRight)), 100) + XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 10, y: 90, width: 0, height: 0), position: .bottomLeft)), 100) } func test_whenCornersHaveNoPadding() { - XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 0, y: 0), position: .topLeft)), 0) - XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 100, y: 0), position: .topRight)), 0) - XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 100, y: 100), position: .bottomRight)), 0) - XCTAssertEqual(rect.area(corner: SourceViewCorner(point: CGPoint(x: 00, y: 100), position: .bottomLeft)), 0) + XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 0, y: 0, width: rect.width, height: rect.height), position: .topLeft)), 0) + XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 100, y: 0, width: rect.width, height: rect.height), position: .topRight)), 0) + XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 100, y: 100, width: rect.width, height: rect.height), position: .bottomRight)), 0) + XCTAssertEqual(rect.area(corner: SourceViewCorner(rect: CGRect(x: 0, y: 100, width: rect.width, height: rect.height), position: .bottomLeft)), 0) } - + }