Skip to content

Instantly share code, notes, and snippets.

@szhu
Forked from n-b/selfcompile.m
Last active May 14, 2018 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save szhu/b536c0c7ba98e9b4ff2bfaca8d8143e8 to your computer and use it in GitHub Desktop.
Save szhu/b536c0c7ba98e9b4ff2bfaca8d8143e8 to your computer and use it in GitHub Desktop.
A simple self-compiling objective-c file
/* 2>/dev/null
COMPILED=${0%.*}
[[ -e "$COMPILED" ]] || clang $0 -o "$COMPILED" -framework Foundation
exec "$COMPILED" $@
*/
#import <Foundation/Foundation.h>
int main(int argc, char *argv[])
{
@autoreleasepool
{
NSLog(@"Hello %@",NSProcessInfo.processInfo.environment[@"USER"]);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment