Repository navigation
Expand file tree
/
Copy pathreact-native-maps.podspec
More file actions
178 lines (155 loc) · 7.29 KB
/
Copy pathreact-native-maps.podspec
File metadata and controls
178 lines (155 loc) · 7.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
require 'json'
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
folly_config = get_folly_config()
folly_compiler_flags = folly_config[:compiler_flags]
Pod::Spec.new do |s|
s.name = "react-native-maps"
s.version = package['version']
s.summary = package["description"]
s.authors = package["author"]
s.homepage = package["homepage"]
s.license = package["license"]
s.platform = :ios, "15.1"
s.source = { :git => "https://github.com/react-native-maps/react-native-maps.git", :tag => "v#{s.version}" }
# Set module_name at the root spec level
s.module_name = 'ReactNativeMaps'
# Generated code subspec
s.subspec 'Generated' do |ss|
ss.source_files = "ios/generated/**/*.{h,m,mm,cpp,swift}"
ss.exclude_files = [
"ios/generated/RCTModuleProviders.h",
"ios/generated/RCTModuleProviders.mm",
"ios/generated/RCTUnstableModulesRequiringMainQueueSetupProvider.h",
"ios/generated/RCTUnstableModulesRequiringMainQueueSetupProvider.mm",
"ios/generated/RCTAppDependencyProvider.h",
"ios/generated/RCTAppDependencyProvider.mm",
"ios/generated/RCTThirdPartyComponentsProvider.h",
"ios/generated/RCTThirdPartyComponentsProvider.mm",
"ios/generated/RCTModulesConformingToProtocolsProvider.h",
"ios/generated/RCTModulesConformingToProtocolsProvider.mm",
]
ss.public_header_files = "ios/generated/**/*.h"
ss.compiler_flags = folly_compiler_flags
install_modules_dependencies(ss)
end
# Main maps component
s.subspec 'Maps' do |ss|
ss.source_files = "ios/AirMaps/**/*.{h,m,mm,swift}"
ss.public_header_files = [
'ios/AirMaps/UIView+AirMap.h',
'ios/AirMaps/RCTConvert+AirMap.h',
]
ss.compiler_flags = folly_compiler_flags
ss.dependency 'react-native-maps/Generated'
install_modules_dependencies(ss)
# Add script phase to detect Google Maps
ss.script_phases = [
{
:name => 'react-native-maps patches',
:script => %(
set -x
echo "Running Google Maps detection script..."
DEFINES_DIR="${PODS_TARGET_SRCROOT}/ios/AirMaps"
DEFINES_FILE="${DEFINES_DIR}/RNMapsDefines.h"
mkdir -p "$DEFINES_DIR"
if [ "$RNMAPS_GOOGLE_NAVIGATION" = "YES" ] || { [ -d "$PODS_ROOT/GoogleMaps" ] && [ -d "$PODS_ROOT/Google-Maps-iOS-Utils" ]; }; then
echo "#define HAVE_GOOGLE_MAPS 1" > "$DEFINES_FILE"
echo "✅ Google Maps libraries detected. HAVE_GOOGLE_MAPS defined."
else
echo "#define HAVE_GOOGLE_MAPS 0" > "$DEFINES_FILE"
echo "❌ Google Maps libraries NOT detected. HAVE_GOOGLE_MAPS set to 0."
fi
if [ -f "$DEFINES_FILE" ]; then
echo "✅ Successfully wrote to $DEFINES_FILE"
cat "$DEFINES_FILE"
else
echo "❌ ERROR: Failed to write to $DEFINES_FILE"
fi
set -e
echo "🔧 Patching @import GoogleMaps..."
FILES=(
"$PODS_ROOT/Google-Maps-iOS-Utils/Sources/GoogleMapsUtilsObjC/include/GMSMarker+GMUClusteritem.h"
"$PODS_ROOT/Google-Maps-iOS-Utils/Sources/GoogleMapsUtilsObjC/include/GMUGeoJSONParser.h"
"$PODS_ROOT/Google-Maps-iOS-Utils/Sources/GoogleMapsUtilsObjC/include/GMUPolygon.h"
"$PODS_ROOT/Google-Maps-iOS-Utils/Sources/GoogleMapsUtilsObjC/include/GMUWeightedLatLng.h"
"$PODS_ROOT/GoogleMaps/Maps/Sources/GMSEmpty.h"
)
for file in "${FILES[@]}"; do
if [ -f "$file" ]; then
if grep -q "@import GoogleMaps;" "$file"; then
sed -i '' 's/@import GoogleMaps;/#import <GoogleMaps\\/GoogleMaps.h>/' "$file"
echo "✅ Patched: $file"
else
echo "ℹ️ No @import in: $file"
fi
else
echo "⚠️ Not found: $file"
fi
done
),
:execution_position => :before_compile
}
]
end
# Google Maps subspec
s.subspec 'Google' do |ss|
ss.source_files = "ios/AirGoogleMaps/**/*.{h,m,mm,swift}"
ss.resource_bundles = {
'GoogleMapsPrivacy' => ['ios/AirGoogleMaps/Resources/GoogleMapsPrivacy.bundle']
}
# Fixed compiler flags to avoid -Wno warnings
ss.compiler_flags = folly_compiler_flags + ' -DHAVE_GOOGLE_MAPS=1 -DHAVE_GOOGLE_MAPS_UTILS=1'
google_maps_version = '9.4.0'
google_maps_utils_version = '6.1.0'
if defined?($RNMapsGoogleMapsVersion)
Pod::UI.puts "#{s.name}: Using user specified GoogleMaps version '#{$RNMapsGoogleMapsVersion}'"
google_maps_version = $RNMapsGoogleMapsVersion
end
if defined?($RNMapsGoogleMapsUtilsVersion)
Pod::UI.puts "#{s.name}: Using user specified Google-Maps-iOS-Utils version '#{$RNMapsGoogleMapsUtilsVersion}'"
google_maps_utils_version = $RNMapsGoogleMapsUtilsVersion
end
ss.dependency 'GoogleMaps', google_maps_version #'8.4.0'
ss.dependency 'Google-Maps-iOS-Utils', google_maps_utils_version #'5.0.0'
ss.dependency 'react-native-maps/Generated'
ss.dependency 'react-native-maps/Maps'
install_modules_dependencies(ss)
end
# Google Navigation SDK subspec, used instead of 'Google'. Opt in from the Podfile with
# `$RNMapsEnableGoogleNavigation = true`. GoogleNavigation is only distributed through Swift
# Package Manager and bundles its own GoogleMaps, so it cannot be combined with the 'Google'
# subspec. Google-Maps-iOS-Utils (Heatmap, KML) is unavailable: its SPM package pins GoogleMaps 10.x.
if defined?($RNMapsEnableGoogleNavigation) && $RNMapsEnableGoogleNavigation
unless defined?(spm_dependency)
raise Pod::Informative, "react-native-maps/GoogleNavigation requires a React Native version that provides spm_dependency."
end
google_navigation_version = '11.1.0'
if defined?($RNMapsGoogleNavigationVersion)
Pod::UI.puts "#{s.name}: Using user specified GoogleNavigation version '#{$RNMapsGoogleNavigationVersion}'"
google_navigation_version = $RNMapsGoogleNavigationVersion
end
s.subspec 'GoogleNavigation' do |ss|
ss.ios.deployment_target = '16.0'
ss.source_files = "ios/AirGoogleMaps/**/*.{h,m,mm,swift}", "ios/AirGoogleNavigation/**/*.{h,m,mm}"
ss.exclude_files = "ios/AirGoogleMaps/AIRGoogleMapHeatmap*.{h,m}"
ss.resource_bundles = {
'GoogleMapsPrivacy' => ['ios/AirGoogleMaps/Resources/GoogleMapsPrivacy.bundle']
}
ss.compiler_flags = folly_compiler_flags + ' -DHAVE_GOOGLE_MAPS=1 -DHAVE_GOOGLE_NAVIGATION=1'
# Read by the Google Maps detection script, since GoogleMaps is not in $PODS_ROOT.
ss.pod_target_xcconfig = { 'RNMAPS_GOOGLE_NAVIGATION' => 'YES' }
ss.dependency 'react-native-maps/Generated'
ss.dependency 'react-native-maps/Maps'
install_modules_dependencies(ss)
end
# SPM dependencies are attached to the pod target, so they must be declared on the root spec.
spm_dependency(
s,
url: "https://github.com/googlemaps/ios-navigation-sdk.git",
requirement: { kind: "exactVersion", version: google_navigation_version },
products: ["GoogleNavigation"]
)
end
# By default, use the Maps subspec
s.default_subspec = 'Maps'
end