-
Notifications
You must be signed in to change notification settings - Fork 1
/
react-native-maps-plugin.js
62 lines (55 loc) · 1.87 KB
/
react-native-maps-plugin.js
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
// See https://github.com/react-native-maps/react-native-maps/issues/3597
// and https://github.com/react-native-maps/react-native-maps/issues/4563.
const fs = require("fs");
const path = require("path");
const generateCode = require("@expo/config-plugins/build/utils/generateCode");
const configPlugins = require("@expo/config-plugins");
const code = `
$static_library = [
'React',
'Google-Maps-iOS-Utils',
'GoogleMaps',
'react-native-maps',
'react-native-google-maps',
'React-hermes'
]
pre_install do |installer|
Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
installer.pod_targets.each do |pod|
bt = pod.send(:build_type)
if $static_library.include?(pod.name)
puts "Overriding the build_type to static_library from static_framework for #{pod.name}"
def pod.build_type;
Pod::BuildType.static_library
end
end
end
installer.pod_targets.each do |pod|
bt = pod.send(:build_type)
puts "#{pod.name} (#{bt})"
puts " linkage: #{bt.send(:linkage)} packaging: #{bt.send(:packaging)}"
end
end`;
module.exports = (config) => {
return configPlugins.withDangerousMod(config, [
"ios",
async (config) => {
const filePath = path.join(config.modRequest.platformProjectRoot, "Podfile");
const contents = fs.readFileSync(filePath, "utf-8");
const addCode = generateCode.mergeContents({
tag: "withReactNativeFirebase",
src: contents,
newSrc: code,
anchor: /\s*get_default_flags\(\)/i,
offset: 2,
comment: "#",
});
if (!addCode.didMerge) {
console.error("ERROR: Cannot add withReactNativeMaps to the project's ios/Podfile because it's malformed.");
return config;
}
fs.writeFileSync(filePath, addCode.contents);
return config;
},
]);
};