@@ -2,6 +2,18 @@ var fs = require('fs');
22var path = require ( 'path' ) ;
33var prompt = require ( 'prompt-lite' ) ;
44
5+ const { execSync } = require ( 'child_process' ) ;
6+ const semver = require ( 'semver' ) ;
7+
8+ // iOS modern build system is supported from version NativeScript (CLI) version 5.2.0
9+ const tnsVersionFull = execSync ( 'tns --version' , { encoding : 'ascii' } ) ;
10+ const supportsIOSModernBuildSystem = tnsVersionFull . indexOf ( "5.2.0-" ) > - 1 || semver . gte ( tnsVersionFull , "5.2.0" ) ;
11+ console . log ( { supportsIOSModernBuildSystem} ) ;
12+
13+ if ( ! supportsIOSModernBuildSystem ) {
14+ console . log ( `You're using NativeScript ${ tnsVersionFull } .. which doesn't support the latest Firestore and in-app-messaging SDKs. Upgrade NativeScript to at least 5.2.0 if you need those!\n\n` ) ;
15+ }
16+
517// Default settings for a few prompts
618var usingiOS = false , usingAndroid = false , externalPushClientOnly = false ;
719
@@ -163,7 +175,7 @@ function promptQuestions() {
163175 default : 'n'
164176 } , {
165177 name : 'messaging' ,
166- description : 'Are you using Firebase Messaging? (y/n)' ,
178+ description : 'Are you using Firebase Cloud Messaging? (y/n)' ,
167179 default : 'n'
168180 } , {
169181 name : 'crashlytics' ,
@@ -255,7 +267,7 @@ function promptQuestionsResult(result) {
255267 writePodFile ( result ) ;
256268 }
257269 writeBuildscriptHookForCrashlytics ( isSelected ( result . crashlytics ) ) ;
258- writeBuildscriptHookForFirestore ( isSelected ( result . firestore ) ) ;
270+ writeBuildscriptHookForFirestore ( isSelected ( result . firestore ) && ! supportsIOSModernBuildSystem ) ;
259271 }
260272
261273 if ( usingAndroid ) {
@@ -341,7 +353,8 @@ function writePodFile(result) {
341353// The MLVision pod requires a minimum of iOS 9, otherwise the build will fail
342354( isPresent ( result . ml_kit ) ? `` : `#` ) + `platform :ios, '9.0'
343355
344- pod 'Firebase/Core', '~> 5.15.0'
356+ # With NativeScript < 5.2 we can't bump Firebase/Core beyond 5.15.0, but with 5.2+ we can
357+ pod 'Firebase/Core', '~> ` + ( supportsIOSModernBuildSystem ? '5.16.0' : '5.15.0' ) + `'
345358
346359# Authentication
347360` + ( ! isPresent ( result . authentication ) || isSelected ( result . authentication ) ? `` : `#` ) + `pod 'Firebase/Auth'
@@ -350,7 +363,9 @@ pod 'Firebase/Core', '~> 5.15.0'
350363` + ( ! isPresent ( result . realtimedb ) || isSelected ( result . realtimedb ) ? `` : `#` ) + `pod 'Firebase/Database'
351364
352365# Cloud Firestore (sticking to 0.14 for now because of build error - see https://github.com/firebase/firebase-ios-sdk/issues/2177)
353- ` + ( isSelected ( result . firestore ) ? `` : `#` ) + `pod 'FirebaseFirestore', '~> 0.14.0'
366+ ` + ( isSelected ( result . firestore ) && ! supportsIOSModernBuildSystem ? `` : `#` ) + `pod 'FirebaseFirestore', '~> 0.14.0'
367+ # .. unless the modern build system is supported, then we can use the latest version (NativeScript 5.2+)
368+ ` + ( isSelected ( result . firestore ) && supportsIOSModernBuildSystem ? `` : `#` ) + `pod 'Firebase/Firestore'
354369
355370# Remote Config
356371` + ( isSelected ( result . remote_config ) ? `` : `#` ) + `pod 'Firebase/RemoteConfig'
0 commit comments