Skip to content

Commit e9246ea

Browse files
author
Bobby Sudekum
authored
Update to swift 4 (#50)
1 parent fc9a00e commit e9246ea

11 files changed

+70
-33
lines changed

.swift-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0
1+
4.0

Cartfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "mapbox/MapboxDirections.swift" ~> 0.12
1+
github "mapbox/MapboxDirections.swift" ~> 0.13

Cartfile.resolved

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
github "mapbox/MapboxDirections.swift" "v0.12.0"
2-
github "raphaelmor/Polyline" "v4.1.1"
1+
github "mapbox/MapboxDirections.swift" "v0.13.0"
2+
github "raphaelmor/Polyline" "v4.2.0"

OSRMTextInstructions.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ Pod::Spec.new do |s|
4646
s.requires_arc = true
4747
s.module_name = "OSRMTextInstructions"
4848

49-
s.dependency "MapboxDirections.swift", "~> 0.10"
49+
s.dependency "MapboxDirections.swift", "~> 0.13"
5050

5151
s.prepare_command = "./json2plist.sh"
5252

OSRMTextInstructions.xcodeproj/project.pbxproj

Lines changed: 45 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -412,17 +412,18 @@
412412
isa = PBXProject;
413413
attributes = {
414414
LastSwiftUpdateCheck = 0820;
415-
LastUpgradeCheck = 0820;
415+
LastUpgradeCheck = 0910;
416416
TargetAttributes = {
417417
352BBC281E5E4D4200703DF1 = {
418418
CreatedOnToolsVersion = 8.2.1;
419419
DevelopmentTeam = GJZR2MEM28;
420+
LastSwiftMigration = 0910;
420421
ProvisioningStyle = Automatic;
421422
};
422423
35EBDB5C1E5E1572006EB3CD = {
423424
CreatedOnToolsVersion = 8.2.1;
424425
DevelopmentTeam = GJZR2MEM28;
425-
LastSwiftMigration = 0830;
426+
LastSwiftMigration = 0910;
426427
ProvisioningStyle = Automatic;
427428
};
428429
DA5F58921E85A32C00BA4D0A = {
@@ -738,7 +739,8 @@
738739
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
739740
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.OSRMTextInstructionsTests;
740741
PRODUCT_NAME = "$(TARGET_NAME)";
741-
SWIFT_VERSION = 3.0;
742+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
743+
SWIFT_VERSION = 4.0;
742744
};
743745
name = Debug;
744746
};
@@ -754,7 +756,8 @@
754756
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
755757
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.OSRMTextInstructionsTests;
756758
PRODUCT_NAME = "$(TARGET_NAME)";
757-
SWIFT_VERSION = 3.0;
759+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
760+
SWIFT_VERSION = 4.0;
758761
};
759762
name = Release;
760763
};
@@ -768,15 +771,21 @@
768771
CLANG_CXX_LIBRARY = "libc++";
769772
CLANG_ENABLE_MODULES = YES;
770773
CLANG_ENABLE_OBJC_ARC = YES;
774+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
771775
CLANG_WARN_BOOL_CONVERSION = YES;
776+
CLANG_WARN_COMMA = YES;
772777
CLANG_WARN_CONSTANT_CONVERSION = YES;
773778
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
774779
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
775780
CLANG_WARN_EMPTY_BODY = YES;
776781
CLANG_WARN_ENUM_CONVERSION = YES;
777782
CLANG_WARN_INFINITE_RECURSION = YES;
778783
CLANG_WARN_INT_CONVERSION = YES;
784+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
785+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
779786
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
787+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
788+
CLANG_WARN_STRICT_PROTOTYPES = YES;
780789
CLANG_WARN_SUSPICIOUS_MOVE = YES;
781790
CLANG_WARN_UNREACHABLE_CODE = YES;
782791
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -807,6 +816,7 @@
807816
SDKROOT = iphoneos;
808817
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
809818
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
819+
SWIFT_VERSION = 4.0;
810820
TARGETED_DEVICE_FAMILY = "1,2";
811821
TVOS_DEPLOYMENT_TARGET = 9.0;
812822
VERSIONING_SYSTEM = "apple-generic";
@@ -825,15 +835,21 @@
825835
CLANG_CXX_LIBRARY = "libc++";
826836
CLANG_ENABLE_MODULES = YES;
827837
CLANG_ENABLE_OBJC_ARC = YES;
838+
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
828839
CLANG_WARN_BOOL_CONVERSION = YES;
840+
CLANG_WARN_COMMA = YES;
829841
CLANG_WARN_CONSTANT_CONVERSION = YES;
830842
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
831843
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
832844
CLANG_WARN_EMPTY_BODY = YES;
833845
CLANG_WARN_ENUM_CONVERSION = YES;
834846
CLANG_WARN_INFINITE_RECURSION = YES;
835847
CLANG_WARN_INT_CONVERSION = YES;
848+
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
849+
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
836850
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
851+
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
852+
CLANG_WARN_STRICT_PROTOTYPES = YES;
837853
CLANG_WARN_SUSPICIOUS_MOVE = YES;
838854
CLANG_WARN_UNREACHABLE_CODE = YES;
839855
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
@@ -856,6 +872,7 @@
856872
MTL_ENABLE_DEBUG_INFO = NO;
857873
SDKROOT = iphoneos;
858874
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
875+
SWIFT_VERSION = 4.0;
859876
TARGETED_DEVICE_FAMILY = "1,2";
860877
TVOS_DEPLOYMENT_TARGET = 9.0;
861878
VALIDATE_PRODUCT = YES;
@@ -886,7 +903,8 @@
886903
PRODUCT_NAME = "$(TARGET_NAME)";
887904
SKIP_INSTALL = YES;
888905
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
889-
SWIFT_VERSION = 3.0;
906+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
907+
SWIFT_VERSION = 4.0;
890908
};
891909
name = Debug;
892910
};
@@ -910,7 +928,8 @@
910928
PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructions";
911929
PRODUCT_NAME = "$(TARGET_NAME)";
912930
SKIP_INSTALL = YES;
913-
SWIFT_VERSION = 3.0;
931+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
932+
SWIFT_VERSION = 4.0;
914933
};
915934
name = Release;
916935
};
@@ -938,7 +957,8 @@
938957
SDKROOT = macosx;
939958
SKIP_INSTALL = YES;
940959
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
941-
SWIFT_VERSION = 3.0;
960+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
961+
SWIFT_VERSION = 4.0;
942962
};
943963
name = Debug;
944964
};
@@ -965,7 +985,8 @@
965985
PRODUCT_NAME = OSRMTextInstructions;
966986
SDKROOT = macosx;
967987
SKIP_INSTALL = YES;
968-
SWIFT_VERSION = 3.0;
988+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
989+
SWIFT_VERSION = 4.0;
969990
};
970991
name = Release;
971992
};
@@ -985,7 +1006,8 @@
9851006
PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructionsTests";
9861007
PRODUCT_NAME = OSRMTextInstructionsTests;
9871008
SDKROOT = macosx;
988-
SWIFT_VERSION = 3.0;
1009+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1010+
SWIFT_VERSION = 4.0;
9891011
};
9901012
name = Debug;
9911013
};
@@ -1005,7 +1027,8 @@
10051027
PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructionsTests";
10061028
PRODUCT_NAME = OSRMTextInstructionsTests;
10071029
SDKROOT = macosx;
1008-
SWIFT_VERSION = 3.0;
1030+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1031+
SWIFT_VERSION = 4.0;
10091032
};
10101033
name = Release;
10111034
};
@@ -1031,7 +1054,8 @@
10311054
SDKROOT = appletvos;
10321055
SKIP_INSTALL = YES;
10331056
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1034-
SWIFT_VERSION = 3.0;
1057+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1058+
SWIFT_VERSION = 4.0;
10351059
TARGETED_DEVICE_FAMILY = 3;
10361060
};
10371061
name = Debug;
@@ -1057,7 +1081,8 @@
10571081
PRODUCT_NAME = OSRMTextInstructions;
10581082
SDKROOT = appletvos;
10591083
SKIP_INSTALL = YES;
1060-
SWIFT_VERSION = 3.0;
1084+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1085+
SWIFT_VERSION = 4.0;
10611086
TARGETED_DEVICE_FAMILY = 3;
10621087
};
10631088
name = Release;
@@ -1076,7 +1101,8 @@
10761101
PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructionsTests";
10771102
PRODUCT_NAME = OSRMTextInstructionsTests;
10781103
SDKROOT = appletvos;
1079-
SWIFT_VERSION = 3.0;
1104+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1105+
SWIFT_VERSION = 4.0;
10801106
};
10811107
name = Debug;
10821108
};
@@ -1094,7 +1120,8 @@
10941120
PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructionsTests";
10951121
PRODUCT_NAME = OSRMTextInstructionsTests;
10961122
SDKROOT = appletvos;
1097-
SWIFT_VERSION = 3.0;
1123+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1124+
SWIFT_VERSION = 4.0;
10981125
};
10991126
name = Release;
11001127
};
@@ -1121,7 +1148,8 @@
11211148
SDKROOT = watchos;
11221149
SKIP_INSTALL = YES;
11231150
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
1124-
SWIFT_VERSION = 3.0;
1151+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1152+
SWIFT_VERSION = 4.0;
11251153
TARGETED_DEVICE_FAMILY = 4;
11261154
WATCHOS_DEPLOYMENT_TARGET = 3.1;
11271155
};
@@ -1149,7 +1177,8 @@
11491177
PRODUCT_NAME = OSRMTextInstructions;
11501178
SDKROOT = watchos;
11511179
SKIP_INSTALL = YES;
1152-
SWIFT_VERSION = 3.0;
1180+
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
1181+
SWIFT_VERSION = 4.0;
11531182
TARGETED_DEVICE_FAMILY = 4;
11541183
WATCHOS_DEPLOYMENT_TARGET = 3.1;
11551184
};

OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions iOS.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0910"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
<TestableReference
@@ -55,6 +56,7 @@
5556
buildConfiguration = "Debug"
5657
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5758
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
language = ""
5860
launchStyle = "0"
5961
useCustomWorkingDirectory = "NO"
6062
ignoresPersistentStateOnLaunch = "NO"

OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions macOS.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0910"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES"
3031
codeCoverageEnabled = "YES">
3132
<Testables>
@@ -56,6 +57,7 @@
5657
buildConfiguration = "Debug"
5758
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5859
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
60+
language = ""
5961
launchStyle = "0"
6062
useCustomWorkingDirectory = "NO"
6163
ignoresPersistentStateOnLaunch = "NO"

OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions tvOS.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0910"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
<TestableReference
@@ -55,6 +56,7 @@
5556
buildConfiguration = "Debug"
5657
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
5758
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
59+
language = ""
5860
launchStyle = "0"
5961
useCustomWorkingDirectory = "NO"
6062
ignoresPersistentStateOnLaunch = "NO"

OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions watchOS.xcscheme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0820"
3+
LastUpgradeVersion = "0910"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -26,6 +26,7 @@
2626
buildConfiguration = "Debug"
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
language = ""
2930
shouldUseLaunchSchemeArgsEnv = "YES">
3031
<Testables>
3132
</Testables>
@@ -36,6 +37,7 @@
3637
buildConfiguration = "Debug"
3738
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
3839
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
40+
language = ""
3941
launchStyle = "0"
4042
useCustomWorkingDirectory = "NO"
4143
ignoresPersistentStateOnLaunch = "NO"

OSRMTextInstructions/OSRMTextInstructions.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protocol Tokenized {
1515

1616
extension String: Tokenized {
1717
public var sentenceCased: String {
18-
return String(characters.prefix(1)).uppercased() + String(characters.dropFirst())
18+
return prefix(1).uppercased() + dropFirst()
1919
}
2020

2121
public func replacingTokens(using interpolator: ((TokenType) -> String)) -> String {
@@ -62,7 +62,7 @@ extension String: Tokenized {
6262
}
6363

6464
extension NSAttributedString: Tokenized {
65-
public func replacingTokens(using interpolator: ((TokenType) -> NSAttributedString)) -> NSAttributedString {
65+
@objc public func replacingTokens(using interpolator: ((TokenType) -> NSAttributedString)) -> NSAttributedString {
6666
let scanner = Scanner(string: string)
6767
scanner.charactersToBeSkipped = nil
6868
let result = NSMutableAttributedString()
@@ -97,13 +97,13 @@ extension NSAttributedString: Tokenized {
9797
// capitalize
9898
let meta = OSRMTextInstructionsStrings["meta"] as! [String: Any]
9999
if meta["capitalizeFirstLetter"] as? Bool ?? false {
100-
result.replaceCharacters(in: NSRange(location: 0, length: 1), with: String(result.string.characters.first!).uppercased())
100+
result.replaceCharacters(in: NSRange(location: 0, length: 1), with: String(result.string.first!).uppercased())
101101
}
102102
return result as NSAttributedString
103103
}
104104
}
105105

106-
public class OSRMInstructionFormatter: Formatter {
106+
@objc public class OSRMInstructionFormatter: Formatter {
107107
let version: String
108108
let instructions: [String: Any]
109109

@@ -116,7 +116,7 @@ public class OSRMInstructionFormatter: Formatter {
116116
return formatter
117117
}()
118118

119-
public init(version: String) {
119+
@objc public init(version: String) {
120120
self.version = version
121121
self.instructions = OSRMTextInstructionsStrings[version] as! [String: Any]
122122

@@ -155,7 +155,7 @@ public class OSRMInstructionFormatter: Formatter {
155155

156156
- returns: A format string suitable for `String.replacingTokens(using:)`.
157157
*/
158-
public func phrase(named name: PhraseName) -> String {
158+
@objc public func phrase(named name: PhraseName) -> String {
159159
let phrases = instructions["phrase"] as! [String: String]
160160
return phrases["\(name)"]!
161161
}
@@ -262,7 +262,7 @@ public class OSRMInstructionFormatter: Formatter {
262262
- parameter modifyValueByKey: Allows for mutating the instruction at given parts of the instruction.
263263
- returns: An instruction as an `NSAttributedString`.
264264
*/
265-
public func attributedString(for obj: Any, withDefaultAttributes attrs: [String : Any]? = nil, legIndex: Int?, numberOfLegs: Int?, roadClasses: RoadClasses? = RoadClasses([]), modifyValueByKey: ((TokenType, NSAttributedString) -> NSAttributedString)?) -> NSAttributedString? {
265+
public func attributedString(for obj: Any, withDefaultAttributes attrs: [NSAttributedStringKey: Any]? = nil, legIndex: Int?, numberOfLegs: Int?, roadClasses: RoadClasses? = RoadClasses([]), modifyValueByKey: ((TokenType, NSAttributedString) -> NSAttributedString)?) -> NSAttributedString? {
266266
guard let step = obj as? RouteStep else {
267267
return nil
268268
}

0 commit comments

Comments
 (0)