StreetComplete on iOS is now in public beta

StreetComplete on iOS is now in public beta

StreetComplete iOS 版本现已进入公开测试阶段

This ticket is something like the master ticket to coordinate development on an iOS port of StreetComplete. It replaces #1892 which also included a lot of discussion and research / observation work. TLDR: Have a look at the Project Board for a list of tasks. Contributions are welcome! Also have a look at the Slides from SotM Europe 2024 talk (I added speaker notes to make this understandable when flipping through).

此工单旨在作为协调 StreetComplete iOS 移植版开发的“主工单”。它取代了之前的 #1892 工单,后者包含了大量的讨论、研究和观察工作。简而言之:请查看项目看板(Project Board)以获取任务列表。欢迎各界贡献!此外,也可以查看 SotM Europe 2024 演讲的幻灯片(我添加了演讲备注,以便在翻阅时更容易理解)。

Approach

技术方案

The code base of this app is written in 100% Kotlin, a modern programming language that is quite similar to Swift. Kotlin code can be transpiled to JavaScript and also to machine code, just like Swift. Furthermore, many dependencies of this app by now are pure Kotlin libraries. An iOS version of this app hence can be done with Kotlin Multiplatform.

该应用的源代码 100% 使用 Kotlin 编写,这是一种与 Swift 非常相似的现代编程语言。与 Swift 一样,Kotlin 代码可以转译为 JavaScript 或机器码。此外,该应用目前的许多依赖项都是纯 Kotlin 库。因此,可以通过 Kotlin Multiplatform(KMP)来实现该应用的 iOS 版本。

The UI code can be shared using Compose Multiplatform, which is currently in alpha beta for iOS. It is a fork/extension of Jetpack Compose with largely the same API. Jetpack Compose is a reactive UI framework in which developers define the UI completely in code (similar idea as SwiftUI, Flutter, …). We’ll have to re-create the entire UI (incrementally) in Compose, though. This will keep the amount of code that needs to be platform dependent (Android / iOS) to a minimum.

UI 代码可以使用 Compose Multiplatform 共享,该框架目前在 iOS 上处于 Alpha/Beta 阶段。它是 Jetpack Compose 的一个分支/扩展,API 基本相同。Jetpack Compose 是一个响应式 UI 框架,开发者可以在其中完全通过代码定义 UI(理念类似于 SwiftUI、Flutter 等)。不过,我们需要在 Compose 中(逐步)重新创建整个 UI。这将使需要针对特定平台(Android/iOS)编写的代码量降至最低。

In comparison to using the framework Flutter for multiplatform (as used by Every Door), it allows us to largely not touch the Kotlin codebase. When using Flutter, we’d need to rewrite it all in Dart.

与使用 Flutter 框架进行多平台开发(如 Every Door 所采用的方式)相比,这种方案让我们基本无需改动现有的 Kotlin 代码库。如果使用 Flutter,我们将需要用 Dart 重写所有代码。

Steps in a nutshell

简要步骤

  1. Separate all platform specific code from application logic.

  2. Replace Android/Java dependencies for application logic with Kotlin multiplatform dependencies.

  3. Incrementally migrate the UI code to Compose Multiplatform:

    • Separate data access and UI state code from pure UI code (use view models).
    • Migrate the UI code that currently uses Android XML layouts to Android Jetpack Compose. This can be done incrementally when done bottom-up.
    • Then, migrate from Jetpack Compose to Compose Multiplatform. This is a small step compared with the first one.
  4. 将所有平台特定的代码与应用逻辑分离。

  5. 将应用逻辑中的 Android/Java 依赖项替换为 Kotlin 多平台依赖项。

  6. 将 UI 代码逐步迁移到 Compose Multiplatform:

    • 将数据访问和 UI 状态代码与纯 UI 代码分离(使用 ViewModels)。
    • 将目前使用 Android XML 布局的 UI 代码迁移到 Android Jetpack Compose。如果采用自下而上的方式,可以逐步完成。
    • 然后,从 Jetpack Compose 迁移到 Compose Multiplatform。与第一步相比,这一步的工作量较小。

Current State

当前状态

This section will be updated continuously. The steps necessary are described in detail in a Kanban-style Project Board. Unless stated otherwise, they are explicitly up for the taking by people who read this and want to contribute to the development towards an iOS port. If you would like to implement one of the tasks described, comment in that ticket.

本节将持续更新。必要的步骤已在看板风格的项目看板中详细描述。除非另有说明,否则阅读此文并希望为 iOS 移植开发做出贡献的人员均可认领这些任务。如果您想实现其中某个任务,请在该工单下留言。

We very roughly estimated some time ago that developing a full port to iOS would take one man-year of work. So, the scope of this remains very large. We will only realistically achieve it together with lots of contributions from the community. Luckily, this is exactly what has been happening in the last years. In the first half of 2024, I have been able to work on this full-time. The migration is now about 50% complete. So, let’s shift gears!

我们之前粗略估计,开发完整的 iOS 移植版大约需要一年的工作量。因此,其规模仍然非常庞大。只有通过社区的大量贡献,我们才能真正实现这一目标。幸运的是,这正是过去几年所发生的情况。在 2024 年上半年,我能够全职投入这项工作。目前迁移进度已完成约 50%。那么,让我们加快步伐吧!

How you can help

您可以如何提供帮助

  • You could take over a task from the project board!

  • Or, you could familiarize yourself with the mentioned technologies / frameworks to make meaningful contributions later. In particular: Jetpack Compose / Compose Multiplatform.

  • You can sponsor development! See the title “Sponsor this project” in the sidebar on the main page. More money allows me to devote more time to development on this app in general.

  • You can help with maintenance and issue triage in general. Time saved on that is time I can put into furthering development on this!

  • 您可以从项目看板中认领一个任务!

  • 或者,您可以熟悉上述提到的技术/框架,以便日后做出有意义的贡献。特别是:Jetpack Compose / Compose Multiplatform。

  • 您可以赞助开发!请查看主页侧边栏中的“Sponsor this project”标题。更多的资金能让我投入更多时间进行该应用的开发。

  • 您可以协助进行日常的维护和工单分类。节省下来的时间,我就可以投入到进一步的开发工作中!