Skip to content

Commit 12c7751

Browse files
authored
fix(ios): support static frameworks under Expo SDK 57 precompiled pipeline (#4245)
Building @rnmapbox/maps with Expo SDK 56+'s precompiled iOS pipeline and `useFrameworks: static` (e.g. required by react-native-firebase) failed at two stages: 1. `pod install` raised `verify_no_static_framework_transitive_dependencies`. rnmapbox's pre_install flips the Mapbox pods to dynamic frameworks, then Expo's precompiled hook downgrades most of them back to static libraries - but not MapboxMaps, leaving a dynamic pod with static dependencies. 2. Even past that, compilation failed with `'rnmapbox_maps/rnmapbox_maps-Swift.h' file not found`. The RNMBX_USE_FRAMEWORKS macro was frozen at podspec-eval time from the USE_FRAMEWORKS env, so the Swift header shim took the framework import path while Expo actually built the pod as a static library. Fixes: - Resolve the generated Swift header with `__has_include`, which follows the pod's actual build output instead of a stale macro (same pattern already used in RNMBXFollyConvert.h). The now-unused RNMBX_USE_FRAMEWORKS flag is removed. - Skip the Mapbox dynamic-framework flip when Expo's precompiled pipeline is active (EXPO_USE_PRECOMPILED_MODULES=1) so all Mapbox pods stay consistently static. Verified on a fresh Expo SDK 57 (RN 0.86) app with useFrameworks: static: clean pod install and a successful rnmapbox-maps compile (Xcode 26.6).
1 parent d4452ff commit 12c7751

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

ios/RNMBX/rnmapbox_maps-Swift.pre.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@interface MapView : UIView
77
@end
88

9-
#if RNMBX_USE_FRAMEWORKS
9+
#if __has_include(<rnmapbox_maps/rnmapbox_maps-Swift.h>)
1010
#import <rnmapbox_maps/rnmapbox_maps-Swift.h>
1111
#else
1212
#import <rnmapbox_maps-Swift.h>

rnmapbox-maps.podspec

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,19 @@ end
199199

200200
$rnMapboxMapsTargetsToChangeToDynamic = rnMapboxMapsTargetsToChangeToDynamic
201201

202+
def $RNMapboxMaps._expo_precompiled_pipeline?
203+
# Expo SDK 56+ precompiled iOS pipeline (prebuilt React core) downgrades every
204+
# framework-style pod back to a static library after the podspec is evaluated.
205+
# Flipping the Mapbox pods to dynamic here fights that and leaves an inconsistent
206+
# graph (MapboxMaps stays dynamic while its deps get forced static). See #4242.
207+
ENV['EXPO_USE_PRECOMPILED_MODULES'] == '1'
208+
end
209+
202210
def $RNMapboxMaps.pre_install(installer)
211+
if $RNMapboxMaps._expo_precompiled_pipeline?
212+
Pod::UI.puts "[RNMapbox] Expo precompiled modules pipeline detected (EXPO_USE_PRECOMPILED_MODULES=1) — skipping the Mapbox dynamic-framework flip so all Mapbox pods stay consistently static."
213+
return
214+
end
203215
installer.aggregate_targets.each do |target|
204216
target.pod_targets.select { |p| $rnMapboxMapsTargetsToChangeToDynamic.include?(p.name) }.each do |mobile_events_target|
205217
mobile_events_target.instance_variable_set(:@build_type,Pod::BuildType.dynamic_framework)
@@ -286,9 +298,6 @@ Pod::Spec.new do |s|
286298
$RNMapboxMaps._add_compiler_flags(sp, "-DRNMBX_RN_72=1")
287299
end
288300
end
289-
if ENV['USE_FRAMEWORKS'] || $RNMapboxMapsUseFrameworks
290-
$RNMapboxMaps._add_compiler_flags(sp, "-DRNMBX_USE_FRAMEWORKS=1")
291-
end
292301
else
293302
fail "$RNMapboxMapsImpl should be mapbox but was: $RNMapboxMapsImpl"
294303
end

0 commit comments

Comments
 (0)