这是一个非常简单的 Objective-C 控制台应用程序:
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
CLLocationManager *locationManager = [[CLLocationManager alloc] init];
NSLog(@"Hello world!");
[pool drain];
return 0;
}
我在我的 Mac 上用 gcc main.m -o main -ObjC -framework Foundation -framework CoreLocation
编译它。
我的 mac 上也安装了 iOS SDK。我如何修改此命令以编译相同的代码,在我的计算机上,以便在(越狱的)iOS 设备上使用?
然后我可以通过 ssh 传输可执行文件并使用 ldid
对其进行签名。
最佳答案
对于简单的情况,这可能就足够了:
gcc -o output -Wall -std=c99 source.m -framework Foundation -lobjc
更新:
此命令不适用于 iOS 命令行应用程序 - arch 必须正确设置。我目前手头没有 iOS 开发环境; -march 标志可能会有所帮助。
查看已接受的答案。
关于ios - 在 mac 上通过 gcc 编译 iOS Objective-C 命令行应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7473246/