Skip to content

Commit

Permalink
(iOS) Use standard pod for Firestore by default but add `IOS_USE_PREC…
Browse files Browse the repository at this point in the history
…OMPILED_FIRESTORE_POD` plugin variable to switch to using pre-built version.

Should resolve #735.
  • Loading branch information
Dave Alden committed Jul 20, 2022
1 parent b68dac0 commit d1fb68a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ See [Specifying Android library versions](#specifying-android-library-versions)
- `ANDROID_GRPC_OKHTTP` - sets version of GRPC OKHTTP library.

### iOS only
- `IOS_USE_PRECOMPILED_FIRESTORE_POD` - if `true`, switches Podfile to use a [pre-compiled version of the Firestore pod](https://github.com/invertase/firestore-ios-sdk-frameworks.git) to reduce build time
- Since some users experienced long build times due to the Firestore pod (see [#407](https://github.com/dpa99c/cordova-plugin-firebasex/issues/407))
- However other users have experienced build issues with the pre-compiled version (see [#735](https://github.com/dpa99c/cordova-plugin-firebasex/issues/735))
- Defaults to `false` if not specified.
- `IOS_STRIP_DEBUG` - prevents symbolification of all libraries included via Cocoapods. See [Strip debug symbols](#strip-debug-symbols) for more info.
- e.g. `--variable IOS_STRIP_DEBUG=true`
- Defaults to `false` if not specified.
Expand Down
4 changes: 3 additions & 1 deletion plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
<hook type="after_plugin_install" src="scripts/ios/after_plugin_install.js" />
<hook type="before_plugin_uninstall" src="scripts/ios/before_plugin_uninstall.js" />

<preference name="IOS_USE_PRECOMPILED_FIRESTORE_POD" default="false" />

<js-module name="FirebasePlugin" src="www/firebase.js">
<clobbers target="FirebasePlugin" />
</js-module>
Expand Down Expand Up @@ -151,7 +153,7 @@
<pod name="Firebase/Performance" spec="9.1.0"/>
<pod name="Firebase/RemoteConfig" spec="9.1.0"/>
<pod name="Firebase/InAppMessaging" spec="9.1.0"/>
<pod name="FirebaseFirestore" git="https://github.com/invertase/firestore-ios-sdk-frameworks.git" tag="9.1.0"/>
<pod name="Firebase/Firestore" spec="9.1.0"/>
<pod name="Firebase/Crashlytics" spec="9.1.0"/>
<pod name="Firebase/Functions" spec="9.1.0"/>
<pod name="Firebase/Installations" spec="9.1.0"/>
Expand Down
2 changes: 2 additions & 0 deletions scripts/after_prepare.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var setupEnv = function(){
appPlist: IOS_DIR + '/' + appName + '/' + appName + '-Info.plist',
entitlementsDebugPlist: IOS_DIR + '/' + appName + '/Entitlements-Debug.plist',
entitlementsReleasePlist: IOS_DIR + '/' + appName + '/Entitlements-Release.plist',
podFile: IOS_DIR + '/Podfile'
},
ANDROID: {
dest: ANDROID_DIR + '/app/google-services.json',
Expand Down Expand Up @@ -143,5 +144,6 @@ module.exports = function(context){
helper.stripDebugSymbols();
}
helper.applyPluginVarsToPlists(pluginVariables, PLATFORM.IOS);
helper.applyPluginVarsToPodfile(pluginVariables, PLATFORM.IOS);
}
};
21 changes: 19 additions & 2 deletions scripts/ios/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ var plist = require('plist');
*/
var comment = "\"Crashlytics\"";

var standardFirestorePodRegEx = /pod 'Firebase\/Firestore', '([\d.]{5})'/,
prebuiltFirestorePodTemplate = "pod 'FirebaseFirestore', :tag => '{version}', :git => 'https://github.com/invertase/firestore-ios-sdk-frameworks.git'";

module.exports = {

/**
* Used to get the path to the XCode project's .pbxproj file.
*/
getXcodeProjectPath: function () {
var appName = utilities.getAppName();
return path.join("platforms", "ios", appName + ".xcodeproj", "project.pbxproj");
var appName = utilities.getAppName(); return path.join("platforms", "ios", appName + ".xcodeproj", "project.pbxproj");
},

/**
Expand Down Expand Up @@ -257,5 +259,20 @@ module.exports = {
fs.writeFileSync(path.resolve(iosPlatform.entitlementsDebugPlist), plist.build(entitlementsDebugPlist));
fs.writeFileSync(path.resolve(iosPlatform.entitlementsReleasePlist), plist.build(entitlementsReleasePlist));
}
},
applyPluginVarsToPodfile: function(pluginVariables, iosPlatform){
var podFileContents = fs.readFileSync(path.resolve(iosPlatform.podFile), 'utf8'),
podFileModified = false;

if(pluginVariables['IOS_USE_PRECOMPILED_FIRESTORE_POD'] === 'true'){
var standardFirestorePodMatches = podFileContents.match(standardFirestorePodRegEx);
if(standardFirestorePodMatches){
podFileContents = podFileContents.replace(standardFirestorePodMatches[0], prebuiltFirestorePodTemplate.replace('{version}', standardFirestorePodMatches[1]));
podFileModified = true;
console.log("Configured Podfile for pre-built Firestore pod");
}
}

if(podFileModified) fs.writeFileSync(path.resolve(iosPlatform.podFile), podFileContents);
}
};

0 comments on commit d1fb68a

Please sign in to comment.