Skip to content

Commit

Permalink
Merge pull request #47 from raphaelmor/swift-4.0
Browse files Browse the repository at this point in the history
Upgrade to Swift 4.0
  • Loading branch information
tomtaylor authored Sep 20, 2017
2 parents 1d0d82e + c9aec55 commit da4547b
Show file tree
Hide file tree
Showing 9 changed files with 72 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode8.2
osx_image: xcode9
before_script:
- export LANG=en_US.UTF-8
script:
Expand Down
46 changes: 29 additions & 17 deletions Polyline.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -363,16 +363,16 @@
attributes = {
LastSwiftMigration = 0700;
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Raphael MOR";
TargetAttributes = {
207F63FD19B5DF7E005261FA = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
207F640819B5DF7E005261FA = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
LastSwiftMigration = 0900;
};
91F7832B1CE4EB7E004E87E3 = {
CreatedOnToolsVersion = 7.3.1;
Expand Down Expand Up @@ -554,14 +554,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -606,14 +612,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -659,7 +671,7 @@
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -679,7 +691,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -694,7 +706,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.ramoapps.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -705,7 +717,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.ramoapps.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -729,7 +741,7 @@
PRODUCT_NAME = Polyline;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -754,7 +766,7 @@
PRODUCT_NAME = Polyline;
SDKROOT = macosx;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -771,7 +783,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramoapps.PolylineTests;
PRODUCT_NAME = PolylineTests;
SDKROOT = macosx;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Debug;
};
Expand All @@ -789,7 +801,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramoapps.PolylineTests;
PRODUCT_NAME = PolylineTests;
SDKROOT = macosx;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
};
name = Release;
};
Expand All @@ -811,7 +823,7 @@
PRODUCT_NAME = Polyline;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -836,7 +848,7 @@
PRODUCT_NAME = Polyline;
SDKROOT = appletvos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 3;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
Expand All @@ -853,7 +865,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramoapps.PolylineTests;
PRODUCT_NAME = PolylineTests;
SDKROOT = appletvos;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
name = Debug;
Expand All @@ -870,7 +882,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.ramoapps.PolylineTests;
PRODUCT_NAME = PolylineTests;
SDKROOT = appletvos;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
};
name = Release;
Expand All @@ -894,7 +906,7 @@
PRODUCT_NAME = Polyline;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand All @@ -920,7 +932,7 @@
PRODUCT_NAME = Polyline;
SDKROOT = watchos;
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = 4;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand Down
4 changes: 3 additions & 1 deletion Polyline.xcodeproj/xcshareddata/xcschemes/Polyline.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
Expand Down Expand Up @@ -56,6 +57,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -55,6 +56,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
2 changes: 1 addition & 1 deletion Polyline/Polyline.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ private func extractNextChunk(_ encodedString: inout String.UnicodeScalarView) t
let currentCharacterValue = Int32(encodedString[currentIndex].value)
if isSeparator(currentCharacterValue) {
let extractedScalars = encodedString[encodedString.startIndex...currentIndex]
encodedString = encodedString[encodedString.index(after: currentIndex)..<encodedString.endIndex]
encodedString = String.UnicodeScalarView(encodedString[encodedString.index(after: currentIndex)..<encodedString.endIndex])

return String(extractedScalars)
}
Expand Down
24 changes: 12 additions & 12 deletions PolylineTests/FunctionalPolylineTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,24 +108,24 @@ class FunctionalPolylineTests : XCTestCase {
let coordinates: [CLLocationCoordinate2D] = decodePolyline("_p~iF~ps|U_ulLnnqC_mqNvxq`@")!

XCTAssertEqual(coordinates.count, 3)
XCTAssertEqualWithAccuracy(coordinates[0].latitude, 38.5, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[0].longitude, -120.2, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[1].latitude, 40.7, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[1].longitude, -120.95, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[2].latitude, 43.252, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[2].longitude, -126.453, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[0].latitude, 38.5, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[0].longitude, -120.2, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[1].latitude, 40.7, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[1].longitude, -120.95, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[2].latitude, 43.252, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[2].longitude, -126.453, accuracy: COORD_EPSILON)
}

func testAnotherValidPolylineShouldReturnValidLocationArray() {
let coordinates: [CLLocationCoordinate2D] = decodePolyline("_ojiHa`tLh{IdCw{Gwc_@")!

XCTAssertEqual(coordinates.count, 3)
XCTAssertEqualWithAccuracy(coordinates[0].latitude, 48.8832, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[0].longitude, 2.23761, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[1].latitude, 48.82747, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[1].longitude, 2.23694, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[2].latitude, 48.87303, accuracy: COORD_EPSILON)
XCTAssertEqualWithAccuracy(coordinates[2].longitude, 2.40154, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[0].latitude, 48.8832, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[0].longitude, 2.23761, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[1].latitude, 48.82747, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[1].longitude, 2.23694, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[2].latitude, 48.87303, accuracy: COORD_EPSILON)
XCTAssertEqual(coordinates[2].longitude, 2.40154, accuracy: COORD_EPSILON)
}

// MARK:- Encoding levels
Expand Down
Loading

0 comments on commit da4547b

Please sign in to comment.