Kotlin Multiplatform by Tutorials: Build Native Apps Faster by Sharing Code Across Platforms. 2 Ed

Kotlin Multiplatform by Tutorials: Build Native Apps Faster by Sharing Code Across Platforms. 2 Ed

Kotlin Multiplatform by Tutorials: Build Native Apps Faster by Sharing Code Across Platforms. 2 Ed
Автор: Kodeco Team, Moore Kevin D., Mota Carlos, Taheri Saeed
Дата выхода: 2023
Издательство: Kodeco Inc
Количество страниц: 488
Размер файла: 4.4 MB
Тип файла: PDF
Добавил: codelibs
 Проверить на вирусы

Book License....11

What You Need....13

Book Source Code & Forums....14

About the Authors....16

About the Editors....17

Introduction....18

How to Read This Book....19

Chapter 1: Introduction....22

What Is Kotlin Multiplatform?....23

Setting Up Your Environment....30

Creating Your First Project....34

Key Points....43

Where to Go From Here?....43

Chapter 2: Getting Started....44

Getting to Know Gradle....45

Version Catalog....45

Build Files....50

Find Time....56

Business Logic....57

Challenge....69

Key Points....70

Where to Go From Here?....70

Chapter 3: Developing UI: Android Jetpack Compose....71

UI Frameworks....72

Jetpack Compose....72

Time Finder....75

Time Zone Screen....92

Find Meeting Time Screen....102

Key Points....111

Where to Go From Here?....111

Chapter 4: Developing UI: iOS SwiftUI....112

Getting to Know SwiftUI....115

Key Points....135

Where to Go From Here?....135

Chapter 5: Developing UI: Compose Multiplatform....136

Getting to Know Compose Multiplatform....137

Creating a Desktop App....137

Shared UI....142

Key Points....163

Where to Go From Here?....163

Chapter 6: Connecting to Platform-Specific API....165

Reusing Code Between Platforms....166

Say Hello to Organize....166

Updating the Platform Class....168

Updating the UI....179

Challenge....191

Key Points....191

Where to Go From Here?....191

Chapter 7: App Architecture....192

Design Patterns....193

Sharing Business Logic....197

Creating Reminders Section....204

Sharing Tests and UI....215

Challenge....216

Key Points....217

Chapter 8: Testing....218

Setting Up the Dependencies....219

Writing Tests for RemindersViewModel....221

Writing Tests for Platform....224

UI Tests....227

Challenge....238

Key Points....238

Where to Go From Here?....239

Chapter 9: Dependency Injection....240

Advantages of Dependency Injection....241

Automated DI vs. Manual DI....241

Setting Up Koin....243

Using Koin on Each Platform....246

Updating AboutViewModel....252

Testing....254

Key Points....257

Where to Go From Here?....258

Chapter 10: Data Persistence....259

Key-Value Storage....260

Database....270

Challenge....283

Key Points....284

Where to Go From Here?....284

Chapter 11: Serialization....286

The Need for Serialization....287

Project Overview....287

Application Features....291

Adding Serialization to Your Gradle Configuration....292

Different Serialization Formats....294

Creating a Custom Serializer....295

Serializing/Deserializing New Data....297

Serializable vs. Parcelable....300

Implementing Parcelize in KMP....300

Sharing Your Data Classes With the Server....304

Testing....307

Challenges....310

Key Points....311

Where to Go From Here?....311

Chapter 12: Networking....312

The Need for a Common Networking Library....313

Adding Ktor....313

Connecting to the API With Ktor....314

Plugins....317

Retrieving Content....322

Adding Headers to Your Request....333

Uploading Files....337

Testing....340

Challenge....343

Challenge: Send Your Package Name in a Request Header....343

Key Points....344

Where to Go From Here?....344

Chapter 13: Concurrency....345

Concurrency and the Need for Structured Concurrency....346

Understanding kotlinx.coroutines....347

Structured Concurrency in iOS....354

Using kotlinx.coroutines....355

Working With kotlinx.coroutines....356

Improving Coroutines Usage for Native Targets....368

Challenge....379

Key Points....380

Where to Go From Here?....380

Chapter 14: Creating Your KMP Library....381

Migrating an Existing Feature to Multiplatform....382

Publishing Your KMP Library....400

Handling Multiple Frameworks....412

Challenges....413

Key Points....414

Where to Go From Here?....415

Conclusion....416

Appendix A: Kotlin: A Primer for Swift Developers....418

Kotlin and Swift: Comparing Both Languages....418

Kotlin and Swift Syntax Table....439

Where to Go From Here?....439

Appendix B: Debugging Your Shared Code From Xcode....440

Debugging the Shared Module....441

Where to Go From Here?....448

Appendix C: Sharing Your Compose UI Across Multiple Platforms....449

Setting Up an iOS App to Use Compose Multiplatform....449

Updating Your Project Structure....453

Sharing Your UI Code....456

Migrating Your Android UI Code to Multiplatform....456

Compose Multiplatform....460

Using Third-Party Libraries....463

Handling Resources....468

What’s Missing?....481

Where to Go From Here?....488

Application developers have to often repeat the same code across multiple platforms, which is not only time-consuming but also error-prone. Most documentation targets only specific use cases but misses out on the nuances essential to sharing code effectively across platforms.

Kotlin Multiplatform by Tutorials will help you efficiently implement real-world apps for different platforms by sharing common code.

Who This Book is For

This book is for mobile developers and managers who want to explore how they can use Kotlin Multiplatform to share code across Android, iOS and desktop apps. If you want to reduce development and testing time by writing certain parts of your apps only once, this book will help.

Topics Covered in Kotlin Multiplatform by Tutorials

  • Jetpack Compose Android: Use Android's latest UI toolkit to quickly spin up the UI for different screens of your Android app.
  • Compose Multiplatform: Use the concepts you learned in Jetpack Compose Android to develop the UI for desktop apps.
  • SwiftUI: Learn how to develop the UI for iOS and macOS apps entirely in Swift.
  • Testing: Make your code reliable by writing tests for both common code as well as platform-specific code.
  • Koin: Learn about dependency injection and how you can use Koin to implement dependency injection in multiplatform apps.
  • SQLDelight: Create a common persistence layer for your multiplatform apps while also getting the benefits of compile-time safety for schemas, statements and migrations.
  • Serialization: Learn about different serialization formats and how you can use them to parse JSON data fetched from the Internet.
  • Ktor: Implement a common networking layer with support for platform-specific HTTP clients.
  • Coroutines: Learn about structures concurrency and the considerations to keep in mind while using coroutines on different platforms.

One thing you can count on: After reading this book, you’ll be prepared to create modules where you can write your code only once but target multiple platforms.


Похожее:

Список отзывов:

Нет отзывов к книге.