@jacques_gordon/expo-mapbox-navigation 2.2.10 → 2.2.11

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/app.plugin.js CHANGED
@@ -172,8 +172,9 @@ def _expo_mapbox_nav_add_spm(installer)
172
172
 
173
173
  pkg_class = Xcodeproj::Project::Object::XCRemoteSwiftPackageReference
174
174
  ref_class = Xcodeproj::Project::Object::XCSwiftPackageProductDependency
175
+ dep_class = Xcodeproj::Project::Object::PBXTargetDependency
175
176
 
176
- # ── Step 1: Add to pods_project (where ExpoMapboxNavigation target lives) ──
177
+ # ── Step 1: Add package + products to pods_project ────────────────────────
177
178
  pods_project = installer.pods_project
178
179
 
179
180
  pkg = pods_project.root_object.package_references.find { |p|
@@ -187,60 +188,52 @@ def _expo_mapbox_nav_add_spm(installer)
187
188
  puts '[ExpoMapboxNavigation] Added mapbox-navigation-ios to pods_project'
188
189
  end
189
190
 
190
- # ── FIX: Stronger target lookup with fallback ──────────────────────────────
191
- # CocoaPods normally names the target exactly 'ExpoMapboxNavigation'.
192
- # Deduplication suffixes (e.g. 'ExpoMapboxNavigation-abc123') only happen
193
- # when the same pod is included in multiple targets with different specs,
194
- # which is not our case. We still add an include? fallback to be safe.
195
191
  expo_target = pods_project.targets.find { |t| t.name == 'ExpoMapboxNavigation' }
196
192
  expo_target ||= pods_project.targets.find { |t| t.name.include?('ExpoMapboxNavigation') }
197
193
  if expo_target
198
194
  puts "[ExpoMapboxNavigation] Found target: #{expo_target.name}"
199
195
  products.each do |product_name|
200
- ref = expo_target.package_product_dependencies.find { |r|
196
+ # 1. package_product_dependencies registers SPM product on target
197
+ prod_ref = expo_target.package_product_dependencies.find { |r|
201
198
  r.class == ref_class && r.package == pkg && r.product_name == product_name
202
199
  }
203
- unless ref
204
- ref = pods_project.new(ref_class)
205
- ref.package = pkg
206
- ref.product_name = product_name
207
- expo_target.package_product_dependencies << ref
208
- puts "[ExpoMapboxNavigation] Linked #{product_name} -> #{expo_target.name}"
200
+ unless prod_ref
201
+ prod_ref = pods_project.new(ref_class)
202
+ prod_ref.package = pkg
203
+ prod_ref.product_name = product_name
204
+ expo_target.package_product_dependencies << prod_ref
205
+ puts "[ExpoMapboxNavigation] Added package_product_dependency: #{product_name}"
206
+ end
207
+ end
208
+
209
+ # ── SWIFT_INCLUDE_PATHS fix ──────────────────────────────────────────────
210
+ # SPM compiles .swiftmodule into ${PODS_CONFIGURATION_BUILD_DIR}.
211
+ # Without adding this path, Xcode throws "no such module MapboxNavigationCore".
212
+ # Source: https://trinhngocthuyen.com/posts/tech/spm-with-cocoapods/
213
+ expo_target.build_configurations.each do |config|
214
+ existing = config.build_settings['SWIFT_INCLUDE_PATHS'] || '$(inherited)'
215
+ unless existing.include?('PODS_CONFIGURATION_BUILD_DIR')
216
+ config.build_settings['SWIFT_INCLUDE_PATHS'] =
217
+ "#{existing} \"${PODS_CONFIGURATION_BUILD_DIR}\""
218
+ puts "[ExpoMapboxNavigation] Added PODS_CONFIGURATION_BUILD_DIR to SWIFT_INCLUDE_PATHS (#{config.name})"
209
219
  end
210
220
  end
211
221
  else
212
- # Debug: print all available targets so we can fix the name if needed
213
222
  puts '[ExpoMapboxNavigation] WARNING: ExpoMapboxNavigation target not found!'
214
223
  puts '[ExpoMapboxNavigation] Available targets:'
215
224
  pods_project.targets.each { |t| puts " - #{t.name}" }
216
225
  end
217
226
  pods_project.save
218
227
 
219
- # ── Step 2: Add package REFERENCE to user_project (NOT products) ────────────
220
- # Critical distinction learned from build logs:
221
- #
222
- # v2.2.8 (Step 2 with products on user target):
223
- # SPM resolved correctly
224
- # But caused "Multiple commands produce MapboxCommon/Turf/MapboxCoreMaps"
225
- # Because @rnmapbox/maps already embeds those transitive dependencies
226
- #
227
- # v2.2.9 (Step 2 removed entirely):
228
- # → No "Multiple commands produce" ✅
229
- # → But "Missing package product MapboxNavigationCore/UIKit" ❌
230
- # → Because Pods.xcodeproj is rebuilt by CocoaPods each time, so the
231
- # package reference injected into pods_project does not persist.
232
- # Without a reference in user_project (Navio.xcodeproj, which persists),
233
- # Xcode does not resolve the SPM package and the products are not found.
234
- #
235
- # v2.2.10 (this version — package reference only in user_project):
236
- # → Add ONLY the XCRemoteSwiftPackageReference to user_project ✅
237
- # → Do NOT add XCSwiftPackageProductDependency to user_target ✅
238
- # → This registers the package in the Xcode workspace SPM graph so it
239
- # gets resolved and downloaded, without embedding its frameworks again.
228
+ # ── Step 2: Register package reference in user_project (persists) ─────────
229
+ # Pods.xcodeproj is rebuilt every pod install — our Step 1 must survive via
230
+ # the workspace SPM graph. Registering the XCRemoteSwiftPackageReference in
231
+ # user_project (Navio.xcodeproj) ensures Xcode resolves the package into
232
+ # the workspace cache, making products available to Pods.xcodeproj targets.
233
+ # We do NOT add product dependencies to the app target — that caused
234
+ # "Multiple commands produce" in v2.2.8 (duplicate embed with @rnmapbox/maps).
240
235
  installer.aggregate_targets.each do |agg|
241
236
  user_project = agg.user_project
242
-
243
- # Add only the package reference — not the product dependencies
244
237
  user_pkg = user_project.root_object.package_references.find { |p|
245
238
  p.class == pkg_class && p.repositoryURL == url
246
239
  }
@@ -249,9 +242,8 @@ def _expo_mapbox_nav_add_spm(installer)
249
242
  user_pkg.repositoryURL = url
250
243
  user_pkg.requirement = requirement
251
244
  user_project.root_object.package_references << user_pkg
252
- puts "[ExpoMapboxNavigation] Registered mapbox-navigation-ios in #{user_project.path.basename}"
245
+ puts "[ExpoMapboxNavigation] Registered package ref in #{user_project.path.basename}"
253
246
  end
254
-
255
247
  user_project.save
256
248
  end
257
249
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jacques_gordon/expo-mapbox-navigation",
3
- "version": "2.2.10",
3
+ "version": "2.2.11",
4
4
  "description": "Expo module for Mapbox Navigation SDK with 16KB page size support, NDK27, and Mapbox Maps v11.11.0+",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -172,8 +172,9 @@ def _expo_mapbox_nav_add_spm(installer)
172
172
 
173
173
  pkg_class = Xcodeproj::Project::Object::XCRemoteSwiftPackageReference
174
174
  ref_class = Xcodeproj::Project::Object::XCSwiftPackageProductDependency
175
+ dep_class = Xcodeproj::Project::Object::PBXTargetDependency
175
176
 
176
- # ── Step 1: Add to pods_project (where ExpoMapboxNavigation target lives) ──
177
+ # ── Step 1: Add package + products to pods_project ────────────────────────
177
178
  pods_project = installer.pods_project
178
179
 
179
180
  pkg = pods_project.root_object.package_references.find { |p|
@@ -187,60 +188,52 @@ def _expo_mapbox_nav_add_spm(installer)
187
188
  puts '[ExpoMapboxNavigation] Added mapbox-navigation-ios to pods_project'
188
189
  end
189
190
 
190
- # ── FIX: Stronger target lookup with fallback ──────────────────────────────
191
- # CocoaPods normally names the target exactly 'ExpoMapboxNavigation'.
192
- # Deduplication suffixes (e.g. 'ExpoMapboxNavigation-abc123') only happen
193
- # when the same pod is included in multiple targets with different specs,
194
- # which is not our case. We still add an include? fallback to be safe.
195
191
  expo_target = pods_project.targets.find { |t| t.name == 'ExpoMapboxNavigation' }
196
192
  expo_target ||= pods_project.targets.find { |t| t.name.include?('ExpoMapboxNavigation') }
197
193
  if expo_target
198
194
  puts "[ExpoMapboxNavigation] Found target: #{expo_target.name}"
199
195
  products.each do |product_name|
200
- ref = expo_target.package_product_dependencies.find { |r|
196
+ # 1. package_product_dependencies registers SPM product on target
197
+ prod_ref = expo_target.package_product_dependencies.find { |r|
201
198
  r.class == ref_class && r.package == pkg && r.product_name == product_name
202
199
  }
203
- unless ref
204
- ref = pods_project.new(ref_class)
205
- ref.package = pkg
206
- ref.product_name = product_name
207
- expo_target.package_product_dependencies << ref
208
- puts "[ExpoMapboxNavigation] Linked #{product_name} -> #{expo_target.name}"
200
+ unless prod_ref
201
+ prod_ref = pods_project.new(ref_class)
202
+ prod_ref.package = pkg
203
+ prod_ref.product_name = product_name
204
+ expo_target.package_product_dependencies << prod_ref
205
+ puts "[ExpoMapboxNavigation] Added package_product_dependency: #{product_name}"
206
+ end
207
+ end
208
+
209
+ # ── SWIFT_INCLUDE_PATHS fix ──────────────────────────────────────────────
210
+ # SPM compiles .swiftmodule into ${PODS_CONFIGURATION_BUILD_DIR}.
211
+ # Without adding this path, Xcode throws "no such module MapboxNavigationCore".
212
+ # Source: https://trinhngocthuyen.com/posts/tech/spm-with-cocoapods/
213
+ expo_target.build_configurations.each do |config|
214
+ existing = config.build_settings['SWIFT_INCLUDE_PATHS'] || '$(inherited)'
215
+ unless existing.include?('PODS_CONFIGURATION_BUILD_DIR')
216
+ config.build_settings['SWIFT_INCLUDE_PATHS'] =
217
+ "#{existing} \"${PODS_CONFIGURATION_BUILD_DIR}\""
218
+ puts "[ExpoMapboxNavigation] Added PODS_CONFIGURATION_BUILD_DIR to SWIFT_INCLUDE_PATHS (#{config.name})"
209
219
  end
210
220
  end
211
221
  else
212
- # Debug: print all available targets so we can fix the name if needed
213
222
  puts '[ExpoMapboxNavigation] WARNING: ExpoMapboxNavigation target not found!'
214
223
  puts '[ExpoMapboxNavigation] Available targets:'
215
224
  pods_project.targets.each { |t| puts " - #{t.name}" }
216
225
  end
217
226
  pods_project.save
218
227
 
219
- # ── Step 2: Add package REFERENCE to user_project (NOT products) ────────────
220
- # Critical distinction learned from build logs:
221
- #
222
- # v2.2.8 (Step 2 with products on user target):
223
- # SPM resolved correctly
224
- # But caused "Multiple commands produce MapboxCommon/Turf/MapboxCoreMaps"
225
- # Because @rnmapbox/maps already embeds those transitive dependencies
226
- #
227
- # v2.2.9 (Step 2 removed entirely):
228
- # → No "Multiple commands produce" ✅
229
- # → But "Missing package product MapboxNavigationCore/UIKit" ❌
230
- # → Because Pods.xcodeproj is rebuilt by CocoaPods each time, so the
231
- # package reference injected into pods_project does not persist.
232
- # Without a reference in user_project (Navio.xcodeproj, which persists),
233
- # Xcode does not resolve the SPM package and the products are not found.
234
- #
235
- # v2.2.10 (this version — package reference only in user_project):
236
- # → Add ONLY the XCRemoteSwiftPackageReference to user_project ✅
237
- # → Do NOT add XCSwiftPackageProductDependency to user_target ✅
238
- # → This registers the package in the Xcode workspace SPM graph so it
239
- # gets resolved and downloaded, without embedding its frameworks again.
228
+ # ── Step 2: Register package reference in user_project (persists) ─────────
229
+ # Pods.xcodeproj is rebuilt every pod install — our Step 1 must survive via
230
+ # the workspace SPM graph. Registering the XCRemoteSwiftPackageReference in
231
+ # user_project (Navio.xcodeproj) ensures Xcode resolves the package into
232
+ # the workspace cache, making products available to Pods.xcodeproj targets.
233
+ # We do NOT add product dependencies to the app target — that caused
234
+ # "Multiple commands produce" in v2.2.8 (duplicate embed with @rnmapbox/maps).
240
235
  installer.aggregate_targets.each do |agg|
241
236
  user_project = agg.user_project
242
-
243
- # Add only the package reference — not the product dependencies
244
237
  user_pkg = user_project.root_object.package_references.find { |p|
245
238
  p.class == pkg_class && p.repositoryURL == url
246
239
  }
@@ -249,9 +242,8 @@ def _expo_mapbox_nav_add_spm(installer)
249
242
  user_pkg.repositoryURL = url
250
243
  user_pkg.requirement = requirement
251
244
  user_project.root_object.package_references << user_pkg
252
- puts "[ExpoMapboxNavigation] Registered mapbox-navigation-ios in #{user_project.path.basename}"
245
+ puts "[ExpoMapboxNavigation] Registered package ref in #{user_project.path.basename}"
253
246
  end
254
-
255
247
  user_project.save
256
248
  end
257
249
  end