Write stderr on iPhone to both file and console

后端 未结 3 1481
醉话见心
醉话见心 2021-02-20 12:53

I\'m following the suggestion in the answer here for redirecting NSLog output on an iOS device to a file, which works great. The problem is that it no longer shows up in the co

3条回答
  •  孤街浪徒
    2021-02-20 13:32

    Once you freopen() the file descriptor, you can read from it and do as you please with the data. Some ideas from this will be useful to you.

    You could either write it back out to stdout, or try to write directly to /dev/console. I've never tried to open /dev/console on an iPhone, but I'm guessing it's possible despite being outside of the sandbox. I'm not sure how the app review process will treat it.

提交回复
热议问题