Skip to content

Instantly share code, notes, and snippets.

@OdNairy
Last active December 21, 2015 00:28
Show Gist options
  • Save OdNairy/6219906 to your computer and use it in GitHub Desktop.
Save OdNairy/6219906 to your computer and use it in GitHub Desktop.
// Source: https://devforums.apple.com/message/866487#866487
typedef int (*PYStdWriter)(void *, const char *, int);
static PYStdWriter _oldStdWrite;
int __pyStderrWrite(void *inFD, const char *buffer, int size)
{
if ( strncmp(buffer, "AssertMacros: queueEntry", 24) == 0 ) {
return 0;
}
return _oldStdWrite(inFD, buffer, size);
}
void __iOS7B5CleanConsoleOutput(void)
{
_oldStdWrite = stderr->_write;
stderr->_write = __pyStderrWrite;
}
int main(int argc, char *argv[])
{
@autoreleasepool {
__iOS7B5CleanConsoleOutput();
return UIApplicationMain(argc, argv, nil, NSStringFromClass([DBAppDelegate class]));
}
}
@kyleclegg
Copy link

I was getting warnings for “no previous prototype for function” and had to define function prototypes at the top of the class. I added this after line 3:

int __pyStderrWrite(void *inFD, const char *buffer, int size);
void __iOS7B5CleanConsoleOutput(void);

@daltonclaybrook
Copy link

Very cool, thanks!

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