@baeckerherz/expo-mapbox-navigation 0.1.16 → 0.1.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/ExpoMapboxNavigation.podspec +8 -0
- package/package.json +1 -1
- package/plugin/build/index.js +4 -9
- package/plugin/build/withMapboxNavPodfile.d.ts +16 -4
- package/plugin/build/withMapboxNavPodfile.js +44 -5
- package/plugin/src/index.ts +4 -10
- package/plugin/src/withMapboxNavPodfile.ts +55 -5
|
@@ -23,4 +23,12 @@ Pod::Spec.new do |s|
|
|
|
23
23
|
'DEFINES_MODULE' => 'YES',
|
|
24
24
|
'SWIFT_COMPILATION_MODE' => 'wholemodule',
|
|
25
25
|
}
|
|
26
|
+
|
|
27
|
+
# Mapbox Navigation SDK v3 is SPM-only. The SPM binary xcframeworks are
|
|
28
|
+
# resolved in the Pods project but the app target must link them because
|
|
29
|
+
# this pod is a static library and cannot link dynamic frameworks itself.
|
|
30
|
+
s.user_target_xcconfig = {
|
|
31
|
+
'OTHER_LDFLAGS' => '$(inherited) -framework "MapboxNavigationNative" -framework "MapboxCommon" -framework "MapboxCoreMaps"',
|
|
32
|
+
'FRAMEWORK_SEARCH_PATHS' => '$(inherited) "$(BUILT_PRODUCTS_DIR)/PackageFrameworks"',
|
|
33
|
+
}
|
|
26
34
|
end
|
package/package.json
CHANGED
package/plugin/build/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
4
|
-
const withMapboxNavSPM_1 = require("./withMapboxNavSPM");
|
|
5
4
|
const withMapboxNavPodfile_1 = require("./withMapboxNavPodfile");
|
|
6
5
|
const withMapboxNavGradle_1 = require("./withMapboxNavGradle");
|
|
7
6
|
const withMapboxNavGradleProperties_1 = require("./withMapboxNavGradleProperties");
|
|
@@ -25,14 +24,10 @@ const withMapboxNavigation = (config, { mapboxAccessToken, mapboxSecretToken, na
|
|
|
25
24
|
config.ios.infoPlist.NSLocationAlwaysAndWhenInUseUsageDescription =
|
|
26
25
|
config.ios.infoPlist.NSLocationAlwaysAndWhenInUseUsageDescription ||
|
|
27
26
|
"This app needs your location for turn-by-turn navigation, including in the background.";
|
|
28
|
-
// iOS:
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
config = (0, withMapboxNavSPM_1.withMapboxNavSPM)(config, { navigationSdkVersion });
|
|
33
|
-
// iOS: Set framework search paths so the ExpoMapboxNavigation pod can find
|
|
34
|
-
// the SPM-built Mapbox frameworks at compile time.
|
|
35
|
-
config = (0, withMapboxNavPodfile_1.withMapboxNavPodfile)(config);
|
|
27
|
+
// iOS: Adds Mapbox Navigation SPM to the Pods project and sets search paths
|
|
28
|
+
// so ExpoMapboxNavigation can import Mapbox modules. CocoaPods persists the
|
|
29
|
+
// changes automatically; xcodebuild resolves SPM during the build.
|
|
30
|
+
config = (0, withMapboxNavPodfile_1.withMapboxNavPodfile)(config, { navigationSdkVersion });
|
|
36
31
|
// Android: Mapbox Maven repository and optional token for SDK download
|
|
37
32
|
config = (0, withMapboxNavGradle_1.withMapboxNavGradle)(config);
|
|
38
33
|
config = (0, withMapboxNavGradleProperties_1.withMapboxNavGradleProperties)(config, { mapboxSecretToken });
|
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
import { ConfigPlugin } from "@expo/config-plugins";
|
|
2
|
+
interface PodfileOptions {
|
|
3
|
+
navigationSdkVersion: string;
|
|
4
|
+
}
|
|
2
5
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
+
* Injects a post_install hook that:
|
|
7
|
+
* 1. Adds Mapbox Navigation SDK as an SPM dependency to the Pods Xcode project
|
|
8
|
+
* and links it to the ExpoMapboxNavigation pod target.
|
|
9
|
+
* 2. Sets FRAMEWORK_SEARCH_PATHS / SWIFT_INCLUDE_PATHS so the pod can find
|
|
10
|
+
* SPM-built frameworks (including transitive deps like MapboxDirections).
|
|
11
|
+
* 3. Enables BUILD_LIBRARY_FOR_DISTRIBUTION on Mapbox/Turf targets.
|
|
12
|
+
*
|
|
13
|
+
* CocoaPods writes the Pods project to disk after post_install returns, so
|
|
14
|
+
* all in-memory modifications are persisted automatically — no explicit
|
|
15
|
+
* project.save or xcodebuild call needed. xcodebuild resolves SPM packages
|
|
16
|
+
* as part of its normal build, which works on both local and EAS clean builds.
|
|
6
17
|
*/
|
|
7
|
-
export declare const withMapboxNavPodfile: ConfigPlugin
|
|
18
|
+
export declare const withMapboxNavPodfile: ConfigPlugin<PodfileOptions>;
|
|
19
|
+
export {};
|
|
@@ -37,20 +37,35 @@ exports.withMapboxNavPodfile = void 0;
|
|
|
37
37
|
const config_plugins_1 = require("@expo/config-plugins");
|
|
38
38
|
const fs = __importStar(require("fs"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
|
+
const MAPBOX_NAV_URL = "https://github.com/mapbox/mapbox-navigation-ios.git";
|
|
41
|
+
const MAPBOX_NAV_PRODUCTS = [
|
|
42
|
+
"MapboxNavigationUIKit",
|
|
43
|
+
"MapboxNavigationCore",
|
|
44
|
+
];
|
|
40
45
|
const PLUGIN_MARKER = "# @baeckerherz/expo-mapbox-navigation:";
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
47
|
+
* Injects a post_install hook that:
|
|
48
|
+
* 1. Adds Mapbox Navigation SDK as an SPM dependency to the Pods Xcode project
|
|
49
|
+
* and links it to the ExpoMapboxNavigation pod target.
|
|
50
|
+
* 2. Sets FRAMEWORK_SEARCH_PATHS / SWIFT_INCLUDE_PATHS so the pod can find
|
|
51
|
+
* SPM-built frameworks (including transitive deps like MapboxDirections).
|
|
52
|
+
* 3. Enables BUILD_LIBRARY_FOR_DISTRIBUTION on Mapbox/Turf targets.
|
|
53
|
+
*
|
|
54
|
+
* CocoaPods writes the Pods project to disk after post_install returns, so
|
|
55
|
+
* all in-memory modifications are persisted automatically — no explicit
|
|
56
|
+
* project.save or xcodebuild call needed. xcodebuild resolves SPM packages
|
|
57
|
+
* as part of its normal build, which works on both local and EAS clean builds.
|
|
45
58
|
*/
|
|
46
|
-
const withMapboxNavPodfile = (config) => {
|
|
59
|
+
const withMapboxNavPodfile = (config, { navigationSdkVersion }) => {
|
|
47
60
|
return (0, config_plugins_1.withDangerousMod)(config, [
|
|
48
61
|
"ios",
|
|
49
62
|
async (config) => {
|
|
50
63
|
const podfilePath = path.join(config.modRequest.platformProjectRoot, "Podfile");
|
|
51
64
|
let contents = fs.readFileSync(podfilePath, "utf8");
|
|
65
|
+
const versionEscaped = navigationSdkVersion.replace(/'/g, "\\\\'");
|
|
52
66
|
const hook = `
|
|
53
|
-
${PLUGIN_MARKER}
|
|
67
|
+
${PLUGIN_MARKER} SPM in Pods + search paths + BUILD_LIBRARY_FOR_DISTRIBUTION
|
|
68
|
+
mapbox_nav_version = '${versionEscaped}'
|
|
54
69
|
installer.pods_project.targets.each do |target|
|
|
55
70
|
if target.name.start_with?('Mapbox') || target.name == 'Turf'
|
|
56
71
|
target.build_configurations.each do |cfg|
|
|
@@ -67,6 +82,30 @@ const withMapboxNavPodfile = (config) => {
|
|
|
67
82
|
cfg.build_settings['SWIFT_INCLUDE_PATHS'] << '$(BUILT_PRODUCTS_DIR)/..'
|
|
68
83
|
end
|
|
69
84
|
end
|
|
85
|
+
end
|
|
86
|
+
emn_target = installer.pods_project.targets.find { |t| t.name == 'ExpoMapboxNavigation' }
|
|
87
|
+
if emn_target
|
|
88
|
+
project = installer.pods_project
|
|
89
|
+
root = project.root_object
|
|
90
|
+
pkg_ref = root.package_references&.find { |r| r.respond_to?(:repositoryURL) && r.repositoryURL == '${MAPBOX_NAV_URL}' }
|
|
91
|
+
unless pkg_ref
|
|
92
|
+
pkg_ref = project.new(Xcodeproj::Project::Object::XCRemoteSwiftPackageReference)
|
|
93
|
+
pkg_ref.repositoryURL = '${MAPBOX_NAV_URL}'
|
|
94
|
+
pkg_ref.requirement = { 'kind' => 'exactVersion', 'version' => mapbox_nav_version }
|
|
95
|
+
root.package_references << pkg_ref
|
|
96
|
+
end
|
|
97
|
+
${MAPBOX_NAV_PRODUCTS.map((name) => `
|
|
98
|
+
unless emn_target.package_product_dependencies.any? { |d| d.product_name == '${name}' }
|
|
99
|
+
dep = project.new(Xcodeproj::Project::Object::XCSwiftPackageProductDependency)
|
|
100
|
+
dep.package = pkg_ref
|
|
101
|
+
dep.product_name = '${name}'
|
|
102
|
+
emn_target.package_product_dependencies << dep
|
|
103
|
+
if emn_target.frameworks_build_phases
|
|
104
|
+
bf = project.new(Xcodeproj::Project::Object::PBXBuildFile)
|
|
105
|
+
bf.product_ref = dep
|
|
106
|
+
emn_target.frameworks_build_phases.files << bf
|
|
107
|
+
end
|
|
108
|
+
end`).join("")}
|
|
70
109
|
end`;
|
|
71
110
|
const escapedMarker = PLUGIN_MARKER.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
72
111
|
// Remove any previously injected hook (handles upgrades from older plugin versions)
|
package/plugin/src/index.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { ConfigPlugin, createRunOncePlugin } from "@expo/config-plugins";
|
|
2
|
-
import { withMapboxNavSPM } from "./withMapboxNavSPM";
|
|
3
2
|
import { withMapboxNavPodfile } from "./withMapboxNavPodfile";
|
|
4
3
|
import { withMapboxNavGradle } from "./withMapboxNavGradle";
|
|
5
4
|
import { withMapboxNavGradleProperties } from "./withMapboxNavGradleProperties";
|
|
@@ -44,15 +43,10 @@ const withMapboxNavigation: ConfigPlugin<PluginConfig> = (
|
|
|
44
43
|
config.ios.infoPlist.NSLocationAlwaysAndWhenInUseUsageDescription ||
|
|
45
44
|
"This app needs your location for turn-by-turn navigation, including in the background.";
|
|
46
45
|
|
|
47
|
-
// iOS:
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
|
|
51
|
-
config = withMapboxNavSPM(config, { navigationSdkVersion });
|
|
52
|
-
|
|
53
|
-
// iOS: Set framework search paths so the ExpoMapboxNavigation pod can find
|
|
54
|
-
// the SPM-built Mapbox frameworks at compile time.
|
|
55
|
-
config = withMapboxNavPodfile(config);
|
|
46
|
+
// iOS: Adds Mapbox Navigation SPM to the Pods project and sets search paths
|
|
47
|
+
// so ExpoMapboxNavigation can import Mapbox modules. CocoaPods persists the
|
|
48
|
+
// changes automatically; xcodebuild resolves SPM during the build.
|
|
49
|
+
config = withMapboxNavPodfile(config, { navigationSdkVersion });
|
|
56
50
|
|
|
57
51
|
// Android: Mapbox Maven repository and optional token for SDK download
|
|
58
52
|
config = withMapboxNavGradle(config);
|
|
@@ -2,14 +2,35 @@ import { withDangerousMod, ConfigPlugin } from "@expo/config-plugins";
|
|
|
2
2
|
import * as fs from "fs";
|
|
3
3
|
import * as path from "path";
|
|
4
4
|
|
|
5
|
+
const MAPBOX_NAV_URL = "https://github.com/mapbox/mapbox-navigation-ios.git";
|
|
6
|
+
const MAPBOX_NAV_PRODUCTS = [
|
|
7
|
+
"MapboxNavigationUIKit",
|
|
8
|
+
"MapboxNavigationCore",
|
|
9
|
+
];
|
|
10
|
+
|
|
5
11
|
const PLUGIN_MARKER = "# @baeckerherz/expo-mapbox-navigation:";
|
|
6
12
|
|
|
13
|
+
interface PodfileOptions {
|
|
14
|
+
navigationSdkVersion: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
7
17
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
18
|
+
* Injects a post_install hook that:
|
|
19
|
+
* 1. Adds Mapbox Navigation SDK as an SPM dependency to the Pods Xcode project
|
|
20
|
+
* and links it to the ExpoMapboxNavigation pod target.
|
|
21
|
+
* 2. Sets FRAMEWORK_SEARCH_PATHS / SWIFT_INCLUDE_PATHS so the pod can find
|
|
22
|
+
* SPM-built frameworks (including transitive deps like MapboxDirections).
|
|
23
|
+
* 3. Enables BUILD_LIBRARY_FOR_DISTRIBUTION on Mapbox/Turf targets.
|
|
24
|
+
*
|
|
25
|
+
* CocoaPods writes the Pods project to disk after post_install returns, so
|
|
26
|
+
* all in-memory modifications are persisted automatically — no explicit
|
|
27
|
+
* project.save or xcodebuild call needed. xcodebuild resolves SPM packages
|
|
28
|
+
* as part of its normal build, which works on both local and EAS clean builds.
|
|
11
29
|
*/
|
|
12
|
-
export const withMapboxNavPodfile: ConfigPlugin = (
|
|
30
|
+
export const withMapboxNavPodfile: ConfigPlugin<PodfileOptions> = (
|
|
31
|
+
config,
|
|
32
|
+
{ navigationSdkVersion }
|
|
33
|
+
) => {
|
|
13
34
|
return withDangerousMod(config, [
|
|
14
35
|
"ios",
|
|
15
36
|
async (config) => {
|
|
@@ -19,8 +40,11 @@ export const withMapboxNavPodfile: ConfigPlugin = (config) => {
|
|
|
19
40
|
);
|
|
20
41
|
let contents = fs.readFileSync(podfilePath, "utf8");
|
|
21
42
|
|
|
43
|
+
const versionEscaped = navigationSdkVersion.replace(/'/g, "\\\\'");
|
|
44
|
+
|
|
22
45
|
const hook = `
|
|
23
|
-
${PLUGIN_MARKER}
|
|
46
|
+
${PLUGIN_MARKER} SPM in Pods + search paths + BUILD_LIBRARY_FOR_DISTRIBUTION
|
|
47
|
+
mapbox_nav_version = '${versionEscaped}'
|
|
24
48
|
installer.pods_project.targets.each do |target|
|
|
25
49
|
if target.name.start_with?('Mapbox') || target.name == 'Turf'
|
|
26
50
|
target.build_configurations.each do |cfg|
|
|
@@ -37,6 +61,32 @@ export const withMapboxNavPodfile: ConfigPlugin = (config) => {
|
|
|
37
61
|
cfg.build_settings['SWIFT_INCLUDE_PATHS'] << '$(BUILT_PRODUCTS_DIR)/..'
|
|
38
62
|
end
|
|
39
63
|
end
|
|
64
|
+
end
|
|
65
|
+
emn_target = installer.pods_project.targets.find { |t| t.name == 'ExpoMapboxNavigation' }
|
|
66
|
+
if emn_target
|
|
67
|
+
project = installer.pods_project
|
|
68
|
+
root = project.root_object
|
|
69
|
+
pkg_ref = root.package_references&.find { |r| r.respond_to?(:repositoryURL) && r.repositoryURL == '${MAPBOX_NAV_URL}' }
|
|
70
|
+
unless pkg_ref
|
|
71
|
+
pkg_ref = project.new(Xcodeproj::Project::Object::XCRemoteSwiftPackageReference)
|
|
72
|
+
pkg_ref.repositoryURL = '${MAPBOX_NAV_URL}'
|
|
73
|
+
pkg_ref.requirement = { 'kind' => 'exactVersion', 'version' => mapbox_nav_version }
|
|
74
|
+
root.package_references << pkg_ref
|
|
75
|
+
end
|
|
76
|
+
${MAPBOX_NAV_PRODUCTS.map(
|
|
77
|
+
(name) => `
|
|
78
|
+
unless emn_target.package_product_dependencies.any? { |d| d.product_name == '${name}' }
|
|
79
|
+
dep = project.new(Xcodeproj::Project::Object::XCSwiftPackageProductDependency)
|
|
80
|
+
dep.package = pkg_ref
|
|
81
|
+
dep.product_name = '${name}'
|
|
82
|
+
emn_target.package_product_dependencies << dep
|
|
83
|
+
if emn_target.frameworks_build_phases
|
|
84
|
+
bf = project.new(Xcodeproj::Project::Object::PBXBuildFile)
|
|
85
|
+
bf.product_ref = dep
|
|
86
|
+
emn_target.frameworks_build_phases.files << bf
|
|
87
|
+
end
|
|
88
|
+
end`
|
|
89
|
+
).join("")}
|
|
40
90
|
end`;
|
|
41
91
|
|
|
42
92
|
const escapedMarker = PLUGIN_MARKER.replace(
|