-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfirebase-mods.js
43 lines (38 loc) · 1.27 KB
/
firebase-mods.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
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 withFirebaseMods = (c) => {
return withDangerousMod(c, [
'ios',
async (config) => {
const file = path.join(config.modRequest.platformProjectRoot, 'Podfile')
const contents = await readFileAsync(file)
await saveFileAsync(file, addFirebaseConfigsToPodFile(contents))
return config
},
])
}
function addFirebaseConfigsToPodFile(src) {
return mergeContents({
tag: 'firebase-mods',
src,
newSrc: `
# install react-native-firebase as a static framework
$RNFirebaseAsStaticFramework = true
pod 'Firebase', :modular_headers => true
pod 'FirebaseCore', :modular_headers => true
pod 'GoogleUtilities', :modular_headers => true
`,
anchor: /platform :ios/,
offset: 0,
comment: '#',
}).contents
}
module.exports = (config) => withPlugins(config, [withFirebaseMods])