在Xcode 7中找不到头文件

时间:2023-01-13 20:23:47

I'm creating a framework which embeds some C libraries. The C libraries code is exposed to Swift using a .modulemap file. In the Build Settings of the target, under Swift Compiler - Search Paths section I set path to the .modulemap file in Import Paths row. Also under Search Paths section, paths for libraries and headers are set, in Library Search Paths and Header Search Paths rows respectively. After adding framework to the app's project and trying to build app, it fails with error pjsip.h file not found.

我正在创建一个嵌入一些C库的框架。 C库代码使用.modulemap文件向Swift公开。在目标的“构建设置”中,在“Swift编译器 - 搜索路径”部分下,我在“导入路径”行中设置了.modulemap文件的路径。同样在“搜索路径”部分下,分别在“库搜索路径”和“页眉搜索路径”行中设置库和标题的路径。将框架添加到应用程序的项目并尝试构建应用程序后,它失败并找不到错误pjsip.h文件。

  • Values of Header Search Paths:
  • 标头搜索路径的值:

在Xcode 7中找不到头文件

  • Structure of headers folders
  • 标题文件夹的结构

在Xcode 7中找不到头文件

The import process starts with highlighted blue file pjsua.h which then imports other headers, those marked with red rectangles.

导入过程以突出显示的蓝色文件pjsua.h开始,然后导入其他标题,标记为红色矩形。

  • The complete list of imported headers in pjsua.h
  • pjsua.h中导入标题的完整列表

在Xcode 7中找不到头文件

You can see that imported headers are not living in same folder as pjsua.h as should be for successful import, but isn't this the job of the Header Search Paths to find the headers ? I don't want to mess the structure of the headers folders, cause it's a third party lib and each time it will be updated each time this 'magic' must be done. The include path is defined in Other C Flags row which is same as settings Header Search Paths. I'm not sure what I've missed.

您可以看到导入的标题与pjsua.h不在同一个文件夹中,应该是成功导入,但这不是标题搜索路径的工作,以查找标题?我不想弄乱头文件夹的结构,因为它是第三方库,每次每次必须完成这个'魔术'时它都会被更新。包含路径在“其他C标志”行中定义,该行与设置标题搜索路径相同。我不确定我错过了什么。

Note:

注意:

  1. Headers paths are right.
  2. 标题路径是正确的。
  3. They don't contain any spaces.
  4. 它们不包含任何空格。

P.S This doesn't help.

P.S这没有用。

Update:

更新:

This error is showed only when building for Simulator, building for real device Xcode fails with multiple errors Redefinition of ...

此错误仅在为Simulator构建时显示,为真实设备构建Xcode失败并出现多个错误重新定义...

1 个解决方案

#1


2  

Solution is simple but ugly. Set Header Search Paths and Search Paths for the main project too. That's definitely not the best way to add a framework to a project because it exposes details about framework but it's the only way to fix the problem.

解决方案很简单但很难看。也为主项目设置标题搜索路径和搜索路径。这绝对不是向项目添加框架的最佳方式,因为它公开了有关框架的详细信息,但这是解决问题的唯一方法。

#1


2  

Solution is simple but ugly. Set Header Search Paths and Search Paths for the main project too. That's definitely not the best way to add a framework to a project because it exposes details about framework but it's the only way to fix the problem.

解决方案很简单但很难看。也为主项目设置标题搜索路径和搜索路径。这绝对不是向项目添加框架的最佳方式,因为它公开了有关框架的详细信息,但这是解决问题的唯一方法。