简体   繁体   English

Clang(LLVM)使用框架进行编译

[英]Clang(LLVM) compile with frameworks

I am using: 我在用:

clang -ObjC -framework UIKit -o /var/compiled/c /Documents/Source/main.m clang -ObjC -framework UIKit -o / var / compiled / c /Documents/Source/main.m

In OS X terminal. 在OS X终端中。 I also tried UIKit.framework, but I am getting 我也试过UIKit.framework,但我得到了

Fatal Error: 'UIKit/UIKit.h' not found 致命错误:找不到'UIKit / UIKit.h'

with both. 既。

Any suggestions? 有什么建议?

Thanks 谢谢

This has been already answered in the Apple developer forum, you can find the whole discussion in here . 这已在Apple开发者论坛中得到解答,您可以在这里找到整个讨论。 In the answer marked as the solution to the question they say: 在答案标记为他们所说的问题的解决方案:

1 - check your PATH variable first: 1 - 首先检查您的PATH变量:

$ echo $PATH

2 - assuming /System/Library/Frameworks is not included in PATH, add it: 2 - 假设/系统/库/框架未包含在PATH中,请添加:

$ PATH=$PATH:/System/Library/Frameworks

3 -now we're ready for Mr. Kochun's incantation: 3,现在我们已经为Kochun先生的咒语做好了准备:

$ clang -fobjc-arc -framework Foundation main.m prog1

Compiling for iOS without using Xcode is not easy. 在不使用Xcode的情况下编译iOS并不容易。 In your case, you're trying to use an iOS framework but you're using neither the iOS toolchain's compiler nor the iOS SDK. 在您的情况下,您尝试使用iOS框架,但您既不使用iOS工具链的编译器也不使用iOS SDK。

If you look at the compile transcript for an Xcode project you'll see some of the flags that are necessary. 如果你查看Xcode项目的编译脚本,你会看到一些必要的标志。 Things you'll need include: 你需要的东西包括:

  • xcrun -sdk iphoneos clang to choose the correct compiler and SDK xcrun -sdk iphoneos clang选择正确的编译器和SDK
  • -arch armv7s to choose the correct CPU architecture -arch armv7s选择正确的CPU架构
  • -mios-version-min=6.1 to set a minimum deployment target -mios-version-min=6.1设置最小部署目标

Some older versions of Xcode also require -isysroot=/path/to/iPhoneOS6.1.sdk to choose the correct SDK because xcrun did not do it automatically. 一些旧版本的Xcode也需要-isysroot=/path/to/iPhoneOS6.1.sdk来选择正确的SDK,因为xcrun没有自动执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM