Create hello-platform for iOS (#11)
Co-authored-by: Михаил Капелько <kornerr@gmail.com>
This commit is contained in:
1 parent
1aa218d0bb
commit
cf79e89dc4
18 files changed
+288
-57
No files matched your search
@@ -3,82 +3,58 @@
|
||||
Native SwiftUI apps on the Dialect v4 declarative reactive engine (v2.0.0).
|
||||
Remote: `https://git.opengamestudio.org/mahjong/mahjong`.
|
||||
|
||||
## Status
|
||||
## Apps
|
||||
|
||||
- `ogs-blue/` — active minimal example (macOS + iOS): solid blue raylib background
|
||||
under a SwiftUI overlay; no model/texture/shadow scene.
|
||||
- `ogs-mahjong/` — macOS scaffold + counter template; no gameplay.
|
||||
- `ogs-chkgfx/` — companion graphics scaffold; targets lag shared-component changes.
|
||||
- `game/ver-mac` and the root `dialect.yml` layout are obsolete.
|
||||
- `hello/hello-platform/` — macOS + iOS platform-support sample (Hello counter). Its
|
||||
structure, startup flow and dialect rules are in
|
||||
[docs/hello-platform.md](docs/hello-platform.md); read that file whenever anything
|
||||
from hello-platform is referenced.
|
||||
|
||||
## Layout
|
||||
|
||||
- `<app>/dialect.yml` → `<app>/ver-mac/src/dialect.swift` (Blue iOS links to it).
|
||||
- `<app>/dialect.yml` → generates `<app>/ver-mac/src/dialect.swift`.
|
||||
- `components/` — shared source of truth; app `src/` entries are relative symlinks:
|
||||
edit the real files and keep symlink parity.
|
||||
- `components/render/` — shared model/constants + mirrored `ios/`/`mac/` effects,
|
||||
helpers, views (`renderConstMac.swift` = native pixel format).
|
||||
- Single-header C: `raybri/raybri.h` (`RAYBRI_IMPLEMENTATION`) + `raybriConst.h` +
|
||||
`mac/raybriAux.h`; `egl/egl.h` (`EGL_IMPLEMENTATION`) + `eglConst.h`;
|
||||
`ogs-blue/ver-{mac,ios}/src/Blue.c` are the platform translation units.
|
||||
- `hello-platform` uses `components/hp/` for its component, view model and shared
|
||||
SwiftUI view, and `components/other/` for shared helpers.
|
||||
- `history/gitjs/` — historical JS reference, outside the build.
|
||||
|
||||
## GL rules
|
||||
|
||||
Never call raylib / `raybri_*` without making the view's GL context current on the
|
||||
calling thread; `rlLoadExtensions` needs a current context and precedes `rlglInit`.
|
||||
|
||||
macOS: `NSOpenGLView` (3.2 Core); `renderInit` makes it current, enables VSync, loads
|
||||
extensions via the C loader, starts raylib. Timer → `needsDisplay`; `draw(_:)` →
|
||||
`renderDraw` activates the context, renders, `flushBuffer`s.
|
||||
|
||||
iOS: `RenderGLView.st` owns an `EGLState`; effects create EGL/ANGLE state and surface,
|
||||
make it current, init raylib. Timer renders directly, `eglSwapBuffers` presents.
|
||||
Resize → `renderRecreateSurface` (macOS no-op). Teardown: stop timer → activate
|
||||
context → release rlgl → destroy EGL surface/context/display.
|
||||
|
||||
Blue iOS bridges via `src/BlueBridgingHeader.h`; `Blue.c` compiles EGL helpers and rlgl
|
||||
with their implementation macros once, uses raylib-iOS XCFramework headers but not its
|
||||
library, links/embeds ANGLE `libEGL` + `libGLESv2`. XcodeGen sets `PLATFORM_IOS`,
|
||||
`GRAPHICS_API_OPENGL_ES3`, `GL_GLEXT_PROTOTYPES`; min iOS 15.0. SPM target
|
||||
`RaylibBridge` compiles `src/Blue.c`, exposes `src/raybri` headers, links Homebrew
|
||||
raylib but NOT `RLGL_IMPLEMENTATION` (headers lack `external/glad.h`).
|
||||
|
||||
## Build
|
||||
|
||||
Prereqs: `brew install raylib xcodegen`; siblings `../dialect` (`util/build-generator`)
|
||||
and `../raylib-ios-xcframeworks` (raylib + libEGL/libGLESv2; presence checked only).
|
||||
Prereqs: sibling `../dialect` checkout (`util/build-generator`).
|
||||
|
||||
```sh
|
||||
util/build-ogs-blue-mac
|
||||
util/run-ogs-blue-mac
|
||||
util/prepare-ogs-blue-ios
|
||||
xcodebuild -project 'ogs-blue/ver-ios/OGS blue.xcodeproj' -scheme ogs-blue \
|
||||
-sdk iphonesimulator -destination 'generic/platform=iOS Simulator' \
|
||||
CODE_SIGNING_ALLOWED=NO build
|
||||
cd hello/hello-platform
|
||||
util/build-mac
|
||||
util/run-mac
|
||||
util/prepare-ios # xcodegen; xcodebuild command is in docs/hello-platform.md
|
||||
```
|
||||
|
||||
macOS scripts regenerate Dialect, `swift build`, then package `ver-mac/res/` into
|
||||
`ver-mac/.build/<App Name>.app`. iOS also checks XCFrameworks, stages ANGLE symlinks in
|
||||
`ver-ios/.build/`, then runs XcodeGen (same scripts for `ogs-chkgfx`/`ogs-mahjong`).
|
||||
`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.
|
||||
Dangling-symlink audit:
|
||||
`find components ogs-blue ogs-chkgfx ogs-mahjong -type l ! -exec test -e {} \; -not -path '*/.build/*'`
|
||||
`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.
|
||||
|
||||
## Dialect
|
||||
|
||||
- Edit `<app>/dialect.yml` / `components/`, then `util/build-<app>-mac`; manual edits to
|
||||
the generated `dialect.swift` are overwritten.
|
||||
- Edit `<app>/dialect.yml` / `components/`, then `util/build-mac`; manual edits to the
|
||||
generated `dialect.swift` are overwritten.
|
||||
- `struct F` (field names) exists only in `dialect.swift`: a new field needs
|
||||
`static let <field> = "<field>"` hand-patched in ASCII order or `F.<field>` won't build.
|
||||
- Validate: `ruby -ryaml -e 'YAML.load_file("ogs-blue/dialect.yml")'`. Every should-label
|
||||
(`1. Upon each ...`) MUST end with a colon — `components/yml/ymlFun.swift` blindly
|
||||
`dropLast()`s it. Complaints inside `if:`/`then:` (unquoted `: `) are expected.
|
||||
`static let <field> = "<field>"` hand-patched in ASCII order 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); `OGS blue`, not `OGS Blue`.
|
||||
- Compose: named `MaterialTheme.typography` styles over `fontSize`; Blue's title is
|
||||
`headlineLarge` (SwiftUI `.largeTitle`).
|
||||
- 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.
|
||||
@@ -88,6 +64,5 @@ Dangling-symlink audit:
|
||||
Follow [docs/file-summary.md](docs/file-summary.md) (single-file) and
|
||||
[docs/mirror-summary.md](docs/mirror-summary.md) (mirrored platforms: one
|
||||
self-contained HTML with aligned function starts, original line numbers, green/orange
|
||||
fills, counts, non-repetitive explanations). Example:
|
||||
`docs/render-platform-comparison.html`; never substitute working-tree code for a
|
||||
fills, counts, non-repetitive explanations); never substitute working-tree code for a
|
||||
requested historical revision.
|
||||
Reference in new issue
Block a user