Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Commit

Permalink
Update for talk
Browse files Browse the repository at this point in the history
  • Loading branch information
kpgalligan committed Nov 5, 2019
1 parent c38b414 commit a3a0d4c
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 136 deletions.
30 changes: 30 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 36 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
# Mach 7 for Android
# Firestore SDK for Kotlin Multiplatform

Library wrapping the Firestore SDK for Kotlin Multiplatform with clients for Android and iOS. Shared common code can
run methods that get delegated to the platform specific SDKs.

This was originally for a client and now is being used as an example library for a talk on KMP libraries. We'll probably
archive this pretty soon because it'll be a lot of support.

## Usage

Use Koltin 1.3.50.

Dependency config

```groovy
sourceSets {
commonMain {
dependencies {
implementation 'co.touchlab:firestore:0.2.5'
}
}
}
```

You'll need to config both Android and iOS as you normally would for Firestore, but then you should be able to get the
Firestore instance like this.

```kotlin
getFirebaseInstance()
```

Then you can do Firestore things.

## Droidcon

[See live example here](https://github.com/touchlab/DroidconKotlin/blob/master/sessionize/lib/src/commonMain/kotlin/co/touchlab/sessionize/SponsorModel.kt#L25)
12 changes: 8 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
ext.kotlin_version = '1.3.41'
ext.kotlin_version = '1.3.50'

ext.versions = [
'minSdk': 9,
'compileSdk': 28,

'kotlin': '1.3.41',
'kotlin': '1.3.50',

'androidPlugin': '3.4.1',
'androidTools': '29.0.1',
Expand All @@ -17,12 +17,14 @@ buildscript {
'firebaseCoreAndroid': '17.0.1',
'firebaseFirestoreAndroid': '20.1.0',

'stately': '0.9.2',
'coroutines': '1.3.0-RC'
'stately': '0.9.3',
'coroutines': '1.3.0'

]

repositories {
mavenLocal()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
google()
jcenter()
mavenCentral()
Expand All @@ -40,6 +42,8 @@ buildscript {

allprojects {
repositories {
mavenLocal()
maven { url 'https://dl.bintray.com/kotlin/kotlin-eap' }
google()
jcenter()
mavenCentral()
Expand Down
10 changes: 0 additions & 10 deletions firebase-test/src/commonMain/kotlin/sample/ExampleTests.kt

This file was deleted.

25 changes: 0 additions & 25 deletions firebase-test/src/commonMain/kotlin/sample/Sample.kt

This file was deleted.

18 changes: 0 additions & 18 deletions firebase-test/src/commonTest/kotlin/sample/SampleTests.kt

This file was deleted.

23 changes: 0 additions & 23 deletions firebase-test/src/iosMain/kotlin/sample/SampleIos.kt

This file was deleted.

11 changes: 0 additions & 11 deletions firebase-test/src/iosTest/kotlin/sample/SampleTestsIOS.kt

This file was deleted.

8 changes: 0 additions & 8 deletions firebase-test/src/main/java/sample/SampleAndroid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,6 @@ import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView

actual class Sample {
actual fun checkMe() = 44
}

actual object Platform {
actual val name: String = "Android"
}

class MainActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
Expand Down
11 changes: 0 additions & 11 deletions firebase-test/src/test/java/sample/SampleTestsAndroid.kt

This file was deleted.

47 changes: 24 additions & 23 deletions firestore/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ dependencies {

implementation 'androidx.appcompat:appcompat:1.0.2'
testImplementation 'junit:junit:4.12'
// androidTestImplementation 'androidx.test:runner:1.1.1'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
}

dokka {
Expand Down Expand Up @@ -81,23 +79,9 @@ kotlin {
android {
publishAllLibraryVariants()
}
// iosArm64()
iosX64("ios"){
compilations["main"].cinterops {
firebasecore {
packageName 'cocoapods.FirebaseCore'
defFile = file("$projectDir/src/iosMain/c_interop/FirebaseCore.def")
includeDirs ("$projectDir/../iosApp/Pods/FirebaseCore/Firebase/Core/Public")
compilerOpts ("-F$projectDir/src/iosMain/c_interop/modules/FirebaseCore-${versions.firebaseCoreIos}")
}
firestore {
packageName 'cocoapods.FirebaseFirestore'
defFile = file("$projectDir/src/iosMain/c_interop/FirebaseFirestore.def")
includeDirs ("$projectDir/../iosApp/Pods/FirebaseFirestore/Firestore/Source/Public", "$projectDir/../iosApp/Pods/FirebaseCore/Firebase/Core/Public")
compilerOpts ("-F$projectDir/src/iosMain/c_interop/modules/FirebaseFirestore-${versions.firebaseFirestoreIos}")
}
}
}

iosArm64()
iosX64()

sourceSets {
commonMain {
Expand Down Expand Up @@ -133,7 +117,6 @@ kotlin {
implementation 'junit:junit:4.12'
implementation "androidx.test:core:1.2.0"
implementation "androidx.test.ext:junit:1.1.1"
// implementation "org.robolectric:robolectric:4.0"
}
}

Expand All @@ -147,15 +130,33 @@ kotlin {
iosTest {
dependsOn commonTest
}

configure([targets.iosX64,
targets.iosArm64
]) {
compilations.main.source(sourceSets.iosMain)
compilations.test.source(sourceSets.iosTest)
compilations["main"].cinterops {
firebasecore {
packageName 'cocoapods.FirebaseCore'
defFile = file("$projectDir/src/iosMain/c_interop/FirebaseCore.def")
includeDirs ("$projectDir/../iosApp/Pods/FirebaseCore/Firebase/Core/Public")
compilerOpts ("-F$projectDir/src/iosMain/c_interop/modules/FirebaseCore-${versions.firebaseCoreIos}")
}
firestore {
packageName 'cocoapods.FirebaseFirestore'
defFile = file("$projectDir/src/iosMain/c_interop/FirebaseFirestore.def")
includeDirs ("$projectDir/../iosApp/Pods/FirebaseFirestore/Firestore/Source/Public", "$projectDir/../iosApp/Pods/FirebaseCore/Firebase/Core/Public")
compilerOpts ("-F$projectDir/src/iosMain/c_interop/modules/FirebaseFirestore-${versions.firebaseFirestoreIos}")
}
}
}
}

cocoapods {
// Configure fields required by CocoaPods.
summary = "Firebase Firestore"
homepage = "https://github.com/touchlab/FirestoreKMP"
//
// pod("FirebaseCore", "~> 6.0.2")
// pod("FirebaseFirestore", "~> 1.3.2")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ expect fun Query.addSnapshotListener_(
expect fun Query.endAt(documentSnapshot: DocumentSnapshot): Query
expect fun Query.endBefore(documentSnapshot: DocumentSnapshot): Query
expect fun Query.startAfter(documentSnapshot: DocumentSnapshot): Query
//expect fun Query.startAt(vararg fields: Any): Query
expect fun Query.startAt(documentSnapshot: DocumentSnapshot): Query
expect fun Query.whereEqualTo(field: String, value: Any): Query
expect fun Query.whereGreaterThan(field: String, value: Any): Query
Expand Down
7 changes: 5 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ android.useAndroidX=true
android.enableJetifier=true

GROUP=co.touchlab
VERSION_NAME=0.2.1
VERSION_NAME=0.2.5

POM_URL=https://github.com/touchlab/FirestoreKMP
POM_DESCRIPTION=Firebase Firestore wrapper library
Expand All @@ -34,4 +34,7 @@ POM_LICENCE_DIST=repo
POM_DEVELOPER_ID=kpgalligan
POM_DEVELOPER_NAME=Kevin Galligan
POM_DEVELOPER_ORG=Kevin Galligan
POM_DEVELOPER_URL=https://touchlab.co/
POM_DEVELOPER_URL=https://touchlab.co/

org.gradle.internal.http.connectionTimeout=1240000
org.gradle.internal.http.socketTimeout=1240000

0 comments on commit a3a0d4c

Please sign in to comment.