Skip to content

Commit d7be2d1

Browse files
committed
Unify iOS app launch and show story openings immediately
1 parent 0046920 commit d7be2d1

19 files changed

Lines changed: 232 additions & 194 deletions

‎AGENTS.md‎

Lines changed: 7 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -385,11 +385,11 @@ make run ARGS="demo/hello/init.lua"
385385
### Run an app in iPhone Simulator
386386

387387
The streaming UIKit host runs an app entry point from the Mac packager. Use
388-
`PROJECT` (not `ARGS`) to select the app:
388+
`APP` with a name from `apps/` or a repository-relative entry path:
389389

390390
```sh
391-
make ios-run PROJECT=demo/hello
392-
make ios-run PROJECT=apps/adventure-arena
391+
make ios-run APP=demo/hello
392+
make ios-run APP=adventure-arena
393393
```
394394

395395
The command builds `build/ios/LuaRuntime.app` if needed, starts the packager on
@@ -407,37 +407,10 @@ running while the app is open for file loading and hot reload.
407407
invalid` or `Connection refused`, retry `simctl` with elevated sandbox
408408
permissions. A restricted shell may not be allowed to connect to the host's
409409
CoreSimulator XPC service. That error does not mean the runtime is absent.
410-
- `make ios-run` also expects
411-
`$DEVELOPER_DIR/Applications/Simulator.app`. If that GUI app path is missing
412-
but `simctl` can list devices, boot and launch by explicit device UDID instead
413-
of treating the simulator runtime as unavailable:
414-
415-
```sh
416-
xcrun simctl list devices available
417-
SIMULATOR_UDID="paste-the-selected-device-udid-here"
418-
xcrun simctl boot "$SIMULATOR_UDID" || true
419-
xcrun simctl bootstatus "$SIMULATOR_UDID" -b
420-
make ios-host ios-packager
421-
```
422-
423-
Start the packager in a separate terminal, using the same app entry point:
424-
425-
```sh
426-
build/lua-objc-packager --root "$PWD" --port 8081 \
427-
--entry apps/adventure-arena
428-
```
429-
430-
The packager ignores `SIGPIPE` and drops hot-reload clients whose socket
431-
has closed. Then install and launch the host explicitly:
432-
433-
```sh
434-
xcrun simctl install "$SIMULATOR_UDID" build/ios/LuaRuntime.app
435-
SIMCTL_CHILD_LUA_OBJC_APP=apps/adventure-arena \
436-
SIMCTL_CHILD_LUA_OBJC_PACKAGER=http://127.0.0.1:8081 \
437-
xcrun simctl launch --terminate-running-process \
438-
"$SIMULATOR_UDID" org.luaobjc.host
439-
xcrun simctl io "$SIMULATOR_UDID" screenshot /tmp/ios-simulator.png
440-
```
410+
- `make ios-run` prefers an available iPhone 17 and can use the sole
411+
available iPhone simulator when that model is absent. Pass `DEVICE` with
412+
the name or UDID to choose a device explicitly. The command uses `simctl`
413+
to boot and launch even when Simulator.app is unavailable.
441414

442415
- If the screen says it is waiting for the packager, confirm the packager
443416
process is still alive and serving port 8081, then relaunch the host after

‎Makefile‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ test: $(LUA_OBJC_BIN) $(FRAMEWORK_MODULES) $(NATIVE_PLUGINS) $(PARITY_IMAGE_DIFF
189189
DEVELOPER_DIR ?= /Applications/Xcode.app/Contents/Developer
190190
export DEVELOPER_DIR
191191
IOS_MIN := 26.5
192-
SIMULATOR_DEVICE = $(or $(DEVICE),iPhone 17)
192+
IOS_APP = $(or $(APP),demo/hello)
193+
IOS_APP_ENTRY = $(if $(findstring /,$(IOS_APP)),$(IOS_APP),apps/$(IOS_APP))
193194
IOS_SDK := $(shell xcrun --sdk iphonesimulator --show-sdk-path 2>/dev/null)
194195
IOS_CC := $(shell xcrun --sdk iphonesimulator --find clang)
195196
LUA_SRC_DIR := vendor/lua-5.4.8/src
@@ -252,20 +253,19 @@ ios-host: $(HOST_BINARY)
252253
ios-packager: $(PACKAGER)
253254

254255
ios-packager-run: ios-packager
255-
./$(PACKAGER) --root "$(CURDIR)" --port 8081 --entry "$(or $(PROJECT),demo/hello)"
256+
./$(PACKAGER) --root "$(CURDIR)" --port 8081 --entry "$(IOS_APP_ENTRY)"
256257

257258
ios-packager-stop:
258259
@if [ -f build/ios/packager.pid ]; then kill $$(cat build/ios/packager.pid) 2>/dev/null || true; rm -f build/ios/packager.pid; fi
259260

260261
ios-run: ios-host ios-packager
261-
chmod +x scripts/ios-run.sh
262-
DEVELOPER_DIR=$(DEVELOPER_DIR) DEVICE="$(SIMULATOR_DEVICE)" PROJECT="$(or $(PROJECT),demo/hello)" \
263-
scripts/ios-run.sh
262+
device="$$(python3 scripts/ios-simulator-device.py "$(DEVICE)")" && \
263+
DEVICE="$$device" scripts/ios-run.sh "$(IOS_APP_ENTRY)"
264264

265265
ios-internal-screenshot: ios-host ios-packager
266-
DEVELOPER_DIR=$(DEVELOPER_DIR) OUT="$(or $(OUT),/tmp/ios-internal-screenshot.png)" \
267-
PROJECT="$(or $(PROJECT),demo/hello)" DEVICE="$(SIMULATOR_DEVICE)" \
268-
scripts/ios-internal-screenshot.sh
266+
device="$$(python3 scripts/ios-simulator-device.py "$(DEVICE)")" && \
267+
DEVICE="$$device" OUT="$(or $(OUT),/tmp/ios-internal-screenshot.png)" \
268+
scripts/ios-internal-screenshot.sh "$(IOS_APP_ENTRY)"
269269

270270
ios-screenshot:
271271
DEVELOPER_DIR=$(DEVELOPER_DIR) xcrun simctl io booted screenshot \

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ iPhone Simulator (host is a runtime; Lua and assets stream from a Mac packager).
8585

8686
```sh
8787
export DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer
88-
make ios-run ARGS=demo/hello
89-
# watch Xcode’s Simulator window (not the terminal)
88+
make ios-run APP=demo/hello
89+
# watch Xcode’s Simulator window if available
9090
# edit demo/hello/views/Window.etlua, save — UI updates without quitting
9191
```
9292

@@ -493,7 +493,7 @@ Use the streaming host for hot reload, or build and install a standalone app
493493
with the Makefile.
494494

495495
```sh
496-
make ios-run PROJECT=apps/adventure-arena
496+
make ios APP=adventure-arena
497497
make ipad-simulator APP=adventure-arena
498498
make ipad-run APP=adventure-arena
499499
make iphone APP=adventure-arena

‎apps/adventure-arena/controllers/SessionController.lua‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ local TOAST = { seconds = 2.2 }
1313
-- the same spacing regardless of word length or the character reveal rate.
1414
local TYPING = {
1515
tick = 1 / 30, charactersPerTick = 3,
16-
hapticInterval = (4 / 30) / 1.75, hapticStyle = "soft", hapticIntensity = 0.5, openingDelay = 0.45,
16+
hapticInterval = (4 / 30) / 1.75, hapticStyle = "soft", hapticIntensity = 0.5,
1717
}
1818

1919
local function characterCount(text)
@@ -104,8 +104,6 @@ function Controller:show(id, fresh)
104104
end
105105
self:render()
106106
self.transcript = self.mountTemplate(self.refs.transcript, "sections/Transcript")
107-
-- A new story types its opening; a resumed one opens at its last line.
108-
if not saved then self:beginTyping(1, TYPING.openingDelay) end
109107
self:applyReadingSettings()
110108
-- A new story is read from its title page; a resumed one from its last line.
111109
self:scrollPage(saved and "bottom" or "top", false)
@@ -219,7 +217,7 @@ end
219217
-- settings change); between renders each tick writes the one paragraph
220218
-- being typed.
221219

222-
function Controller:beginTyping(firstEntry, delay)
220+
function Controller:beginTyping(firstEntry)
223221
local queue = {}
224222
for _, item in ipairs(self.model:paragraphsSince(firstEntry)) do
225223
item.length = characterCount(item.text)
@@ -229,7 +227,7 @@ function Controller:beginTyping(firstEntry, delay)
229227
self.typingGeneration = (self.typingGeneration or 0) + 1
230228
local generation = self.typingGeneration
231229
self.typing = { queue = queue, position = 1, revealed = 0, hapticGeneration = 0, generation = generation }
232-
self.after(delay or TYPING.tick, function() self:typeNext(generation) end)
230+
self.after(TYPING.tick, function() self:typeNext(generation) end)
233231
end
234232

235233
-- Everything typed so far stays; what is left appears at the next render.

‎apps/coin-quest/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ and Y on the right. A swipe on the scene also runs and a tap jumps, so the
3737
Mac's mouse can try the touch controls. Try it in the iPhone Simulator:
3838

3939
```sh
40-
make ios-run PROJECT=apps/coin-quest
40+
make ios-run APP=coin-quest
4141
```
4242

4343
## The worlds

‎apps/studio/Controller.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ end
212212
function Controller:createWindow()
213213
self.ns = self.ns or require("ns")
214214
local ns = self.ns
215-
assert(ns.Preview, "Lua Studio requires the iOS runtime. Use make ipad-run, or make ios-run PROJECT=apps/studio for an iPhone.")
215+
assert(ns.Preview, "Lua Studio requires the iOS runtime. Use make ipad-run, or make ios-run APP=studio for the iPhone Simulator.")
216216
DataModel.bind(self.store)
217217
-- A phone runs the project full screen under the Studio capsule; the
218218
-- iPad lays the workspace out in columns.

‎apps/studio/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Share, GitHub, New Project, Delete Project and Settings. Run it in the iPhone
1919
Simulator with the streaming host:
2020

2121
```sh
22-
make ios-run PROJECT=apps/studio
22+
make ios-run APP=studio
2323
```
2424

2525
## Install

‎apps/studio/services/Export.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function Export.items(project, files)
1616
end
1717
table.insert(result, { name = "README.md", text = "# " .. project .. "\n\n"
1818
.. "Copy this folder to apps/" .. project .. " in a lua-objc checkout.\n"
19-
.. "Run make ios-run PROJECT=apps/" .. project .. " for the iPhone host, or\n"
19+
.. "Run make ios-run APP=" .. project .. " for the iPhone Simulator, or\n"
2020
.. "make iphone-deploy APP=" .. project .. " for a paired iPhone with development signing.\n"
2121
.. "App Store distribution requires a separate release/signing configuration.\n\n"
2222
.. "Export rewrites Studio's demo.playground namespace to apps." .. project .. ".\n"

‎docs/agents/quickstart.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ Lua, templates, and assets stream from a Mac packager. After `make ios-run`,
9999
a save reloads the running app **without quitting**:
100100

101101
```sh
102-
make ios-run ARGS=demo/hello
102+
make ios-run APP=demo/hello
103103
```
104104

105105
Do not copy Lua into the `.app`. Do not rebuild the host because a view or

‎docs/index.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ AppKit/UIKit controls, and no compile cycle for every UI change.
2727
## The core loop
2828

2929
1. Describe the view in Lua or an etlua template.
30-
2. Run it: `./lua-objc apps/<app>` on macOS, or `make ios-run ARGS=apps/<app>` on the iPhone Simulator. Framework demos live under `demo/`; test harness apps live under `test/`.
30+
2. Run it: `./lua-objc apps/<app>` on macOS, or `make ios-run APP=<app>` on the iPhone Simulator. Framework demos live under `demo/`; test harness apps live under `test/`.
3131
3. On iOS, save a Lua/etlua/asset file; the running host reloads in place (no quit, no rebuild).
3232
4. Exercise the behavior with a headless Lua test.
3333
5. Inspect a screenshot or native layout dump when the change is visual.

0 commit comments

Comments
 (0)