如何在模块化Swift框架中使用libproc.h?

时间:2018-10-30 22:17:13

标签: macos module frameworks module-map

我已经按照other similar questions的所有步骤进行操作,但我仍然受阻。

我需要使用the function proc_pidpath in libproc.h来通过其PID获取BSD进程的路径。但是,libproc.h不是模块化标头,因此无法将其包含在伞形标头中:

a line of code reading "#import <libproc.h>" with the error "Include of non-modular header inside framework module"

足够公平;现在我尝试将其包含在我的模块图中:

framework module My_Modular_Framework {
    umbrella header "My_Modular_Framework.h"

    private header "/usr/include/libproc.h"

    export *
    module * { export * }
}

现在我得到了这个错误提示,它似乎认为我的项目中包含许多系统模块/标头:

A long list of errors like "Redeclaration of module SomeSystemModule"

我不知道该怎么办。就像我说的那样,我已经尝试按照other similar questions的所有步骤进行操作,但都没有成功。 在这里可以做什么?如何使用proc_pidpath?是否还有另一种更容易在模块化框架中使用Swift的方法来从进程ID获取路径?

我不想启用“在框架模块中允许非模块化包含”,因为这违反了模块化框架的目的。

1 个答案:

答案 0 :(得分:1)

由于libproc.h libproc.c是开放源代码(APSL 2.0)作为Apple Darwin项目的一部分,因此您可以将它们包括在内(当然,根据许可条款)在您的项目中。由于两者都不导入任何非模块化标头,因此您可以自己进行编译,并且编译器不会抱怨!