diff --git a/README.md b/README.md index 07a9ed7..f910309 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ npx expo install @youssefhenna/expo-mapbox-navigation ### Configure package -In your `app.json` or `app.js`, you'll need to add a plugin for the package under the `plugins` entry with a valid mapbox access token (The one that starts with `pk.`). +In your `app.json` or `app.js`, you'll need to add a plugin for the package under the `plugins` entry with a valid mapbox access token (The one that starts with `pk.`). For the mapbox maps version, you have to use the same version set in the setup steps of `@rnmapbox/maps`. ```json "plugins": [ @@ -29,7 +29,8 @@ In your `app.json` or `app.js`, you'll need to add a plugin for the package unde [ "@youssefhenna/expo-mapbox-navigation", { - "accessToken": "" + "accessToken": "", + "mapboxMapsVersion": "" } ] ] diff --git a/example/app.json b/example/app.json index 48735ae..3a50356 100644 --- a/example/app.json +++ b/example/app.json @@ -51,7 +51,8 @@ [ "../app.plugin.js", { - "accessToken": "" + "accessToken": "", + "mapboxMapsVersion": "11.3.0" } ] ] diff --git a/ios/ExpoMapboxNavigation.podspec b/ios/ExpoMapboxNavigation.podspec index 3d9d42d..ca94d6f 100644 --- a/ios/ExpoMapboxNavigation.podspec +++ b/ios/ExpoMapboxNavigation.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| s.static_framework = true s.dependency 'ExpoModulesCore' - s.dependency 'MapboxMaps', $RNMapboxMapsVersion + s.dependency 'MapboxMaps', ENV['ExpoNavigationMapboxMapsVersion'] s.dependency 'Turf', '~> 2.4' s.source_files = "**/*.{h,m,swift}" diff --git a/plugin/withIosConfig.js b/plugin/withIosConfig.js index f1b9f9b..43ccac2 100644 --- a/plugin/withIosConfig.js +++ b/plugin/withIosConfig.js @@ -9,10 +9,12 @@ const path = require("path"); * See https://github.com/CocoaPods/CocoaPods/issues/11079#issuecomment-984670700 */ -const applyPodfilePostInstallModifications = (src) => { - return src.replace( - "post_install do |installer|", - `post_install do |installer| +const applyPodfilePostInstallModifications = (src, mapboxMapsVersion) => { + return ( + `ENV['ExpoNavigationMapboxMapsVersion'] = '${mapboxMapsVersion}'\n` + + src.replace( + "post_install do |installer|", + `post_install do |installer| installer.pods_project.targets.each do |target| if (target.name.include? 'MapboxMaps' or target.name.include? 'Turf') target.build_configurations.each do |config| @@ -20,10 +22,11 @@ const applyPodfilePostInstallModifications = (src) => { end end end` + ) ); }; -const withIosPostInstallStep = (config) => +const withIosPostInstallStep = (config, mapboxMapsVersion) => withDangerousMod(config, [ "ios", async (exportedConfig) => { @@ -35,7 +38,7 @@ const withIosPostInstallStep = (config) => const contents = await fs.readFile(file, "utf8"); await fs.writeFile( file, - applyPodfilePostInstallModifications(contents), + applyPodfilePostInstallModifications(contents, mapboxMapsVersion), "utf-8" ); @@ -56,8 +59,11 @@ const withIosTokenInfoPlist = (config, accessToken) => { return config; }; -const withIosConfig = (config, { accessToken }) => { - const configWithPostInstallStep = withIosPostInstallStep(config); +const withIosConfig = (config, { accessToken, mapboxMapsVersion }) => { + const configWithPostInstallStep = withIosPostInstallStep( + config, + mapboxMapsVersion + ); const configWithAccessToken = withIosTokenInfoPlist( configWithPostInstallStep, accessToken