Skip to content

Instantly share code, notes, and snippets.

@shoeper
Forked from Nosskirneh/README.md
Created March 22, 2022 20:25
Show Gist options
  • Save shoeper/2bfa721d8cfd2469262b00124b79e94e to your computer and use it in GitHub Desktop.
Save shoeper/2bfa721d8cfd2469262b00124b79e94e to your computer and use it in GitHub Desktop.
Logging without syslog – Tweak development

The iOS syslog was removed in iOS 13.3. Prior to that, you could still view the deprecated syslog if you compiled your tweaks using an iOS 9 or lower SDK. Apple introduced oslog in iOS 10.

  1. Clone https://github.com/theos/theos/ to $THEOS/sdks.
  2. Change $THEOS/vendor/logos/bin/lib/Logos/Generator/Base/Method.pm:73 from HBLogDebug(... or NSLog(..., depending on theos version, to log(... .
  3. Add the following to $THEOS/include/HBLog.h:
    • #define log(...) HBLogWarn(@"<NOSS>: %@", [NSString stringWithFormat:__VA_ARGS__]); on line 19, ie if you're running os_log / iOS 10+ SDK.

    • #define log(...) HBLogDebug(__VA_ARGS__); on line 41, ie when not running an iOS 10+ SDK.

  4. On your iDevice, add alias debug="oslog | awk 'f; /\)/{f=0} /<NOSS>:/{print; f=/\(/}'" to /etc/profile.d/profile.sh and source it afterwards. You may need to create the file if you haven't already.
  5. Write debug in your device's terminal.

Feel free to use anything other than <NOSS>:, it was only to make the prints hold something unique in order to filter it.

If you need to manually log something, simply use log(@"...", ...);

To change from the new oslog to the old syslog, simply change the TARGET in the Makefile from iphone:clang:11.2 to iphone:clang:9.2. I recommend adding an alias for the old syslog in the same file as above if you're going to use the syslog: alias syslog="socat - UNIX-CONNECT:/var/run/lockdown/syslog.sock"

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