xcode iOS 库的尖括号导入失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15915783/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
iOS library's angle bracket imports failing
提问by oxyacanthous
I am building an iOS project and I want to link in a static library from OpenSceneGraph. Right now, I have imported the header files into the project.
我正在构建一个 iOS 项目,我想从 OpenSceneGraph 链接一个静态库。现在,我已经将头文件导入到项目中。
In my ViewController, I have the statement:
在我的 ViewController 中,我有以下声明:
#import "osg/Geode"
and this does not give an error.
这不会出错。
(I initially tried
(我最初尝试
#import <osg/Geode>
but Xcode told me I needed to use quotes instead.)
但 Xcode 告诉我我需要使用引号代替。)
However, when I try to compile the project, Xcode runs into an issue when it does import osg/Geode. That file includes the line
但是,当我尝试编译项目时,Xcode 在导入 osg/Geode 时遇到了问题。该文件包括该行
#import <osg/Node>
When Xcode tries to compile, it imports "osg/Geode", and then it tries to import , but the angle brackets don't work there either, so it fails.
当 Xcode 尝试编译时,它会导入“osg/Geode”,然后尝试导入,但尖括号在那里也不起作用,因此它失败了。
How can I fix this issue? Thank you!
我该如何解决这个问题?谢谢!
Update
更新
As per Reck Hou's suggestion, I edited my "Header Search Paths" in build settings.
根据 Reck Hou 的建议,我在构建设置中编辑了我的“标题搜索路径”。
"$(SRCROOT)" - recursive
Now, when I try to compile, I get errors coming from the header files. Ex. "Unknown type name 'namespace'", "Expected ';' after top level declarator". I am also getting the error "'ostream' fiel not found".
现在,当我尝试编译时,我收到来自头文件的错误。前任。"未知类型名称 'namespace'", "预期的 ';' 在顶级声明符之后”。我也收到错误“'ostream' fiel not found”。
Does anyone know how to fix this problem? Thank you!
有谁知道如何解决这个问题?谢谢!
回答by Reck Hou
Into your project setting then find your building target->build settings
.
进入您的项目设置,然后找到您的构建目标-> build settings
。
Find Header search paths
then add your header path into it.
查找Header search paths
然后将您的标题路径添加到其中。
For example:
例如:
"$(SRCROOT)/[your header path]"
“$(SRCROOT)/[你的头文件路径]”
Be advice, add parent directory path takes no effect.
请注意,添加父目录路径无效。
e.g. You should add static library into Build Phases
->Link Binary With Libraries
to prevent link error.
例如,您应该将静态库添加到Build Phases
->Link Binary With Libraries
以防止链接错误。
回答by Yana
'namespace' is not a valid Objective-C keyword. What extension is ScopedLock file? Is it .mm? You need to tell xCode to compile it as C++.
“命名空间”不是有效的 Objective-C 关键字。ScopedLock 文件的扩展名是什么?是.mm吗?您需要告诉 xCode 将其编译为 C++。
To do that go to you Project Settings, choose the Target -> Build Settings -> Apple LLVM compiler X.X - Language -> Compile Sources As. Set it to Objective-C++ which allows mixture of Objective-C and C++.
为此,请转到项目设置,选择目标 -> 构建设置 -> Apple LLVM 编译器 XX - 语言 -> 编译源为。将其设置为允许 Objective-C 和 C++ 混合使用的 Objective-C++。
回答by matt
I'm pretty sure you're going to need to edit the header search paths in your build settings.
我很确定您将需要在构建设置中编辑标题搜索路径。