Skip to content

chore: example app — macOS (react-native-macos 0.81) split-pane#25

Closed
LeslieOA wants to merge 7 commits into
developfrom
chore/macos-example-app
Closed

chore: example app — macOS (react-native-macos 0.81) split-pane#25
LeslieOA wants to merge 7 commits into
developfrom
chore/macos-example-app

Conversation

@LeslieOA

@LeslieOA LeslieOA commented May 6, 2026

Copy link
Copy Markdown
Member

Summary

Adds a runnable macOS example under example/macos-app/, scaffolded via @react-native-community/cli init --version 0.81.2 then react-native-macos-init (which pulls react-native-macos@^0.81.7).

Layout

Fixed split pane per #17 + your revised spec:

  • Left<SourceEditor> with live syntax highlighting
  • Right<WebView> per-language preview:
    • markdownmarked rendered HTML in a system-styled doc
    • html → the document itself
    • javascript / typescript → captured console output (TS types stripped before exec)
    • json / plaintext → monospace dump
  • Top — plain RN tab bar switching Markdown / JSON / JS / TS / HTML

Toolchain (deliberately different from iOS)

Concern iOS example macOS example
Build flow Expo CNG (expo prebuild + expo run:ios) Plain RN (react-native run-macos)
pod install Auto-handled by expo run:ios Manual via macos:pods
cocoapods-spm wiring Injected by our app.plugin.js at prebuild Hard-wired into macos/Podfile
UI components @expo/ui (Liquid Glass, SwiftUI Picker) Plain RN Pressables
Native folder in git Not committed (CNG regenerates) Committed (no CNG)

Root scripts

Mirrors the Workspace desktop:* set: macos:plugin, macos:install, macos:pods, macos:clean, macos:start, macos:clear, macos:run, macos:dev.

Notes

  • --legacy-peer-deps required throughout: react-native-macos@0.81.7 wants react@^19.1.4 but RN 0.81.2 ships react@19.1.0. Upstream mismatch.
  • Unused ios/ and android/ scaffolding from react-native init removed — this app is macOS-only.
  • Library typecheck + expo-module build both pass.
  • The macOS branch of SourceEditorView.swift has never been exercised end-to-end. Expect compile/runtime issues on first build — will fix forward on this branch.
  • CI build-macos job will be added separately (it's also gated on getting this app to actually build first).

Closes #17

Adds a runnable macOS example under `example/macos-app/`, scaffolded
via `@react-native-community/cli init --version 0.81.2` then
`react-native-macos-init` (which installs `react-native-macos@^0.81`).

Layout per #17 + user's revised spec: a fixed split pane with
`<SourceEditor>` on the left and a `<WebView>` preview on the right.
Top tab bar switches Markdown / JSON / JavaScript / TypeScript /
HTML. Each language seeds a sample and drives the right pane:
markdown → marked-rendered HTML, html → the doc itself, JS/TS →
captured console output (TS types stripped before exec), JSON /
plaintext → monospace dump.

Toolchain notes (deliberately different from the iOS example):

- Plain RN, no Expo. `react-native run-macos` does NOT auto-pod —
  `pod install` is the correct manual invocation here.
- The `cocoapods-spm` Podfile mods are written directly into
  `macos/Podfile` (no Expo config plugin to inject them, since
  there's no `expo prebuild` flow).
- `--legacy-peer-deps` required: react-native-macos@0.81.7 declares
  `react@^19.1.4` as a peer but RN 0.81.2 ships `react@19.1.0`.
  Mismatch is upstream.
- Module resolution mirrors the iOS pattern: `metro.config.js` maps
  `@workspace-sh/react-native-source-editor` to the repo root via
  `extraNodeModules` + `watchFolders` + `blockList` for parent
  react/react-native; tsconfig has the same `paths` mapping.
- `@expo/ui` doesn't exist on macOS — the toolbar is plain RN
  Pressables. No Liquid Glass on this side.

Root scripts mirror the Workspace `desktop:*` set:
macos:plugin (gem), macos:install (--legacy-peer-deps),
macos:pods, macos:clean (wipe Pods/Podfile.lock/build),
macos:start / macos:clear, macos:run, macos:dev (concurrent).

The unused `ios/` and `android/` scaffolding from `react-native init`
is removed — this app is macOS-only.

Note: the macOS branch of `SourceEditorView.swift` has never been
exercised end-to-end. Compile/runtime issues likely on first build
and will be fixed forward on the same branch.

Closes #17
LeslieOA added 6 commits May 6, 2026 15:56
Unlike Expo's run:ios, react-native run-macos doesn't start Metro
itself. Both READMEs now lead with macos:dev (concurrent Metro +
run-macos), with macos:start + macos:run documented as the
two-terminal alternative.
RN's vendored fmt failed to compile under Xcode 16/17 + macOS 14
with 'call to consteval function ... is not a constant expression'.
post_install patches the fmt target to define FMT_USE_CONSTEVAL=0.
Previous attempt scoped the define to the fmt target only, but the
consteval errors instantiate in EVERY pod that includes fmt headers
(RCT-Folly, React-jsi, etc.). Now applies the define at the umbrella
project level (xcconfig) and on every pod target, via both
GCC_PREPROCESSOR_DEFINITIONS and OTHER_CPLUSPLUSFLAGS for safety.
xcconfig and OTHER_CPLUSPLUSFLAGS approaches both failed to make
FMT_USE_CONSTEVAL=0 reach fmt's headers in time — the consteval
calls were still firing in format-inl.h. Switch to a direct
post_install file patch: prepend a guarded `#define
FMT_USE_CONSTEVAL 0` to Pods/fmt/include/fmt/base.h. The marker
comment makes it idempotent on subsequent installs.
Previous patch ran but didn't visibly land — likely my conditional
short-circuited on a path I wasn't expecting, or the file we needed
to patch wasn't base.h alone.

This version:
- Patches base.h, core.h AND format.h (whichever exist) so we cover
  fmt's auto-detection wherever it lives across versions
- ALSO appends GCC_PREPROCESSOR_DEFINITIONS = $(inherited)
  FMT_USE_CONSTEVAL=0 to every xcconfig under the sandbox, as
  belt-and-braces in case a header is included before our patched
  source
- Prints diagnostic lines (sandbox path, file existence, patched/
  already-patched status) so we can see exactly what ran
…ection chain

Top-of-file #define-if-undefined was correctly applied but didn't
stick: fmt's auto-detection block (base.h lines 119-138) is NOT
wrapped in #ifndef and UNCONDITIONALLY reassigns FMT_USE_CONSTEVAL
based on compiler probes. On Apple Clang 17 the `__cpp_consteval`
branch fires and sets it back to 1, so by the time FMT_CONSTEVAL
expands to consteval, the override is gone.

This patch finds the precise anchor between the detection chain's
closing #endif and the next `#if FMT_USE_CONSTEVAL` and injects
`#undef FMT_USE_CONSTEVAL` + `#define FMT_USE_CONSTEVAL 0`
between them. Idempotent via a second marker comment.
@LeslieOA

LeslieOA commented May 7, 2026

Copy link
Copy Markdown
Member Author

Superseding via the library refactor (bare RN + codegen Fabric + Expo plugin wrapper, mirroring react-native-enriched-markdown). The fmt patch, scripts, and layout work captured here will be re-applied on the refactor branch — but with the architecturally correct library underneath, the macOS example will actually exercise the editor (not a placeholder).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore: macOS example app — editor in split-pane

1 participant