-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_ios_podfile_plugin.js
69 lines (62 loc) · 2.58 KB
/
update_ios_podfile_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
63
64
65
66
67
68
69
const { withDangerousMod, withPlugins } = require("@expo/config-plugins")
const { mergeContents } = require("@expo/config-plugins/build/utils/generateCode")
const fs = require("fs")
const path = require("path")
async function readFileAsync(path) {
return fs.promises.readFile(path, "utf8")
}
async function saveFileAsync(path, content) {
return fs.promises.writeFile(path, content, "utf8")
}
const withUseFrameworksHacks = (c) => {
return withDangerousMod(c, [
"ios",
async (config) => {
const file = path.join(config.modRequest.platformProjectRoot, "Podfile")
const contents = await readFileAsync(file)
await saveFileAsync(file, addUseFrameworksHacks(contents))
return config
},
])
}
function addUseFrameworksHacks(src) {
src = mergeContents({
tag: `rn-firebase-use-frameworks-hacks`,
src,
newSrc: `$RNFirebaseAsStaticFramework = true`,
anchor: /platform :ios/,
offset: 0,
comment: "#",
}).contents
src = mergeContents({
tag: `rn-firebase-use-frameworks-hacks-header-paths`,
src,
newSrc: `
#Fix bug where headers get set as "Project" files instead of "Public" when cocoapods traverses symlinks
installer.pods_project.targets.each do |target|
puts "target ? #{target.name}"
if (target.respond_to?(:headers_build_phase) && target.name.include?("React-bridging"))
puts "target has headers build phase, setting public attrs"
target.headers_build_phase.files.each do |file|
puts "setting attributes on header build phase #{file.file_ref.name}"
file.settings = { 'ATTRIBUTES' => ['Public'] }
end
end
end
#Fix search paths for React-bridging
installer.target_installation_results.pod_target_installation_results.each do |pod_name, target_installation_result|
target_installation_result.native_target.build_configurations.each do |config|
# For third party modules who have React-bridging dependency to search correct headers
config.build_settings['HEADER_SEARCH_PATHS'] ||= '$(inherited) '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_ROOT)/Headers/Private/React-bridging" '
config.build_settings['HEADER_SEARCH_PATHS'] << '"$(PODS_CONFIGURATION_BUILD_DIR)/React-bridging/_.framework/Headers" '
end
end
`,
anchor: /react_native_post_install\(installer\)/,
offset: 0,
comment: "#",
}).contents
return src
}
module.exports = (config) => withPlugins(config, [withUseFrameworksHacks])