作者:放开丶那手 | 来源:互联网 | 2023-05-16 17:08
MyteamhasafewfullObj-Clibrariesweliketereuseinourprojects.Todoso,weusuallysetup
My team has a few full Obj-C libraries we like te reuse in our projects. To do so, we usually set up a git submodule, and then add it to the xcode project as a sub-project (Using target dependency
, link binary with library
and updating the User Header Search Paths
)
我的团队有一些完整的Obj-C库,我们喜欢在我们的项目中重用它们。为此,我们通常设置一个git子模块,然后将其作为子项目添加到xcode项目中(使用目标依赖项,链接二进制文件库并更新用户标题搜索路径)
So far it's only been done in full Obj-C projects, and I'm now trying to use it in a Swift project but with very little success so far. I tried to add the briding-header
file, referenced it in the project and filled it like so :
到目前为止,它只在完整的Obj-C项目中完成,我现在正尝试在Swift项目中使用它,但迄今为止收效甚微。我试图添加briding-header文件,在项目中引用它并填充它如下:
#import "MyLibraryHeader.h"
With the target header being in the User Header Search Paths
.
目标标题位于用户标题搜索路径中。
It lets me build, but when using it in my Swift files:
它允许我构建,但在我的Swift文件中使用它时:
let test = MyLib();
let secOndTest= MyLib.classMethod1("some_arguments");
I get an EXC_BAD_INSTRUCTION
on secondTest
, and the following logs in the debugger:
我在secondTest上得到一个EXC_BAD_INSTRUCTION,以及调试器中的以下日志:
(lldb) po test
error: :1:1: error: use of unresolved identifier 'test'
(lldb) po secondTest
error: Error in auto-import:
failed to get module 'MyProject' from AST context:
/Users/siegele/Sources/MyProject_iOS/MyProject/Classes/MyProject-Bridging-Header.h:12:9: error: 'MyLibraryHeader.h' file not found
#import "MyLibraryHeader.h"
^
failed to import bridging header '/Users/siegele/Sources/MyProject_iOS/MyProject/Classes/MyProject-Bridging-Header.h'
Found the following question with no answer : Xcode 6 crashing when using Objective-C subproject inside Swift
找不到以下问题:在Swift中使用Objective-C子项目时Xcode 6崩溃
Any help would be appreciated.
任何帮助,将不胜感激。
2 个解决方案