如何用C在iOS应用中的静态库? [英] How to use c static library in iOS app?

查看:148
本文介绍了如何用C在iOS应用中的静态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有库的头文件,并从C源X $ C $çSDK编译静态库。如何使用它在我的iOS应用程序?我相信我有添加在项目设置某文件(链接部分)和头文件在源文件中的设置。怎么样使用.mm而不是.m文件?如何包装C API到Objective-C的正确?

I have library header files and static library compiled with XCode SDK from C sources. How to use it in my iOS app? I believe i have to add .a file in the project settings (link section) and header files in source files settings. What about using .mm files instead of .m? How to wrap C API to Objective-c correctly?

推荐答案

您不需要使用 .mm 。这仅仅是对的Objective-C ++文件。

You don't need to use .mm. This is only for Objective-C++ files.

所有你需要做的是包括 .A .H 在你的项目文件(我想你只需拖放),然后#进口你想使用的库文件的 .H 文件

All you need to do is include the .a and .h files in your project (I think you can just drag and drop) and then #import the .h files in the files you want to use the library in.

在旧版本的X $ C $的C您必须手动确保 .A 正在联系,但我很肯定的,这是现在自动处理当库拖放到项目中。

In older versions of Xcode you had to manually make sure the .a was being linked, but I'm quite positive that this is handled automatically now when you drop the library into the project.

如果拖放放大器;掉落不工作,您可以直接在项目中的文件列表中单击,然后单击添加文件,这将打开一个Finder窗口。从这里,导航到 .A .H 文件,选择他们,和包括他们。

If drag&dropping isn't working, you can right click in your projects list of files and click "Add files", which will open a finder window. From here, navigate to the .a and .h files, select them all, and include them.

这篇关于如何用C在iOS应用中的静态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆