The document discusses Kotlin Multiplatform Mobile (KMM), which allows sharing code across Android and iOS platforms. It provides an overview of what KMM is and isn't, how it works using expect/actual keywords and interfaces, integration methods, requirements, documentation, sample projects, libraries, benefits and challenges. Key points are that KMM allows a single codebase for business logic across platforms, saves development time, provides a single source of truth, but concurrency and debugging can be challenging.
24. // Common
interface TwitterCredentialsProvider {
var bearerToken: String
val consumerKey: String
val consumerSecret: String
}
// androidApp
object TwitterCredentialsDataProvider : TwitterCredentialsProvider {
override var bearerToken: String = String()
override val consumerKey: String
get() = BuildConfig.CONSUMER_KEY
override val consumerSecret: String
get() = BuildConfig.CONSUMER_SECRET
}
@emmakoko96
25. // Common
interface TwitterCredentialsProvider {
var bearerToken: String
val consumerKey: String
val consumerSecret: String
}
// iOSApp
class TwitterCredentialsDataProvider: TwitterCredentialsProvider {
static let shared: TwitterCredentialsProvider = TwitterCredentialsDataProvider()
private let infoDict: [String: Any]?
init() {
infoDict = Bundle.main.infoDictionary
}
var bearerToken: String = String()
var consumerKey: String {
return (infoDict?["TWITTER_CONSUMER_KEY"] as? String) ?? String()
}
var consumerSecret: String {
return (infoDict?["TWITTER_CONSUMER_SECRET"] as? String) ?? String()
}
}
@emmakoko96
26. Benefits of Interface
→ Platform specific code can be easily managed
→ Testing is easier as you can mock easily
→ Useful when handling concurrency with Kotlin
Native
@emmakoko96
48. KMM Libraries
→ Ktor for network requests
→ Coroutines for asynchronous programming
→ SQLDelight for data storage
and lots more...
KMM Libraries - https://libs.kmp.icerock.dev/
54. The not so Good
→ Concurrency/Memory Management not fun
Blog Post: https://emmanuelkehinde.io/supporting-multithreaded-coroutines-in-a-kotlin-multiplatform-project
55. The not so Good
→ Concurrency/Memory Management not fun
→ Debugging from Xcode still a concern
Xcode Plugin: https://github.com/touchlab/xcode-kotlin