Files
kornerr 45ca185094 Create hello-platform for Android (#12)
Co-authored-by: Михаил Капелько <kornerr@gmail.com>
2026-11-01 15:52:24 +01:00

3.3 KiB

OGS applications (mj)

Native SwiftUI and Compose apps on the Dialect v4 declarative reactive engine. Remote: https://git.opengamestudio.org/mahjong/mahjong.

Apps

  • hello/hello-platform/ — macOS + iOS + Android platform-support sample (Hello counter). Its structure, startup flow and dialect rules are in docs/hello-platform.md; read that file whenever anything from hello-platform is referenced.

Layout

  • <app>/dialect.yml → generates <app>/ver-mac/src/dialect.swift and <app>/ver-android/.../dialect.kt.
  • components/ — shared source of truth; app src/ entries are relative symlinks: edit the real files and keep symlink parity.
  • hello-platform uses components/hp/ for its component, view models and views (mac/, ios/, android/), and components/other/ for shared helpers.
  • history/gitjs/ — historical JS reference, outside the build.

Build

Prereqs: sibling ../dialect checkout (util/build-generator).

cd hello/hello-platform
util/build-mac
util/run-mac
util/prepare-ios    # xcodegen; xcodebuild command is in docs/hello-platform.md
util/prepare-android # generate dialect.kt; gradlew command is in docs/hello-platform.md

build-mac regenerates Dialect, runs swift build in ver-mac/, then packages the binary and ver-mac/res/ into ver-mac/.build/<App Name>.app. ver-ios/ mirrors ver-mac/ and shares dialect.swift, HPView and the app icon via symlinks. ver-android/ has its own generated dialect.kt and Compose view. Kotlin output is LLM-transpiled: run ollama serve before generating (model qwen2.5-coder:3b). Dangling-symlink audit: find components hello -type l ! -exec test -e {} \; -not -path '*/.build/*'

iOS simulator: use IVA (EB867790-F2C0-4392-9F99-C509D4487FDA, iPhone 17, iOS 26.5), not iPhone 15 Pro. Android emulator: Small_30 (-gpu swiftshader_indirect avoids a headless crash).

Dialect

  • Edit <app>/dialect.yml / components/, then util/build-mac; manual edits to the generated dialect.swift / dialect.kt are overwritten.
  • struct F (field names) exists only in the generated files: a new field needs static let <field> = "<field>" hand-patched in ASCII order in both dialect.swift and dialect.kt or F.<field> will not build.
  • Validate: ruby -ryaml -e 'YAML.load_file("hello/hello-platform/dialect.yml")'. Every should-label (1. Upon each ...) MUST end with a colon — ../dialect/components/yml/ymlFun.swift blindly dropLast()s it. Complaints inside if:/then: (unquoted : ) are expected.

Conventions

  • Mirror Swift/iOS into Android (naming, text, layout, styling).
  • Compose: named MaterialTheme.typography styles over fontSize.
  • Kotlin: wildcard imports for multiple declarations from one package, including generated ones; subpackages need separate imports.
  • .build/, build/, .DS_Store, Xcode/Gradle artifacts are git-ignored.

Source studies

Follow docs/file-summary.md (single-file) and docs/mirror-summary.md (mirrored platforms: one self-contained HTML with aligned function starts, original line numbers, green/orange fills, counts, non-repetitive explanations); never substitute working-tree code for a requested historical revision.