diff --git a/.circleci/config.yml b/.circleci/config.yml index 67a2ad2a5..dbd2524b4 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -198,12 +198,9 @@ jobs: steps: - checkout - install-mapbox-token - - install-carthage - - restore-cache - - carthage-bootstrap - run: name: "Build example app" - command: xcodebuild -sdk iphonesimulator -project MapboxDirections.xcodeproj -scheme 'Example' -destination 'platform=iOS Simulator,OS=15.5,name=iPhone 13 Pro Max' clean build + command: xcodebuild -sdk iphonesimulator -project DirectionsPlayground/DirectionsPlayground.xcodeproj -scheme 'DirectionsPlayground' -destination 'platform=iOS Simulator,OS=15.5,name=iPhone 13 Pro Max' clean build - save-cache build-job: diff --git a/Directions Example/AppDelegate.swift b/Directions Example/AppDelegate.swift deleted file mode 100644 index f358f5e3e..000000000 --- a/Directions Example/AppDelegate.swift +++ /dev/null @@ -1,10 +0,0 @@ -import SwiftUI - -@main -struct TestApp: App { - var body: some Scene { - WindowGroup { - ContentView(vm: DirectionsViewModel()) - } - } -} diff --git a/Directions Example/Assets.xcassets/AppIcon.appiconset/Contents.json b/Directions Example/Assets.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index d8db8d65f..000000000 --- a/Directions Example/Assets.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,98 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "20x20", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "20x20", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "1x" - }, - { - "idiom" : "ipad", - "size" : "76x76", - "scale" : "2x" - }, - { - "idiom" : "ipad", - "size" : "83.5x83.5", - "scale" : "2x" - }, - { - "idiom" : "ios-marketing", - "size" : "1024x1024", - "scale" : "1x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/Directions Example/Info.plist b/Directions Example/Info.plist deleted file mode 100644 index f84499f8c..000000000 --- a/Directions Example/Info.plist +++ /dev/null @@ -1,47 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - $(PRODUCT_BUNDLE_IDENTIFIER) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 2.9.0 - CFBundleSignature - ???? - CFBundleVersion - 110 - LSRequiresIPhoneOS - - NSLocationWhenInUseUsageDescription - Use the user location to fetch a route from their current position. - UILaunchStoryboardName - Launch Screen - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - UISupportedInterfaceOrientations~ipad - - UIInterfaceOrientationPortrait - UIInterfaceOrientationPortraitUpsideDown - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - - diff --git a/Directions Example/Launch Screen.storyboard b/Directions Example/Launch Screen.storyboard deleted file mode 100644 index 026a2622b..000000000 --- a/Directions Example/Launch Screen.storyboard +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/DirectionsExample/DirectionsExample.xcodeproj/project.pbxproj b/DirectionsExample/DirectionsExample.xcodeproj/project.pbxproj new file mode 100644 index 000000000..eee1e4622 --- /dev/null +++ b/DirectionsExample/DirectionsExample.xcodeproj/project.pbxproj @@ -0,0 +1,433 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + E2E47CC227F62E06003C859F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E2E47CC127F62E06003C859F /* Assets.xcassets */; }; + E2E47CC527F62E06003C859F /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E2E47CC427F62E06003C859F /* Preview Assets.xcassets */; }; + E2E47CE127F62E8F003C859F /* QueriesList.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2E47CDA27F62E8F003C859F /* QueriesList.swift */; }; + E2E47CE227F62E8F003C859F /* DirectionsExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2E47CDB27F62E8F003C859F /* DirectionsExample.swift */; }; + E2E47CE327F62E8F003C859F /* RoutesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2E47CDC27F62E8F003C859F /* RoutesView.swift */; }; + E2E47CE427F62E8F003C859F /* Query.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2E47CDD27F62E8F003C859F /* Query.swift */; }; + E2E47CE527F62E8F003C859F /* QueryEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2E47CDE27F62E8F003C859F /* QueryEditor.swift */; }; + E2E47CE627F62E8F003C859F /* WaypointsEditor.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2E47CDF27F62E8F003C859F /* WaypointsEditor.swift */; }; + E2E47CE727F62E8F003C859F /* Storage.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2E47CE027F62E8F003C859F /* Storage.swift */; }; + E2E47CEB27F62EB7003C859F /* MapboxDirections in Frameworks */ = {isa = PBXBuildFile; productRef = E2E47CEA27F62EB7003C859F /* MapboxDirections */; }; + E2E47CEF27F6EF7D003C859F /* InfoButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = E2E47CEE27F6EF7D003C859F /* InfoButton.swift */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + E2E47CBA27F62E05003C859F /* DirectionsExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DirectionsExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + E2E47CC127F62E06003C859F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + E2E47CC427F62E06003C859F /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + E2E47CDA27F62E8F003C859F /* QueriesList.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueriesList.swift; sourceTree = ""; }; + E2E47CDB27F62E8F003C859F /* DirectionsExample.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DirectionsExample.swift; sourceTree = ""; }; + E2E47CDC27F62E8F003C859F /* RoutesView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoutesView.swift; sourceTree = ""; }; + E2E47CDD27F62E8F003C859F /* Query.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Query.swift; sourceTree = ""; }; + E2E47CDE27F62E8F003C859F /* QueryEditor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QueryEditor.swift; sourceTree = ""; }; + E2E47CDF27F62E8F003C859F /* WaypointsEditor.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WaypointsEditor.swift; sourceTree = ""; }; + E2E47CE027F62E8F003C859F /* Storage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Storage.swift; sourceTree = ""; }; + E2E47CE827F62EAE003C859F /* mapbox-directions-swift */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = "mapbox-directions-swift"; path = ..; sourceTree = ""; }; + E2E47CED27F630BE003C859F /* DirectionsExample.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = DirectionsExample.entitlements; sourceTree = ""; }; + E2E47CEE27F6EF7D003C859F /* InfoButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoButton.swift; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + E2E47CB727F62E05003C859F /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + E2E47CEB27F62EB7003C859F /* MapboxDirections in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + E2E47CB127F62E05003C859F = { + isa = PBXGroup; + children = ( + E2E47CE827F62EAE003C859F /* mapbox-directions-swift */, + E2E47CBC27F62E05003C859F /* DirectionsExample */, + E2E47CBB27F62E05003C859F /* Products */, + E2E47CE927F62EB7003C859F /* Frameworks */, + ); + sourceTree = ""; + }; + E2E47CBB27F62E05003C859F /* Products */ = { + isa = PBXGroup; + children = ( + E2E47CBA27F62E05003C859F /* DirectionsExample.app */, + ); + name = Products; + sourceTree = ""; + }; + E2E47CBC27F62E05003C859F /* DirectionsExample */ = { + isa = PBXGroup; + children = ( + E2E47CED27F630BE003C859F /* DirectionsExample.entitlements */, + E2E47CD927F62E78003C859F /* Sources */, + E2E47CC127F62E06003C859F /* Assets.xcassets */, + E2E47CC327F62E06003C859F /* Preview Content */, + ); + path = DirectionsExample; + sourceTree = ""; + }; + E2E47CC327F62E06003C859F /* Preview Content */ = { + isa = PBXGroup; + children = ( + E2E47CC427F62E06003C859F /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + E2E47CD927F62E78003C859F /* Sources */ = { + isa = PBXGroup; + children = ( + E2E47CDB27F62E8F003C859F /* DirectionsExample.swift */, + E2E47CDA27F62E8F003C859F /* QueriesList.swift */, + E2E47CDD27F62E8F003C859F /* Query.swift */, + E2E47CDE27F62E8F003C859F /* QueryEditor.swift */, + E2E47CDC27F62E8F003C859F /* RoutesView.swift */, + E2E47CE027F62E8F003C859F /* Storage.swift */, + E2E47CDF27F62E8F003C859F /* WaypointsEditor.swift */, + E2E47CEE27F6EF7D003C859F /* InfoButton.swift */, + ); + path = Sources; + sourceTree = ""; + }; + E2E47CE927F62EB7003C859F /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + E2E47CB927F62E05003C859F /* DirectionsExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = E2E47CC827F62E06003C859F /* Build configuration list for PBXNativeTarget "DirectionsExample" */; + buildPhases = ( + E2E47CB627F62E05003C859F /* Sources */, + E2E47CB727F62E05003C859F /* Frameworks */, + E2E47CB827F62E05003C859F /* Resources */, + E2E47CEC27F62F0D003C859F /* Apply Mapbox Access Token */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = DirectionsExample; + packageProductDependencies = ( + E2E47CEA27F62EB7003C859F /* MapboxDirections */, + ); + productName = DirectionsPlayground; + productReference = E2E47CBA27F62E05003C859F /* DirectionsExample.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + E2E47CB227F62E05003C859F /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1330; + LastUpgradeCheck = 1330; + TargetAttributes = { + E2E47CB927F62E05003C859F = { + CreatedOnToolsVersion = 13.3; + LastSwiftMigration = 1330; + }; + }; + }; + buildConfigurationList = E2E47CB527F62E05003C859F /* Build configuration list for PBXProject "DirectionsExample" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = E2E47CB127F62E05003C859F; + productRefGroup = E2E47CBB27F62E05003C859F /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + E2E47CB927F62E05003C859F /* DirectionsExample */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + E2E47CB827F62E05003C859F /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E2E47CC527F62E06003C859F /* Preview Assets.xcassets in Resources */, + E2E47CC227F62E06003C859F /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + E2E47CEC27F62F0D003C859F /* Apply Mapbox Access Token */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + ); + inputPaths = ( + "$(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)", + ); + name = "Apply Mapbox Access Token"; + outputFileListPaths = ( + ); + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "# Look for a global file named 'mapbox' or '.mapbox' within the home directory\ntoken_file=~/.mapbox\ntoken_file2=~/mapbox\ntoken=\"$(cat $token_file 2>/dev/null || cat $token_file2 2>/dev/null)\"\nif [ \"$token\" ]; then\n plutil -replace MGLMapboxAccessToken -string $token \"$TARGET_BUILD_DIR/$INFOPLIST_PATH\"\nelse\n echo 'warning: Missing Mapbox access token'\n open 'https://account.mapbox.com/access-tokens/'\n echo \"warning: Get an access token from , then create a new file at $token_file or $token_file2 that contains the access token.\"\nfi\n"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + E2E47CB627F62E05003C859F /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + E2E47CE527F62E8F003C859F /* QueryEditor.swift in Sources */, + E2E47CE727F62E8F003C859F /* Storage.swift in Sources */, + E2E47CE427F62E8F003C859F /* Query.swift in Sources */, + E2E47CEF27F6EF7D003C859F /* InfoButton.swift in Sources */, + E2E47CE227F62E8F003C859F /* DirectionsExample.swift in Sources */, + E2E47CE327F62E8F003C859F /* RoutesView.swift in Sources */, + E2E47CE127F62E8F003C859F /* QueriesList.swift in Sources */, + E2E47CE627F62E8F003C859F /* WaypointsEditor.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + E2E47CC627F62E06003C859F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.4; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + E2E47CC727F62E06003C859F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + 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_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.4; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + E2E47CC927F62E06003C859F /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = DirectionsExample/DirectionsExample.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"DirectionsExample/Preview Content\""; + DEVELOPMENT_TEAM = GJZR2MEM28; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = mapbox.DirectionsExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,6"; + }; + name = Debug; + }; + E2E47CCA27F62E06003C859F /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CLANG_ENABLE_MODULES = YES; + CODE_SIGN_ENTITLEMENTS = DirectionsExample/DirectionsExample.entitlements; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"DirectionsExample/Preview Content\""; + DEVELOPMENT_TEAM = GJZR2MEM28; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = mapbox.DirectionsExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = YES; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2,6"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + E2E47CB527F62E05003C859F /* Build configuration list for PBXProject "DirectionsExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E2E47CC627F62E06003C859F /* Debug */, + E2E47CC727F62E06003C859F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + E2E47CC827F62E06003C859F /* Build configuration list for PBXNativeTarget "DirectionsExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + E2E47CC927F62E06003C859F /* Debug */, + E2E47CCA27F62E06003C859F /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + E2E47CEA27F62EB7003C859F /* MapboxDirections */ = { + isa = XCSwiftPackageProductDependency; + productName = MapboxDirections; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = E2E47CB227F62E05003C859F /* Project object */; +} diff --git a/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000..919434a62 --- /dev/null +++ b/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 000000000..18d981003 --- /dev/null +++ b/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved new file mode 100644 index 000000000..6ddc00467 --- /dev/null +++ b/DirectionsExample/DirectionsExample.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -0,0 +1,43 @@ +{ + "object": { + "pins": [ + { + "package": "OHHTTPStubs", + "repositoryURL": "https://github.com/AliSoftware/OHHTTPStubs", + "state": { + "branch": null, + "revision": "12f19662426d0434d6c330c6974d53e2eb10ecd9", + "version": "9.1.0" + } + }, + { + "package": "Polyline", + "repositoryURL": "https://github.com/raphaelmor/Polyline.git", + "state": { + "branch": null, + "revision": "554a15b15ff33cf6757f4cb693c5c285fe58694e", + "version": "5.0.3" + } + }, + { + "package": "swift-argument-parser", + "repositoryURL": "https://github.com/apple/swift-argument-parser", + "state": { + "branch": null, + "revision": "82905286cc3f0fa8adc4674bf49437cab65a8373", + "version": "1.1.1" + } + }, + { + "package": "Turf", + "repositoryURL": "https://github.com/mapbox/turf-swift.git", + "state": { + "branch": null, + "revision": "87b5b37108ba9f37f0885b586d8f6355d8240dd8", + "version": "2.6.1" + } + } + ] + }, + "version": 1 +} diff --git a/MapboxDirections.xcodeproj/xcshareddata/xcschemes/Example.xcscheme b/DirectionsExample/DirectionsExample.xcodeproj/xcshareddata/xcschemes/DirectionsExample.xcscheme similarity index 59% rename from MapboxDirections.xcodeproj/xcshareddata/xcschemes/Example.xcscheme rename to DirectionsExample/DirectionsExample.xcodeproj/xcshareddata/xcschemes/DirectionsExample.xcscheme index f5613f9ca..9e1920e3e 100644 --- a/MapboxDirections.xcodeproj/xcshareddata/xcschemes/Example.xcscheme +++ b/DirectionsExample/DirectionsExample.xcodeproj/xcshareddata/xcschemes/DirectionsExample.xcscheme @@ -1,6 +1,6 @@ + BlueprintIdentifier = "E2E47CB927F62E05003C859F" + BuildableName = "DirectionsExample.app" + BlueprintName = "DirectionsExample" + ReferencedContainer = "container:DirectionsExample.xcodeproj"> @@ -27,26 +27,7 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES"> - - - - - - - - + BlueprintIdentifier = "E2E47CB927F62E05003C859F" + BuildableName = "DirectionsExample.app" + BlueprintName = "DirectionsExample" + ReferencedContainer = "container:DirectionsExample.xcodeproj"> @@ -80,10 +61,10 @@ runnableDebuggingMode = "0"> + BlueprintIdentifier = "E2E47CB927F62E05003C859F" + BuildableName = "DirectionsExample.app" + BlueprintName = "DirectionsExample" + ReferencedContainer = "container:DirectionsExample.xcodeproj"> diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AccentColor.colorset/Contents.json b/DirectionsExample/DirectionsExample/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 000000000..611286920 --- /dev/null +++ b/DirectionsExample/DirectionsExample/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,15 @@ +{ + "colors" : [ + { + "color" : { + "platform" : "universal", + "reference" : "systemBlueColor" + }, + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/AppStore.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/AppStore.png new file mode 100644 index 000000000..9d420aec4 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/AppStore.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/CarPlay@2x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/CarPlay@2x.png new file mode 100644 index 000000000..4d00bf751 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/CarPlay@2x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/CarPlay@3x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/CarPlay@3x.png new file mode 100644 index 000000000..8b78c4328 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/CarPlay@3x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000..42be50245 --- /dev/null +++ b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,128 @@ +{ + "images" : [ + { + "filename" : "iPhone-Notification@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "20x20" + }, + { + "filename" : "iPhone-Notification@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "20x20" + }, + { + "filename" : "iPhone@2x.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "29x29" + }, + { + "filename" : "iPhone@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "29x29" + }, + { + "filename" : "iPhone-Spotlight.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "40x40" + }, + { + "filename" : "iPhone-Spotlight@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "40x40" + }, + { + "filename" : "iPhone-App.png", + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "filename" : "iPhone-App@3x.png", + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "filename" : "iPad-Notifications.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "20x20" + }, + { + "filename" : "iPad-Notifications@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "20x20" + }, + { + "filename" : "iPad-Settings.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "29x29" + }, + { + "filename" : "iPad-Settings@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "29x29" + }, + { + "filename" : "iPad-Spotlight.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "40x40" + }, + { + "filename" : "iPad-Spotlight@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "40x40" + }, + { + "filename" : "iPad-App.png", + "idiom" : "ipad", + "scale" : "1x", + "size" : "76x76" + }, + { + "filename" : "iPad-App@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "76x76" + }, + { + "filename" : "iPadPro-App@2x.png", + "idiom" : "ipad", + "scale" : "2x", + "size" : "83.5x83.5" + }, + { + "filename" : "CarPlay@2x.png", + "idiom" : "car", + "scale" : "2x", + "size" : "60x60" + }, + { + "filename" : "CarPlay@3x.png", + "idiom" : "car", + "scale" : "3x", + "size" : "60x60" + }, + { + "filename" : "AppStore.png", + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-App.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-App.png new file mode 100644 index 000000000..4eaf320bf Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-App.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-App@2x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-App@2x.png new file mode 100644 index 000000000..82e195fd9 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-App@2x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Notifications.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Notifications.png new file mode 100644 index 000000000..25afc63c4 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Notifications.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Notifications@2x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Notifications@2x.png new file mode 100644 index 000000000..73adc93e0 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Notifications@2x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Settings.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Settings.png new file mode 100644 index 000000000..abd389902 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Settings.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Settings@2x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Settings@2x.png new file mode 100644 index 000000000..3e7c9c3cd Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Settings@2x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Spotlight.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Spotlight.png new file mode 100644 index 000000000..73adc93e0 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Spotlight.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Spotlight@2x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Spotlight@2x.png new file mode 100644 index 000000000..19fb06ae8 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPad-Spotlight@2x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPadPro-App@2x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPadPro-App@2x.png new file mode 100644 index 000000000..e3a1aec8c Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPadPro-App@2x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-App.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-App.png new file mode 100644 index 000000000..4d00bf751 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-App.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-App@3x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-App@3x.png new file mode 100644 index 000000000..8b78c4328 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-App@3x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Notification@2x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Notification@2x.png new file mode 100644 index 000000000..73adc93e0 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Notification@2x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Notification@3x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Notification@3x.png new file mode 100644 index 000000000..dd8288a31 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Notification@3x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Spotlight.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Spotlight.png new file mode 100644 index 000000000..19fb06ae8 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Spotlight.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Spotlight@3x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Spotlight@3x.png new file mode 100644 index 000000000..4d00bf751 Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone-Spotlight@3x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone@2x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone@2x.png new file mode 100644 index 000000000..3e7c9c3cd Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone@2x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone@3x.png b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone@3x.png new file mode 100644 index 000000000..36a441a7e Binary files /dev/null and b/DirectionsExample/DirectionsExample/Assets.xcassets/AppIcon.appiconset/iPhone@3x.png differ diff --git a/DirectionsExample/DirectionsExample/Assets.xcassets/Contents.json b/DirectionsExample/DirectionsExample/Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/DirectionsExample/DirectionsExample/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DirectionsExample/DirectionsExample/DirectionsExample.entitlements b/DirectionsExample/DirectionsExample/DirectionsExample.entitlements new file mode 100644 index 000000000..ee95ab7e5 --- /dev/null +++ b/DirectionsExample/DirectionsExample/DirectionsExample.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.app-sandbox + + com.apple.security.network.client + + + diff --git a/DirectionsExample/DirectionsExample/Preview Content/Preview Assets.xcassets/Contents.json b/DirectionsExample/DirectionsExample/Preview Content/Preview Assets.xcassets/Contents.json new file mode 100644 index 000000000..73c00596a --- /dev/null +++ b/DirectionsExample/DirectionsExample/Preview Content/Preview Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/DirectionsExample/DirectionsExample/Sources/DirectionsExample.swift b/DirectionsExample/DirectionsExample/Sources/DirectionsExample.swift new file mode 100644 index 000000000..209ab9a90 --- /dev/null +++ b/DirectionsExample/DirectionsExample/Sources/DirectionsExample.swift @@ -0,0 +1,13 @@ +import SwiftUI + +@main +struct DirectionsExample: App { + var body: some Scene { + WindowGroup { + NavigationView { + QueriesList() + } + .navigationViewStyle(.stack) + } + } +} diff --git a/DirectionsExample/DirectionsExample/Sources/InfoButton.swift b/DirectionsExample/DirectionsExample/Sources/InfoButton.swift new file mode 100644 index 000000000..f438b8da8 --- /dev/null +++ b/DirectionsExample/DirectionsExample/Sources/InfoButton.swift @@ -0,0 +1,38 @@ +import SwiftUI + +struct InfoButton: View { + enum DocUrl { + case waypointAllowsSnappingToClosedRoad + case waypointAllowsArrivingOnOppositeSide + case separatesLegs + } + + let docUrl: DocUrl + @Environment(\.openURL) var openURL + + var body: some View { + Button { + openURL(docUrl.url) + } label: { + Image(systemName: "info.circle") + } + .buttonStyle(.bordered) + } +} + +extension InfoButton.DocUrl { + var urlString: String { + switch self { + case .waypointAllowsArrivingOnOppositeSide: + return "https://docs.mapbox.com/ios/directions/api/2.3.0/Classes/Waypoint.html#/s:16MapboxDirections8WaypointC28allowsArrivingOnOppositeSideSbvp" + case .waypointAllowsSnappingToClosedRoad: + return "https://docs.mapbox.com/ios/directions/api/2.3.0/Classes/Waypoint.html#/s:16MapboxDirections8WaypointC26allowsSnappingToClosedRoadSbvp" + case .separatesLegs: + return "https://docs.mapbox.com/ios/directions/api/2.3.0/Classes/Waypoint.html#/s:16MapboxDirections8WaypointC13separatesLegsSbvp" + } + } + + var url: URL { + URL(string: urlString)! + } +} diff --git a/DirectionsExample/DirectionsExample/Sources/QueriesList.swift b/DirectionsExample/DirectionsExample/Sources/QueriesList.swift new file mode 100644 index 000000000..28d5403bf --- /dev/null +++ b/DirectionsExample/DirectionsExample/Sources/QueriesList.swift @@ -0,0 +1,61 @@ +import Foundation +import SwiftUI + +struct QueriesList: View { + @State + var queries: [Query] = [] { + didSet { saveQueries() } + } + + var body: some View { + List { + ForEach($queries) { $query in + NavigationLink( + destination: QueryEditor(query: $query), + label: { + TextField("Query Name", text: $query.name) + }) + } + .onMove { indices, newOffset in + queries.move(fromOffsets: indices, toOffset: newOffset) + } + .onDelete { indexSet in + queries.remove(atOffsets: indexSet) + } + } + .onAppear { loadQueries() } + .toolbar { + ToolbarItem(placement: .primaryAction) { + Button { newQuery() } + label: { Image(systemName: "plus") } + } + ToolbarItem(placement: ToolbarItemPlacement.automatic) { + EditButton() + } + } + .navigationTitle("Saved Queries") + } + + private func loadQueries() { + do { + queries = try Storage.shared.load() ?? [.default] + } + catch { + print(error) + } + } + + private func newQuery() { + let newQuery = Query.make() + queries.append(newQuery) + } + + private func saveQueries() { + do { + try Storage.shared.save(queries) + } + catch { + print(error) + } + } +} diff --git a/DirectionsExample/DirectionsExample/Sources/Query.swift b/DirectionsExample/DirectionsExample/Sources/Query.swift new file mode 100644 index 000000000..d0597084d --- /dev/null +++ b/DirectionsExample/DirectionsExample/Sources/Query.swift @@ -0,0 +1,16 @@ +import Foundation + +struct Query: Codable, Identifiable { + let id: String + var name: String + var waypoints: [Waypoint] + + static func make() -> Query { + let uuid = UUID().uuidString + return .init(id: uuid, name: "New Query", waypoints: .defaultWaypoints) + } + + static var `default`: Query { + .init(id: UUID().uuidString, name: "Mapbox Office", waypoints: .defaultWaypoints) + } +} diff --git a/DirectionsExample/DirectionsExample/Sources/QueryEditor.swift b/DirectionsExample/DirectionsExample/Sources/QueryEditor.swift new file mode 100644 index 000000000..4dec2ad53 --- /dev/null +++ b/DirectionsExample/DirectionsExample/Sources/QueryEditor.swift @@ -0,0 +1,67 @@ +import Foundation +import SwiftUI +import Combine +import MapboxDirections + +struct QueryEditor: View { + @State var routes: [Route] = [] { + didSet { + showRoutes = !routes.isEmpty + } + } + @State var error: DirectionsError? + @State var showRoutes: Bool = false + @Binding var query: Query + + var body: some View { + VStack { + WaypointsEditor(waypoints: $query.waypoints) + .toolbar(content: { + ToolbarItem(placement: ToolbarItemPlacement.navigationBarTrailing) { + NavigationLink( + destination: RoutesView(routes: routes), + isActive: $showRoutes, + label: { + Button("Directions") { + loadRoutes(for: query) + }.buttonStyle(.borderless) + }) + } + }) + .navigationTitle(query.name) + + } + .alert(isPresented: .constant(error != nil), error: error) { + Button("Ok") { + error = nil + } + } + } + + func loadRoutes(for query: Query) { + let options = RouteOptions(waypoints: query.waypoints.map(\.native)) + print("Calculating route for \(options.waypoints)") + options.includesSteps = true + options.routeShapeResolution = .full + options.attributeOptions = [.congestionLevel, .maximumSpeedLimit] + + Directions.shared.calculate(options) { (session, result) in + switch result { + case let .failure(error): + self.error = error + case let .success(response): + self.routes = response.routes ?? [] + } + } + } +} + +extension Array where Element == Waypoint { + static var defaultWaypoints: Self { + [ + .init(id: .init(), latitude: 38.9131752, longitude: -77.0324047, name: "Mapbox"), + .init(id: .init(), latitude: 38.8906572, longitude: -77.0090701, name: "Capitol"), + .init(id: .init(), latitude: 38.8977000, longitude: -77.0365000, name: "White House"), + ] + } +} diff --git a/Directions Example/ContentView.swift b/DirectionsExample/DirectionsExample/Sources/RoutesView.swift similarity index 56% rename from Directions Example/ContentView.swift rename to DirectionsExample/DirectionsExample/Sources/RoutesView.swift index d8612c6da..272183bfb 100644 --- a/Directions Example/ContentView.swift +++ b/DirectionsExample/DirectionsExample/Sources/RoutesView.swift @@ -1,79 +1,21 @@ import Foundation import SwiftUI -import Combine import MapboxDirections -final class DirectionsViewModel: ObservableObject { - private let distanceFormatter: LengthFormatter = .init() - private let travelTimeFormatter: DateComponentsFormatter = .init() +struct RoutesView: View { + private static let distanceFormatter: LengthFormatter = .init() + private static let travelTimeFormatter: DateComponentsFormatter = { + let f = DateComponentsFormatter() + f.unitsStyle = .short + return f + }() - @Published - var routes: [Route] = [] - - init() { - travelTimeFormatter.unitsStyle = .short - } - - func loadRoutes() { - let startPoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.9131752, longitude: -77.0324047), - name: "Mapbox") - let stopPoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.89065720, longitude: -77.0090701), - name: "Capitol") - let endPoint = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), - name: "White House") - let options = RouteOptions(waypoints: [startPoint, stopPoint, endPoint]) - options.includesSteps = true - options.routeShapeResolution = .full - options.attributeOptions = [.congestionLevel, .maximumSpeedLimit] - - Directions.shared.calculate(options) { (session, result) in - switch result { - case let .failure(error): - print("Error calculating directions: \(error)") - case let .success(response): - self.routes = response.routes ?? [] - } - } - } - - func formattedDistance(for route: Route) -> String { - return distanceFormatter.string(fromMeters: route.distance) - } - - func formattedTravelTime(for route: Route) -> String { - return travelTimeFormatter.string(from: route.expectedTravelTime)! - } - - func formattedTypicalTravelTime(for route: Route) -> String { - if let typicalTravelTime = route.typicalTravelTime, - let formattedTypicalTravelTime = travelTimeFormatter.string(from: typicalTravelTime) { - return formattedTypicalTravelTime - } - else { - return "Not available" - } - } - - func stepDescriptions(for step: RouteStep) -> String { - var description: String = "" - let direction = step.maneuverDirection?.rawValue ?? "none" - description.append("\(step.instructions) [\(step.maneuverType) \(direction)]") - if step.distance > 0 { - let formattedDistance = distanceFormatter.string(fromMeters: step.distance) - description.append(" (\(step.transportType) for \(formattedDistance))") - } - return description - } -} - -struct ContentView: View { - @ObservedObject - var vm: DirectionsViewModel + let routes: [Route] var body: some View { ScrollView { LazyVStack(spacing: 10, content: { - ForEach(vm.routes, id: \.distance) { route in + ForEach(routes, id: \.distance) { route in VStack(alignment: .leading, spacing: 3) { headerView(for: route) ForEach(0.. String { + return Self.distanceFormatter.string(fromMeters: route.distance) + } + + func formattedTravelTime(for route: Route) -> String { + return Self.travelTimeFormatter.string(from: route.expectedTravelTime)! + } + + func formattedTypicalTravelTime(for route: Route) -> String { + if let typicalTravelTime = route.typicalTravelTime, + let formattedTypicalTravelTime = Self.travelTimeFormatter.string(from: typicalTravelTime) { + return formattedTypicalTravelTime + } + else { + return "Not available" + } + } + + func stepDescriptions(for step: RouteStep) -> String { + var description: String = "" + let direction = step.maneuverDirection?.rawValue ?? "none" + description.append("\(step.instructions) [\(step.maneuverType) \(direction)]") + if step.distance > 0 { + let formattedDistance = Self.distanceFormatter.string(fromMeters: step.distance) + description.append(" (\(step.transportType) for \(formattedDistance))") + } + return description + } } diff --git a/DirectionsExample/DirectionsExample/Sources/Storage.swift b/DirectionsExample/DirectionsExample/Sources/Storage.swift new file mode 100644 index 000000000..061816c33 --- /dev/null +++ b/DirectionsExample/DirectionsExample/Sources/Storage.swift @@ -0,0 +1,22 @@ +import Foundation + +final class Storage { + static let shared: Storage = .init() + + private enum K { + static let saveKey: String = "mapbox-directions-queries" + } + + func save(_ queries: [Query]) throws { + let coder = JSONEncoder() + let data = try coder.encode(queries) + UserDefaults.standard.setValue(data, forKey: K.saveKey) + } + + func load() throws -> [Query]? { + let decoder = JSONDecoder() + return try UserDefaults.standard.data(forKey: K.saveKey).map { + try decoder.decode([Query].self, from: $0) + } + } +} diff --git a/DirectionsExample/DirectionsExample/Sources/WaypointsEditor.swift b/DirectionsExample/DirectionsExample/Sources/WaypointsEditor.swift new file mode 100644 index 000000000..749269335 --- /dev/null +++ b/DirectionsExample/DirectionsExample/Sources/WaypointsEditor.swift @@ -0,0 +1,119 @@ +import Foundation +import SwiftUI +import CoreLocation +import MapboxDirections + +struct Waypoint: Identifiable, Hashable, Codable { + let id: UUID + var latitude: CLLocationDegrees = 0 + var longitude: CLLocationDegrees = 0 + var name: String = "" + var allowsSnappingToClosedRoad: Bool = false + var allowsArrivingOnOppositeSide: Bool = false + var separatesLegs: Bool = true + + var native: MapboxDirections.Waypoint { + let waypoint = MapboxDirections.Waypoint(coordinate: .init(latitude: latitude, longitude: longitude), name: name) + waypoint.allowsSnappingToClosedRoad = allowsSnappingToClosedRoad + waypoint.allowsArrivingOnOppositeSide = allowsArrivingOnOppositeSide + waypoint.separatesLegs = separatesLegs + return waypoint + } + + static func make() -> Waypoint { + .init(id: .init()) + } +} + +struct WaypointsEditor: View { + @Binding + var waypoints: [Waypoint] + + var body: some View { + List { + ForEach($waypoints) { $waypoint in + HStack(alignment: .top) { + WaypointView(waypoint: $waypoint) + + Menu { + Button("Insert Above") { + addNewWaypoint(before: waypoint) + } + Button("Insert Below") { + addNewWaypoint(after: waypoint) + } + } label: { + Image(systemName: "ellipsis") + .frame(width: 30, height: 30, alignment: .center) + }.menuStyle(.borderlessButton) + } + } + .onMove { indices, newOffset in + waypoints.move(fromOffsets: indices, toOffset: newOffset) + } + .onDelete { indexSet in + waypoints.remove(atOffsets: indexSet) + } + } + .listStyle(InsetGroupedListStyle()) + .toolbar { + ToolbarItem(placement: ToolbarItemPlacement.automatic) { + EditButton() + } + } + } + + private func addNewWaypoint(after waypoint: Waypoint) { + guard let waypointIndex = waypoints.firstIndex(of: waypoint) else { + preconditionFailure("Waypoint is in the array of waypoints") + } + let insertionIndex = waypoints.index(after: waypointIndex) + waypoints.insert(Waypoint.make(), at: insertionIndex) + } + private func addNewWaypoint(before waypoint: Waypoint) { + guard let insertionIndex = waypoints.firstIndex(of: waypoint) else { + preconditionFailure("Waypoint is in the array of waypoints") + } + waypoints.insert(Waypoint.make(), at: insertionIndex) + } +} + +struct WaypointView: View { + @Binding var waypoint: Waypoint + @State private var latitudeString: String + @State private var longitudeString: String + + init(waypoint: Binding) { + _waypoint = waypoint + _latitudeString = .init(initialValue: waypoint.wrappedValue.latitude.description) + _longitudeString = .init(initialValue: waypoint.wrappedValue.longitude.description) + } + + var body: some View { + VStack(alignment: .leading) { + TextField("Name", text: $waypoint.name) + HStack { + TextField("Lat", text: $latitudeString, onEditingChanged: { _ in + waypoint.latitude = .init(latitudeString) ?? 0 + }) + .fixedSize() + TextField("Lon", text: $longitudeString, onEditingChanged: { _ in + waypoint.longitude = .init(longitudeString) ?? 0 + }) + .fixedSize() + } + HStack { + InfoButton(docUrl: .separatesLegs) + Toggle("Separates Legs", isOn: $waypoint.separatesLegs) + } + HStack { + InfoButton(docUrl: .waypointAllowsSnappingToClosedRoad) + Toggle("Snap To Closed Road", isOn: $waypoint.allowsArrivingOnOppositeSide) + } + HStack { + InfoButton(docUrl: .waypointAllowsArrivingOnOppositeSide) + Toggle("Allows Arriving On Opposite Side", isOn: $waypoint.allowsSnappingToClosedRoad) + } + } + } +} diff --git a/DirectionsExample/README.md b/DirectionsExample/README.md new file mode 100644 index 000000000..c121865a8 --- /dev/null +++ b/DirectionsExample/README.md @@ -0,0 +1,8 @@ +# Directions Example + +Shows how to obtain directions using "MapboxDirection" library. + +## Requirements + +- Xcode 13.3 +- iOS 15 diff --git a/MapboxDirections.xcodeproj/project.pbxproj b/MapboxDirections.xcodeproj/project.pbxproj index 4afe05402..6db159c63 100644 --- a/MapboxDirections.xcodeproj/project.pbxproj +++ b/MapboxDirections.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 54; + objectVersion = 52; objects = { /* Begin PBXBuildFile section */ @@ -377,9 +377,6 @@ DAD31BC324D4ADBF00A1654D /* match-polyline6.json in Resources */ = {isa = PBXBuildFile; fileRef = DAD31BC224D4A8D100A1654D /* match-polyline6.json */; }; DAD31BC424D4ADBF00A1654D /* match-polyline6.json in Resources */ = {isa = PBXBuildFile; fileRef = DAD31BC224D4A8D100A1654D /* match-polyline6.json */; }; DAD31BC524D4ADC000A1654D /* match-polyline6.json in Resources */ = {isa = PBXBuildFile; fileRef = DAD31BC224D4A8D100A1654D /* match-polyline6.json */; }; - DADD27B81E5AAAD800D31FAD /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = DADD27B71E5AAAD800D31FAD /* AppDelegate.swift */; }; - DADD27BF1E5AAAD800D31FAD /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = DADD27BE1E5AAAD800D31FAD /* Assets.xcassets */; }; - DADD27C81E5AAE3100D31FAD /* Launch Screen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DADD27C71E5AAE3100D31FAD /* Launch Screen.storyboard */; }; DAE2DF6823AECB120065057A /* QuickLookTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAE2DF6723AECB120065057A /* QuickLookTests.swift */; }; DAE2DF6923AECB120065057A /* QuickLookTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAE2DF6723AECB120065057A /* QuickLookTests.swift */; }; DAE2DF6A23AECB120065057A /* QuickLookTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAE2DF6723AECB120065057A /* QuickLookTests.swift */; }; @@ -396,13 +393,9 @@ DAE9E0F41EB7DE2E001E8E8B /* RouteOptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAE9E0F31EB7DE2E001E8E8B /* RouteOptionsTests.swift */; }; DAE9E0F51EB7DE2E001E8E8B /* RouteOptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAE9E0F31EB7DE2E001E8E8B /* RouteOptionsTests.swift */; }; DAE9E0F61EB7DE2E001E8E8B /* RouteOptionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = DAE9E0F31EB7DE2E001E8E8B /* RouteOptionsTests.swift */; }; - DAF08AAB25C0E96E00ABA8F3 /* MapboxDirections.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA6C9D881CAE442B00094FBC /* MapboxDirections.framework */; }; - DAF08AAC25C0E96E00ABA8F3 /* MapboxDirections.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA6C9D881CAE442B00094FBC /* MapboxDirections.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; E232F8A8266513E90038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; E232F8A9266513EE0038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; E232F8AA266513F10038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; - E232F8AC266513FF0038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; - E232F8AD266513FF0038CAF3 /* Polyline.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; E232F8B2266516640038CAF3 /* Turf.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F8AE2665141F0038CAF3 /* Turf.xcframework */; }; E232F8B32665166D0038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; E232F8B4266516950038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; @@ -418,7 +411,6 @@ E232F8C52665173C0038CAF3 /* MapboxDirections.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA1A10AF1D00F8FF009F82FA /* MapboxDirections.framework */; }; E232F8C62665173C0038CAF3 /* MapboxDirections.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = DA1A10AF1D00F8FF009F82FA /* MapboxDirections.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; E232F8C9266518480038CAF3 /* Polyline.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E232F899266513C20038CAF3 /* Polyline.xcframework */; }; - E28E325826662B1E0030807F /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E28E325726662B1E0030807F /* ContentView.swift */; }; F457FA7A252B9E29007DAEB1 /* Incident.swift in Sources */ = {isa = PBXBuildFile; fileRef = F457FA79252B9E29007DAEB1 /* Incident.swift */; }; F457FA7B252B9E29007DAEB1 /* Incident.swift in Sources */ = {isa = PBXBuildFile; fileRef = F457FA79252B9E29007DAEB1 /* Incident.swift */; }; F457FA7C252B9E29007DAEB1 /* Incident.swift in Sources */ = {isa = PBXBuildFile; fileRef = F457FA79252B9E29007DAEB1 /* Incident.swift */; }; @@ -469,13 +461,6 @@ remoteGlobalIDString = DA6C9D871CAE442B00094FBC; remoteInfo = MapboxDirections; }; - DADD27F91E5AC8E900D31FAD /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = DD6254461AE70C1700017857 /* Project object */; - proxyType = 1; - remoteGlobalIDString = DA6C9D871CAE442B00094FBC; - remoteInfo = MapboxDirections; - }; E232F8C72665173C0038CAF3 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = DD6254461AE70C1700017857 /* Project object */; @@ -506,18 +491,6 @@ ); runOnlyForDeploymentPostprocessing = 1; }; - DAF08AAD25C0E96E00ABA8F3 /* Embed Frameworks */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = ""; - dstSubfolderSpec = 10; - files = ( - DAF08AAC25C0E96E00ABA8F3 /* MapboxDirections.framework in Embed Frameworks */, - E232F8AD266513FF0038CAF3 /* Polyline.xcframework in Embed Frameworks */, - ); - name = "Embed Frameworks"; - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ @@ -641,11 +614,6 @@ DAD06E34239F0B19001A917D /* DirectionsErrorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectionsErrorTests.swift; sourceTree = ""; }; DAD06E3823A008EB001A917D /* QuickLook.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickLook.swift; sourceTree = ""; }; DAD31BC224D4A8D100A1654D /* match-polyline6.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = "match-polyline6.json"; sourceTree = ""; }; - DADD27B51E5AAAD800D31FAD /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; - DADD27B71E5AAAD800D31FAD /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; - DADD27BE1E5AAAD800D31FAD /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - DADD27C31E5AAAD800D31FAD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - DADD27C71E5AAE3100D31FAD /* Launch Screen.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = "Launch Screen.storyboard"; sourceTree = ""; }; DAE2DF6723AECB120065057A /* QuickLookTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuickLookTests.swift; sourceTree = ""; }; DAE2DF6B23AED2280065057A /* RouteTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RouteTests.swift; sourceTree = ""; }; DAE33A1A1F215DF600C06039 /* IntersectionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = IntersectionTests.swift; sourceTree = ""; }; @@ -655,7 +623,6 @@ E232F899266513C20038CAF3 /* Polyline.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Polyline.xcframework; path = Carthage/Build/Polyline.xcframework; sourceTree = ""; }; E232F8AE2665141F0038CAF3 /* Turf.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Turf.xcframework; path = Carthage/Build/Turf.xcframework; sourceTree = ""; }; E232F8BA266516D70038CAF3 /* OHHTTPStubs.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = OHHTTPStubs.xcframework; path = Carthage/Build/OHHTTPStubs.xcframework; sourceTree = ""; }; - E28E325726662B1E0030807F /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; F457FA79252B9E29007DAEB1 /* Incident.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Incident.swift; sourceTree = ""; }; F4CF2C562523B66300A6D0B6 /* TollCollection.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TollCollection.swift; sourceTree = ""; }; F4D785EE1DDD82C100FF4665 /* RouteStepTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RouteStepTests.swift; sourceTree = ""; }; @@ -728,15 +695,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - DADD27B21E5AAAD800D31FAD /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - DAF08AAB25C0E96E00ABA8F3 /* MapboxDirections.framework in Frameworks */, - E232F8AC266513FF0038CAF3 /* Polyline.xcframework in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; E05B24A0DFB05E8378736C51 /* Frameworks */ = { isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; @@ -993,31 +951,10 @@ path = v5; sourceTree = ""; }; - DADD27B61E5AAAD800D31FAD /* Directions Example */ = { - isa = PBXGroup; - children = ( - DADD27B71E5AAAD800D31FAD /* AppDelegate.swift */, - E28E325726662B1E0030807F /* ContentView.swift */, - DADD27CB1E5AAF5600D31FAD /* Supporting Files */, - ); - path = "Directions Example"; - sourceTree = ""; - }; - DADD27CB1E5AAF5600D31FAD /* Supporting Files */ = { - isa = PBXGroup; - children = ( - DADD27BE1E5AAAD800D31FAD /* Assets.xcassets */, - DADD27C71E5AAE3100D31FAD /* Launch Screen.storyboard */, - DADD27C31E5AAAD800D31FAD /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; DD6254451AE70C1700017857 = { isa = PBXGroup; children = ( 438BFEBF233D804600457294 /* Documents */, - DADD27B61E5AAAD800D31FAD /* Directions Example */, DA6C9D891CAE442B00094FBC /* MapboxDirections */, 2B4382FF2549C1D200A3E38B /* MapboxDirectionsCLI */, DA6C9D971CAE442B00094FBC /* MapboxDirectionsTests */, @@ -1036,7 +973,6 @@ DA1A10D51D0101ED009F82FA /* MapboxDirections.framework */, DA1A10DE1D0101ED009F82FA /* MapboxDirectionsTests.xctest */, DA1A10FB1D010361009F82FA /* MapboxDirections.framework */, - DADD27B51E5AAAD800D31FAD /* Example.app */, 2BA98970253F007600B643F6 /* mapbox-directions-swift */, ); name = Products; @@ -1226,26 +1162,6 @@ productReference = DA6C9D911CAE442B00094FBC /* MapboxDirectionsTests.xctest */; productType = "com.apple.product-type.bundle.unit-test"; }; - DADD27B41E5AAAD800D31FAD /* Example */ = { - isa = PBXNativeTarget; - buildConfigurationList = DADD27C61E5AAAD800D31FAD /* Build configuration list for PBXNativeTarget "Example" */; - buildPhases = ( - DADD27B11E5AAAD800D31FAD /* Sources */, - DADD27B21E5AAAD800D31FAD /* Frameworks */, - DADD27B31E5AAAD800D31FAD /* Resources */, - DA3DFB08236973E9003AE57F /* Apply Mapbox Access Token */, - DAF08AAD25C0E96E00ABA8F3 /* Embed Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - DADD27FA1E5AC8E900D31FAD /* PBXTargetDependency */, - ); - name = Example; - productName = "Directions Example"; - productReference = DADD27B51E5AAAD800D31FAD /* Example.app */; - productType = "com.apple.product-type.application"; - }; /* End PBXNativeTarget section */ /* Begin PBXProject section */ @@ -1290,11 +1206,6 @@ CreatedOnToolsVersion = 7.3; LastSwiftMigration = 1100; }; - DADD27B41E5AAAD800D31FAD = { - CreatedOnToolsVersion = 8.2.1; - LastSwiftMigration = 1100; - ProvisioningStyle = Automatic; - }; }; }; buildConfigurationList = DD6254491AE70C1700017857 /* Build configuration list for PBXProject "MapboxDirections" */; @@ -1310,7 +1221,6 @@ projectDirPath = ""; projectRoot = ""; targets = ( - DADD27B41E5AAAD800D31FAD /* Example */, DA6C9D871CAE442B00094FBC /* MapboxDirections */, DA6C9D901CAE442B00094FBC /* MapboxDirectionsTests */, DA1A10AE1D00F8FF009F82FA /* MapboxDirectionsMac */, @@ -1445,40 +1355,8 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - DADD27B31E5AAAD800D31FAD /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - DADD27BF1E5AAAD800D31FAD /* Assets.xcassets in Resources */, - DADD27C81E5AAE3100D31FAD /* Launch Screen.storyboard in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXResourcesBuildPhase section */ -/* Begin PBXShellScriptBuildPhase section */ - DA3DFB08236973E9003AE57F /* Apply Mapbox Access Token */ = { - isa = PBXShellScriptBuildPhase; - alwaysOutOfDate = 1; - buildActionMask = 2147483647; - files = ( - ); - inputFileListPaths = ( - ); - inputPaths = ( - "$(TARGET_BUILD_DIR)/$(INFOPLIST_PATH)", - ); - name = "Apply Mapbox Access Token"; - outputFileListPaths = ( - ); - outputPaths = ( - ); - runOnlyForDeploymentPostprocessing = 0; - shellPath = /bin/sh; - shellScript = "# Look for a global file named 'mapbox' or '.mapbox' within the home directory\ntoken_file=~/.mapbox\ntoken_file2=~/mapbox\ntoken=\"$(cat $token_file 2>/dev/null || cat $token_file2 2>/dev/null)\"\nif [ \"$token\" ]; then\n plutil -replace MGLMapboxAccessToken -string $token \"$TARGET_BUILD_DIR/$INFOPLIST_PATH\"\nelse\n echo 'warning: Missing Mapbox access token'\n open 'https://account.mapbox.com/access-tokens/'\n echo \"warning: Get an access token from , then create a new file at $token_file or $token_file2 that contains the access token.\"\nfi\n"; - }; -/* End PBXShellScriptBuildPhase section */ - /* Begin PBXSourcesBuildPhase section */ 2BA9896C253F007600B643F6 /* Sources */ = { isa = PBXSourcesBuildPhase; @@ -1865,15 +1743,6 @@ ); runOnlyForDeploymentPostprocessing = 0; }; - DADD27B11E5AAAD800D31FAD /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - DADD27B81E5AAAD800D31FAD /* AppDelegate.swift in Sources */, - E28E325826662B1E0030807F /* ContentView.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ @@ -1897,11 +1766,6 @@ target = DA6C9D871CAE442B00094FBC /* MapboxDirections */; targetProxy = DA6C9D931CAE442B00094FBC /* PBXContainerItemProxy */; }; - DADD27FA1E5AC8E900D31FAD /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = DA6C9D871CAE442B00094FBC /* MapboxDirections */; - targetProxy = DADD27F91E5AC8E900D31FAD /* PBXContainerItemProxy */; - }; E232F8C82665173C0038CAF3 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = DA1A10AE1D00F8FF009F82FA /* MapboxDirectionsMac */; @@ -2350,50 +2214,6 @@ }; name = Release; }; - DADD27C41E5AAAD800D31FAD /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ANALYZER_NONNULL = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - DEBUG_INFORMATION_FORMAT = dwarf; - DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = "Directions Example/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Directions; - PRODUCT_MODULE_NAME = DirectionsExampleSwift; - PRODUCT_NAME = Example; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - }; - name = Debug; - }; - DADD27C51E5AAAD800D31FAD /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - CLANG_ANALYZER_NONNULL = YES; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = "$(inherited)"; - INFOPLIST_FILE = "Directions Example/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 14.1; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Directions; - PRODUCT_MODULE_NAME = DirectionsExampleSwift; - PRODUCT_NAME = Example; - SWIFT_SWIFT3_OBJC_INFERENCE = Off; - }; - name = Release; - }; DD62546B1AE70C1700017857 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -2589,15 +2409,6 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Release; }; - DADD27C61E5AAAD800D31FAD /* Build configuration list for PBXNativeTarget "Example" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - DADD27C41E5AAAD800D31FAD /* Debug */, - DADD27C51E5AAAD800D31FAD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; DD6254491AE70C1700017857 /* Build configuration list for PBXProject "MapboxDirections" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/README.md b/README.md index 7d015232b..c4973f469 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Or in your [Swift Package Manager](https://swift.org/package-manager/) Package.s Then `import MapboxDirections`. -This repository contains an example application that demonstrates how to use the framework. To run it, you need to use [Carthage](https://github.com/Carthage/Carthage) 0.19 or above to install the dependencies. Detailed documentation is available in the [Mapbox API Documentation](https://docs.mapbox.com/api/navigation/#directions). +This repository contains an [example application](./DirectionsExample/) that demonstrates how to use the framework. Detailed documentation is available in the [Mapbox API Documentation](https://docs.mapbox.com/api/navigation/#directions). ## System requirements diff --git a/Sources/MapboxDirections/DirectionsError.swift b/Sources/MapboxDirections/DirectionsError.swift index a4de44e34..909e01da8 100644 --- a/Sources/MapboxDirections/DirectionsError.swift +++ b/Sources/MapboxDirections/DirectionsError.swift @@ -110,7 +110,12 @@ public enum DirectionsError: LocalizedError { */ case unknown(response: URLResponse?, underlying: Error?, code: String?, message: String?) - + + public var errorDescription: String? { + guard let failureReason = failureReason else { return nil } + return failureReason.appending(recoverySuggestion ?? "") + } + public var failureReason: String? { switch self { case .network(_):