diff --git a/.swift-version b/.swift-version index 9f55b2c..5186d07 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -3.0 +4.0 diff --git a/Cartfile b/Cartfile index 9ee1698..3260185 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "mapbox/MapboxDirections.swift" ~> 0.12 +github "mapbox/MapboxDirections.swift" ~> 0.13 diff --git a/Cartfile.resolved b/Cartfile.resolved index d721df2..884f375 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "mapbox/MapboxDirections.swift" "v0.12.0" -github "raphaelmor/Polyline" "v4.1.1" +github "mapbox/MapboxDirections.swift" "v0.13.0" +github "raphaelmor/Polyline" "v4.2.0" diff --git a/OSRMTextInstructions.podspec b/OSRMTextInstructions.podspec index 1811a35..f6baf38 100644 --- a/OSRMTextInstructions.podspec +++ b/OSRMTextInstructions.podspec @@ -46,7 +46,7 @@ Pod::Spec.new do |s| s.requires_arc = true s.module_name = "OSRMTextInstructions" - s.dependency "MapboxDirections.swift", "~> 0.10" + s.dependency "MapboxDirections.swift", "~> 0.13" s.prepare_command = "./json2plist.sh" diff --git a/OSRMTextInstructions.xcodeproj/project.pbxproj b/OSRMTextInstructions.xcodeproj/project.pbxproj index e7e2a88..f6e00f6 100644 --- a/OSRMTextInstructions.xcodeproj/project.pbxproj +++ b/OSRMTextInstructions.xcodeproj/project.pbxproj @@ -412,17 +412,18 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0820; - LastUpgradeCheck = 0820; + LastUpgradeCheck = 0910; TargetAttributes = { 352BBC281E5E4D4200703DF1 = { CreatedOnToolsVersion = 8.2.1; DevelopmentTeam = GJZR2MEM28; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; }; 35EBDB5C1E5E1572006EB3CD = { CreatedOnToolsVersion = 8.2.1; DevelopmentTeam = GJZR2MEM28; - LastSwiftMigration = 0830; + LastSwiftMigration = 0910; ProvisioningStyle = Automatic; }; DA5F58921E85A32C00BA4D0A = { @@ -738,7 +739,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.OSRMTextInstructionsTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -754,7 +756,8 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.OSRMTextInstructionsTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -768,7 +771,9 @@ 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_DOCUMENTATION_COMMENTS = YES; @@ -776,7 +781,11 @@ 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; @@ -807,6 +816,7 @@ SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -825,7 +835,9 @@ 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_DOCUMENTATION_COMMENTS = YES; @@ -833,7 +845,11 @@ 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; @@ -856,6 +872,7 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = "1,2"; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; @@ -886,7 +903,8 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -910,7 +928,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructions"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -938,7 +957,8 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -965,7 +985,8 @@ PRODUCT_NAME = OSRMTextInstructions; SDKROOT = macosx; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -985,7 +1006,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructionsTests"; PRODUCT_NAME = OSRMTextInstructionsTests; SDKROOT = macosx; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1005,7 +1027,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructionsTests"; PRODUCT_NAME = OSRMTextInstructionsTests; SDKROOT = macosx; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -1031,7 +1054,8 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Debug; @@ -1057,7 +1081,8 @@ PRODUCT_NAME = OSRMTextInstructions; SDKROOT = appletvos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 3; }; name = Release; @@ -1076,7 +1101,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructionsTests"; PRODUCT_NAME = OSRMTextInstructionsTests; SDKROOT = appletvos; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Debug; }; @@ -1094,7 +1120,8 @@ PRODUCT_BUNDLE_IDENTIFIER = "org.project-osrm.OSRMTextInstructionsTests"; PRODUCT_NAME = OSRMTextInstructionsTests; SDKROOT = appletvos; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; }; name = Release; }; @@ -1121,7 +1148,8 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 3.1; }; @@ -1149,7 +1177,8 @@ PRODUCT_NAME = OSRMTextInstructions; SDKROOT = watchos; SKIP_INSTALL = YES; - SWIFT_VERSION = 3.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Off; + SWIFT_VERSION = 4.0; TARGETED_DEVICE_FAMILY = 4; WATCHOS_DEPLOYMENT_TARGET = 3.1; }; diff --git a/OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions iOS.xcscheme b/OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions iOS.xcscheme index ea0fc1d..7d665a0 100644 --- a/OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions iOS.xcscheme +++ b/OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions iOS.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions tvOS.xcscheme b/OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions tvOS.xcscheme index ed45c9f..a6f381d 100644 --- a/OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions tvOS.xcscheme +++ b/OSRMTextInstructions.xcodeproj/xcshareddata/xcschemes/OSRMTextInstructions tvOS.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/OSRMTextInstructions/OSRMTextInstructions.swift b/OSRMTextInstructions/OSRMTextInstructions.swift index 7aaf730..58bbeb0 100644 --- a/OSRMTextInstructions/OSRMTextInstructions.swift +++ b/OSRMTextInstructions/OSRMTextInstructions.swift @@ -15,7 +15,7 @@ protocol Tokenized { extension String: Tokenized { public var sentenceCased: String { - return String(characters.prefix(1)).uppercased() + String(characters.dropFirst()) + return prefix(1).uppercased() + dropFirst() } public func replacingTokens(using interpolator: ((TokenType) -> String)) -> String { @@ -62,7 +62,7 @@ extension String: Tokenized { } extension NSAttributedString: Tokenized { - public func replacingTokens(using interpolator: ((TokenType) -> NSAttributedString)) -> NSAttributedString { + @objc public func replacingTokens(using interpolator: ((TokenType) -> NSAttributedString)) -> NSAttributedString { let scanner = Scanner(string: string) scanner.charactersToBeSkipped = nil let result = NSMutableAttributedString() @@ -97,13 +97,13 @@ extension NSAttributedString: Tokenized { // capitalize let meta = OSRMTextInstructionsStrings["meta"] as! [String: Any] if meta["capitalizeFirstLetter"] as? Bool ?? false { - result.replaceCharacters(in: NSRange(location: 0, length: 1), with: String(result.string.characters.first!).uppercased()) + result.replaceCharacters(in: NSRange(location: 0, length: 1), with: String(result.string.first!).uppercased()) } return result as NSAttributedString } } -public class OSRMInstructionFormatter: Formatter { +@objc public class OSRMInstructionFormatter: Formatter { let version: String let instructions: [String: Any] @@ -116,7 +116,7 @@ public class OSRMInstructionFormatter: Formatter { return formatter }() - public init(version: String) { + @objc public init(version: String) { self.version = version self.instructions = OSRMTextInstructionsStrings[version] as! [String: Any] @@ -155,7 +155,7 @@ public class OSRMInstructionFormatter: Formatter { - returns: A format string suitable for `String.replacingTokens(using:)`. */ - public func phrase(named name: PhraseName) -> String { + @objc public func phrase(named name: PhraseName) -> String { let phrases = instructions["phrase"] as! [String: String] return phrases["\(name)"]! } @@ -262,7 +262,7 @@ public class OSRMInstructionFormatter: Formatter { - parameter modifyValueByKey: Allows for mutating the instruction at given parts of the instruction. - returns: An instruction as an `NSAttributedString`. */ - public func attributedString(for obj: Any, withDefaultAttributes attrs: [String : Any]? = nil, legIndex: Int?, numberOfLegs: Int?, roadClasses: RoadClasses? = RoadClasses([]), modifyValueByKey: ((TokenType, NSAttributedString) -> NSAttributedString)?) -> NSAttributedString? { + public func attributedString(for obj: Any, withDefaultAttributes attrs: [NSAttributedStringKey: Any]? = nil, legIndex: Int?, numberOfLegs: Int?, roadClasses: RoadClasses? = RoadClasses([]), modifyValueByKey: ((TokenType, NSAttributedString) -> NSAttributedString)?) -> NSAttributedString? { guard let step = obj as? RouteStep else { return nil } diff --git a/README.md b/README.md index 9848b78..6f3b1fa 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/OSRMTextInstructions.svg)](http://cocoadocs.org/docsets/OSRMTextInstructions/) -OSRM Text Instructions is a library for iOS, macOS, tvOS, and watchOS applications written in Swift 3 or Objective-C that transforms [OSRM](http://www.project-osrm.org/) route responses into localized text instructions. +OSRM Text Instructions is a library for iOS, macOS, tvOS, and watchOS applications written in Swift 4 or Objective-C that transforms [OSRM](http://www.project-osrm.org/) route responses into localized text instructions. The last tagged version for Swift 3.2 is `v0.5.0` and the code is also available on the branch [`swift3.2`](https://github.com/Project-OSRM/osrm-text-instructions.swift/tree/swift3.2). You can use OSRM Text Instructions in conjunction with [MapboxDirections.swift](https://github.com/mapbox/MapboxDirections.swift/) and [MapboxNavigation.swift](https://github.com/mapbox/MapboxNavigation.swift/) to generate visual and voice guidance in a turn-by-turn navigation application.