xcode 如何在 iOS 中正确链接第三方库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10990332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to link third party libraries properly in iOS
提问by Selkie
I'm new in iOS development, and met this library linking problem in last few days.
我是 iOS 开发的新手,最近几天遇到了这个库链接问题。
I was trying to use GMGridViewin a project, but cannot make it working.
我试图在项目中使用GMGridView,但无法使其工作。
This project is shipped as static library, so I just drag the xcodeproj file in my project. Then I added libGMGridView.a in Link Binary With Libraries,GMGridView in Target Dependencies. I also added the path in Header Search Paths.
这个项目是作为静态库提供的,所以我只是在我的项目中拖动 xcodeproj 文件。然后我在Link Binary With Libraries 中添加了 libGMGridView.a ,在Target Dependencies 中添加了 GMGridView 。我还在Header Search Paths 中添加了路径。
However, Xcode still report .h file not found error when I tried to import GMGridView.h.
但是,当我尝试导入 GMGridView.h 时,Xcode 仍然报告 .h file not found 错误。
Could anyone give me a hand on this? Thanks in advance!
任何人都可以帮我解决这个问题吗?提前致谢!
回答by comonitos
Had the same issue!!! Made it work!!!! soooooooo:
有同样的问题!!!让它工作!!!!呜呜呜:
- copy GMGridView folder from https://github.com/gmoledina/GMGridViewto your project dir
- in xcode right click on any file group and choose add files
- find GMGridView folder in your folder dir and choose GMGridView.xcodeproj - (dont copy, create groups not folders, add targets)
- go to your project targets - search - HEADER_SEARCH_PATHS add- GMGridView/**
- select Building phases in settings - choose target dependencies and add GMGridView
- select Building phases in settings - link binary libraries and add libGMGridView.a
- 将 GMGridView 文件夹从https://github.com/gmoledina/GMGridView复制到您的项目目录
- 在 xcode 中右键单击任何文件组并选择添加文件
- 在您的文件夹目录中找到 GMGridView 文件夹并选择 GMGridView.xcodeproj - (不要复制,创建组而不是文件夹,添加目标)
- 转到您的项目目标 - 搜索 - HEADER_SEARCH_PATHS 添加 - GMGridView/**
- 在设置中选择构建阶段 - 选择目标依赖项并添加 GMGridView
- 在设置中选择构建阶段 - 链接二进制库并添加 libGMGridView.a
import should be:
进口应该是:
#import "GMGridView.h"
#import <QuartzCore/QuartzCore.h>