Skip to content

feat(runtime): forward stdout and stderr to os_log for the CLI - #532

Open
rigor789 wants to merge 2 commits into
feat/ios-log-chunksfrom
feat/ios-stdio-forwarding
Open

rigor789 wants to merge 2 commits into
feat/ios-log-chunksfrom
feat/ios-stdio-forwarding

Conversation

@rigor789

@rigor789 rigor789 commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

What is the current behavior?

Without a console, an app's stdio is /dev/null. print() output is lost, and so is NSLog on devices, where it only goes to stderr on iPadOS 26.7. A CLI can't attach to it after launch, because stdio is fixed when the process starts.

What is the new behavior?

In debug builds whose CLI sets forwardStdio in the app's package.json, with stdout still /dev/null, the runtime pipes stdout and stderr into os_log under the org.nativescript.stdio subsystem, with stdout and stderr as categories.

  • Older CLIs never set the key, and release builds and attached consoles fail the checks, so nothing changes for them.
  • stdout becomes line buffered, or print() would wait for a full buffer.
  • Long lines are split the same way as console messages.
  • Devices forward both streams. The simulator forwards stdout only, because NSLog there also reaches the unified log and would print twice. That means fputs(..., stderr) isn't forwarded on the simulator.

Known limits: output buffered at the moment of a crash is lost, so the last lines before an abort() may not appear. An unterminated final line isn't forwarded until a newline arrives or it reaches 64 KB.

Testing

Demo app with Swift code calling print() (short, 5,000 characters, background thread), NSLog and fputs(stderr), on both launches of each run:

Setup Result
New CLI, default, simulator and iPad Hidden, and all 11 console messages intact
New CLI, --log debug, simulator print() shown, 5,000-character line intact, NSLog once (from Foundation)
New CLI, --log debug, iPad (iPadOS 26.7) print(), NSLog and stderr all shown once
Published CLI 9.1.1, simulator No forwarding
simctl launch --console-pty print() goes to the console directly

Older iOS versions weren't tested, and NSLog may behave differently there. A launch from Xcode itself wasn't tested either.

Part of a stack

Base: #530. The CLI side is NativeScript/nativescript-cli#6181.

@coderabbitai

coderabbitai Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 21aa753f-cc86-4427-9ab6-2149ff826f81
Commits

Reviewing files that changed from the base of the PR and between db9cadd and 8715264.

Files selected for processing: 6
  • NativeScript/NativeScript.mm
  • NativeScript/runtime/Helpers.h
  • NativeScript/runtime/Helpers.mm
  • NativeScript/runtime/StdioForwarder.h
  • NativeScript/runtime/StdioForwarder.mm
  • v8ios.xcodeproj/project.pbxproj
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Without a console an app's stdio is /dev/null, so print() and, on devices, NSLog never reach any log stream, and a CLI can't attach to them after launch. In debug builds whose CLI sets forwardStdio in the app's package.json, with stdout still /dev/null, the runtime now pipes them into os_log under the org.nativescript.stdio subsystem. Long lines are split like console messages.

This branch has not been deployed

No deployments
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.

1 participant