Last active
February 16, 2025 20:01
-
-
Save sindresorhus/d5c626fde1647f0b3e0d to your computer and use it in GitHub Desktop.
Compile Objective-C on the command-line with clang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -fobjc-arc: enables ARC | |
# -fmodules: enables modules so you can import with `@import AppKit;` | |
# -mmacosx-version-min=10.6: support older OS X versions, this might increase the binary size | |
clang main.m -fobjc-arc -fmodules -mmacosx-version-min=10.6 -o main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import Foundation; | |
int main() { | |
@autoreleasepool { | |
NSArray *args = [[NSProcessInfo processInfo] arguments]; | |
if (args.count == 1) { | |
return 1; | |
} | |
NSString *input = args[1]; | |
puts([input UTF8String]); | |
} | |
return 0; | |
} |
libremahdi
commented
Jun 7, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment