如何将静态库包含到Swift项目中?

[英]How to include static library into Swift project?


I have a swift base project iPhone app. I would like to use Zoiper SDK within it. What I got from them are static libraries (.a files):

我有一个快速的基础项目iPhone应用程序。我想在其中使用Zoiper SDK。我从他们那里得到的是静态库(.a文件):

- libcrypto.a
- libsipwrapper.a
- libssl.a

written probably in Objective-C.

可能是在Objective-C中写的。

And also external header files

还有外部头文件

- wrapper_defs.h, 
- wrapper_cbk.h, 
- wrapper.h

written in Objective-C.

用Objective-C编写。

I tried to add bridging header like this:

我试着像这样添加桥接头:

#ifndef ZoiperTest_Bridging_Header_h
#define ZoiperTest_Bridging_Header_h

#import "include/wrapper_defs.h"
#import "include/wrapper_cbk.h"
#import "include/wrapper.h"

#endif /* ZoiperTest_Bridging_Header_h */

But that returned lots of errors (types used in wrapper.h not being recognized)

但是返回了很多错误(wrapper.h中使用的类型无法识别)

Do I have to include also library .a files into bridging header? What would be exact syntax for that?

我是否还必须将库.a文件包含在桥接头中?那个准确的语法是什么?

I've tried adding #import into bridge header but that gives me file not found error.

我已经尝试将#import添加到桥接头中但是这给了我找不到文件的错误。

2 个解决方案

#1


0  

What you can do is the following and it worked for me. Create a static library from scratch. Add the .h (wrappers), including the LibController from the demo. Then once you finish follow this link: How can I use an .a static library in swift?

你可以做的是以下,它对我有用。从头开始创建静态库。添加.h(包装器),包括演示中的LibController。然后,一旦完成,请按照以下链接:如何在swift中使用.a静态库?

I was able to use the methods and all but not fully tested yet.

我能够使用这些方法,但尚未完全测试。

#2


0  

I could integrate zoiper SDK on a swift project. The easy way for me was create an Static Library on Objetive-C with the libs and integrate this on my swift project. -> https://github.com/depazsierra/zoiperExample

我可以在一个快速的项目上集成zoiper SDK。对我来说简单的方法是使用libs在Objetive-C上创建一个静态库,并将其集成到我的swift项目中。 - > https://github.com/depazsierra/zoiperExample

On the static library, i reused the ZSDKLibControl that came with zoiper example.

在静态库中,我重用了zoiper示例附带的ZSDKLibControl。

Any question, just let me know.

有任何问题,请告诉我。


注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.silva-art.net/blog/2016/03/22/17ebffdb4230de9b166737099998a54.html



 
© 2014-2018 ITdaan.com 粤ICP备14056181号