Skip to content

Commit 3992fd0

Browse files
Daeda88avdyushin
andauthored
Upgrade firebase sdk and improve iOS build process (#78)
* Update FirebaseCore.def * Trying to resolve Firestore issues * Fixed compile for tests * Add missing firetore frameworks * Use Carthage instead of zip for linking. This cleans up dependencies and reduces build time * Track firestore version * Update yaml * Code cleanup Co-authored-by: Grigory Avdyushin <[email protected]>
1 parent e6d8487 commit 3992fd0

File tree

21 files changed

+113
-88
lines changed

21 files changed

+113
-88
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,10 @@ jobs:
2424
arguments: :updateVersions
2525
- name: Grant execute permission for gradlew
2626
run: chmod +x gradlew
27-
- name: Retrieve cache key
28-
id: cache-key
29-
uses: actions/cache@v2
30-
with:
31-
path: build/Firebase-6.17.0.zip
32-
key: key-Firebase-6.17.0
33-
restore-keys: key-Firebase-6.17.0
34-
- name: Download Firebase
35-
run: ./gradlew downloadIOSFirebaseZipFile
36-
- name: Expand Zip
37-
run: unzip build/Firebase-6.17.0.zip -d build
27+
- name: Install Homebrew
28+
run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
29+
- name: Install Carthage
30+
run: brew install carthage
3831
- name: Publish
3932
uses: eskatos/gradle-command-action@v1
4033
with:

.github/workflows/pull_request.yml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,10 @@ jobs:
2020
java-version: 1.8
2121
- name: Grant execute permission for gradlew
2222
run: chmod +x gradlew
23-
- name: Retrieve cache key
24-
id: cache-key
25-
uses: actions/cache@v2
26-
with:
27-
path: build/Firebase-6.17.0.zip
28-
key: key-Firebase-6.17.0
29-
restore-keys: key-Firebase-6.17.0
30-
- name: Download Firebase
31-
run: ./gradlew downloadIOSFirebaseZipFile
32-
- name: Expand Zip
33-
run: unzip build/Firebase-6.17.0.zip -d build
23+
- name: Install Homebrew
24+
run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
25+
- name: Install Carthage
26+
run: brew install carthage
3427
- name: Assemble
3528
run: ./gradlew assemble
3629
- name: Run JS Tests

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ firebase-database/src/iosMain/c_interop/modules/
1313
Firebase*.zip
1414
/Firebase
1515
/.DS_Store
16+
17+
18+
/**/Cartfile.resolved
19+
/**/c_interop/Carthage/

build.gradle.kts

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ buildscript {
1919
}
2020
}
2121
dependencies {
22-
classpath("com.android.tools.build:gradle:3.6.1")
22+
classpath("com.android.tools.build:gradle:4.0.1")
2323
classpath("de.undercouch:gradle-download-task:4.0.4")
2424
classpath("com.adarshr:gradle-test-logger-plugin:2.0.0")
2525
}
@@ -28,29 +28,7 @@ buildscript {
2828
val targetSdkVersion by extra(28)
2929
val minSdkVersion by extra(16)
3030

31-
3231
tasks {
33-
val downloadIOSFirebaseZipFile by creating(Download::class) {
34-
src("https://github.com/firebase/firebase-ios-sdk/releases/download/6.17.0/Firebase-6.17.0.zip")
35-
dest(File(buildDir, "Firebase-6.17.0.zip"))
36-
if (System.getenv("token") != null) {
37-
username(System.getenv("token"))
38-
}
39-
overwrite(false)
40-
}
41-
42-
val unzipIOSFirebase by creating(Copy::class) {
43-
if (!File("$buildDir/Firebase").exists()) {
44-
val zipFile = File(buildDir, "Firebase-6.17.0.zip")
45-
if (!zipFile.exists()) {
46-
dependsOn(downloadIOSFirebaseZipFile)
47-
}
48-
from(zipTree(zipFile))
49-
into(buildDir)
50-
}
51-
outputs.upToDateWhen { File("$buildDir/Firebase").isDirectory }
52-
}
53-
5432
val updateVersions by registering {
5533
dependsOn(
5634
"firebase-app:updateVersion", "firebase-app:updateDependencyVersion",
@@ -61,7 +39,6 @@ tasks {
6139
"firebase-functions:updateVersion", "firebase-functions:updateDependencyVersion"
6240
)
6341
}
64-
6542
}
6643

6744
subprojects {
@@ -172,6 +149,29 @@ subprojects {
172149
)
173150
}
174151
}
152+
153+
listOf("bootstrap", "update").forEach {
154+
task<Exec>("carthage${it.capitalize()}") {
155+
group = "carthage"
156+
executable = "carthage"
157+
args(
158+
it,
159+
"--project-directory", "src/iosMain/c_interop",
160+
"--platform", "iOS",
161+
"--cache-builds"
162+
)
163+
}
164+
}
165+
166+
withType(org.jetbrains.kotlin.gradle.tasks.CInteropProcess::class) {
167+
dependsOn("carthageBootstrap")
168+
}
169+
170+
create("carthageClean", Delete::class.java) {
171+
group = "carthage"
172+
delete(File("$projectDir/src/iosMain/c_interop/Carthage"))
173+
delete(File("$projectDir/src/iosMain/c_interop/Cartfile.resolved"))
174+
}
175175
}
176176

177177
// tasks.withType<KotlinCompile<*>> {
@@ -188,34 +188,33 @@ subprojects {
188188
mkdir("$buildDir/node_module")
189189
}
190190

191-
if(Os.isFamily(Os.FAMILY_MAC)) {
192-
tasks.getByPath("compileKotlinIos").dependsOn(rootProject.tasks.named("unzipIOSFirebase"))
193-
} else {
194-
println("Skipping Firebase zip download")
191+
tasks.named<Delete>("clean") {
192+
dependsOn("carthageClean")
195193
}
196194

197-
198195
dependencies {
199196
"commonMainImplementation"(kotlin("stdlib-common"))
200-
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.6")
197+
"commonMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.8")
201198
"jsMainImplementation"(kotlin("stdlib-js"))
202-
"jsMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.6")
203-
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6")
199+
"jsMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-js:1.3.8")
200+
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8")
204201
"androidMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.3.6")
205-
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.6")
206-
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.6")
202+
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.8")
203+
"iosMainImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-native:1.3.8")
207204
"commonTestImplementation"(kotlin("test-common"))
208205
"commonTestImplementation"(kotlin("test-annotations-common"))
209-
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.6")
210-
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.6")
206+
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-core-common:1.3.8")
207+
"commonTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.3.8")
211208
"jsTestImplementation"(kotlin("test-js"))
212209
"androidAndroidTestImplementation"(kotlin("test-junit"))
213-
"androidAndroidTestImplementation"("junit:junit:4.12")
210+
"androidAndroidTestImplementation"("junit:junit:4.13")
214211
"androidAndroidTestImplementation"("androidx.test:core:1.2.0")
215-
"androidAndroidTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.6")
212+
"androidAndroidTestImplementation"("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.8")
216213
"androidAndroidTestImplementation"("androidx.test.ext:junit:1.1.1")
217-
"androidAndroidTestImplementation"("androidx.test:runner:1.1.0")
214+
"androidAndroidTestImplementation"("androidx.test:runner:1.2.0")
218215
}
216+
217+
219218
}
220219

221220
apply(plugin="maven-publish")

firebase-app/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ kotlin {
6767
val iosX64 = iosX64("ios") {
6868
binaries {
6969
getTest("DEBUG").apply {
70-
linkerOpts("-F${rootProject.buildDir}/Firebase/FirebaseAnalytics")
70+
linkerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/")
7171
linkerOpts("-ObjC")
7272
}
7373
}
@@ -87,7 +87,7 @@ kotlin {
8787
}
8888
val androidMain by getting {
8989
dependencies {
90-
api("com.google.firebase:firebase-common:19.2.0")
90+
api("com.google.firebase:firebase-common:19.3.1")
9191
}
9292
}
9393

@@ -97,7 +97,7 @@ kotlin {
9797
val firebasecore by cinterops.creating {
9898
packageName("cocoapods.FirebaseCore")
9999
defFile(file("$projectDir/src/iosMain/c_interop/FirebaseCore.def"))
100-
compilerOpts("-F${rootProject.buildDir}/Firebase/FirebaseAnalytics")
100+
compilerOpts("-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/")
101101
}
102102
}
103103
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAnalyticsBinary.json" == 6.30.0
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language = Objective-C
22
modules = FirebaseCore
33
compilerOpts = -framework FirebaseCore
4-
linkerOpts = -framework FirebaseCore -framework FIRAnalyticsConnector -framework FirebaseAnalytics -framework FirebaseCore -framework FirebaseCoreDiagnostics -framework FirebaseInstallations -framework FirebaseInstanceID -framework GoogleAppMeasurement -framework GoogleDataTransport -framework GoogleDataTransportCCTSupport -framework GoogleUtilities -framework PromisesObjC -framework nanopb -framework StoreKit -lsqlite3
4+
linkerOpts = -framework FirebaseCore -framework FirebaseCoreDiagnostics -framework FirebaseAnalytics -framework FIRAnalyticsConnector -framework GoogleAppMeasurement -framework FirebaseInstallations -framework GoogleDataTransport -framework GoogleUtilities -framework PromisesObjC -framework nanopb -framework StoreKit -lsqlite3

firebase-auth/build.gradle.kts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,10 @@ kotlin {
7676
val iosX64 = iosX64("ios") {
7777
binaries {
7878
getTest("DEBUG").apply {
79-
linkerOpts("-F${rootProject.buildDir}/Firebase/FirebaseAnalytics")
80-
linkerOpts("-F${rootProject.buildDir}/Firebase/FirebaseAuth")
81-
linkerOpts("-F${rootProject.buildDir}/Firebase/GoogleSignIn")
79+
linkerOpts(
80+
"-F${rootProject.projectDir}/firebase-app/src/iosMain/c_interop/Carthage/Build/iOS/",
81+
"-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/")
8282
linkerOpts("-ObjC")
83-
// compilerOpts("-framework AppAuth")
8483
}
8584
}
8685
}
@@ -103,7 +102,7 @@ kotlin {
103102

104103
val androidMain by getting {
105104
dependencies {
106-
api("com.google.firebase:firebase-auth:19.1.0")
105+
api("com.google.firebase:firebase-auth:19.3.2")
107106
}
108107
}
109108

@@ -113,8 +112,9 @@ kotlin {
113112
val firebaseAuth by cinterops.creating {
114113
packageName("cocoapods.FirebaseAuth")
115114
defFile(file("$projectDir/src/iosMain/c_interop/FirebaseAuth.def"))
116-
compilerOpts("-F$projectDir/../build/Firebase/FirebaseAuth")
117-
compilerOpts("-F$projectDir/../build/Firebase/GoogleSignIn")
115+
compilerOpts(
116+
"-F$projectDir/src/iosMain/c_interop/Carthage/Build/iOS/"
117+
)
118118
}
119119
}
120120
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
binary "https://dl.google.com/dl/firebase/ios/carthage/FirebaseAuthBinary.json" == 6.30.0

firebase-common/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ kotlin {
6969
}
7070
val androidMain by getting {
7171
dependencies {
72-
api("com.google.firebase:firebase-common:19.2.0")
72+
api("com.google.firebase:firebase-common:19.3.0")
7373
api("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.20.0")
7474
}
7575
}

0 commit comments

Comments
 (0)