您的位置:首页 > 移动开发 > IOS开发

ZBarSDK API Documentation (一)—Installing the SDK

2013-10-22 10:43 316 查看


1.1. 安装 the SDK

这篇文章将会对下载ZBar SDK和添加此SDK到工程的方式做基本的介绍。

如果你想了解更多,可以访问ZBar
SDK Integration Tutorial


1.1.1. 要求

如果你想在你的iphone应用程序中使用这个SDK,你必须满足以下条件:
Mac OS X >= 10.6.x (Snow Leopard) 
Xcode >= 3.2.3
iPhone SDK >= 4.0
An iPhone 3GS or iPhone 4
iOS >= 3.1 running on the device (>= 4.0 is preferred)

Warning
 

Only the iPhone 3GS and iPhone 4 are supported, as they have a camera with auto-focus. The ZBar library does not support the iPhone 3G and is unlikely to ever support it.


1.1.2. 下载

http://zbar.sourceforge.net/iphone上下载最新版本的ZBar
SDK


1.1.3. 整合

以下将推荐一种简单的将SDK复制到你的Xcode工程中的安装方法:

在Finder中打开ZBarSDK-1.2.dmg。

拖拽ZBarSDK 文件夹到你的Xcode工程中。弹出一个对话框后,你应该选择复制这个SDK到你的工程中,并且在target列表中选择你想要使用此第三方库的target。

使用ZBarSDK还需要添加以下frameworks库文件。如果你需要支持 iOS
3,首先你应该设置前面三个库为弱引用,并且在target中配置一个合适的deployment值:
AVFoundation.framework (weak)
CoreMedia.framework (weak)
CoreVideo.framework (weak)
QuartzCore.framework
libiconv.dylib
If you check “Link Binary With Libraries” for the target(s), you should see all of these frameworks followed by libzbar.a.

Note
 
Link order may be important for some versions of Xcode; the referenced libraries should be listed before libzbar.a in
the link order.

在.pch文件中导入SDK头文件:

#import "ZBarSDK.h"


通过阅读《Scanning
From the Camera Feed》或者《 Scanning
a User-Selected Image》 去学习如何使用这个APIs去扫描条形码。 通过 API Reference 可以了解得更详细。


1.1.4. 更新版本

如果你使用的是一个老版本,请通过以下方式更新:
在你的工程中删除当前的 ZBarSDK。如果你是复制他们到你的工程中,你应该选择删除那些文件。
从DMG中拖拽新的ZBarSDK到你的工程中。
Clean和重新build一下你的工程。


1.1.5. 升级 Pre-SDK 集成

在介绍这个SDK前,如果你的工程是直接使用从the Mercurial repository中下载的库文件,为了升级,你必须解决一些不兼容的问题。不用担心,保持你所有的源码不变,你仅仅只需要更新一下如何去把这个库文件导入你的工程中以及怎么导入头文件。


1.1.5.1. Switching to the Binary Distribution

This approach is recommended - the binary releases provide you with a stable development platform, isolating you from temporary instability and transient problems that may occur at the bleeding edge.
The first task is to reverse the previous ZBar integration:
Remove the reference to zbar.xcodeproj from your project.
Remove any zbar-* files from your Resources.
In the target build settings, remove any “Header Search Paths” that reference zbar.
Remove any references to zbar headers in your prefix.pch or source
files.
Now just continue with the integration instructions
above and you should be back up and running!


1.1.5.2. Continuing with Mercurial

Alternatively, you may still prefer to select Mercurial revisions. You have a few choices for this:
You may build your own ZBarSDK and copy/link it into your project. This is the same as Switching
to the Binary Distribution, except that you use your own version of the SDK. In this case you need to manually rebuild the SDK when you update it.
You may leave zbar.xcodeproj as a project dependency and pull the SDK into your project. This is not well tested, so ymmv.
You may leave zbar.xcodeproj as a project dependency and just link libzbar.a into your project, as before. You will need to update the target dependency (the library target changed names to libzbar) and add the iphone/include/ZBarSDK directory
to “Header Search Paths”
In any case, you should remove the references to the zbar headers from prefix.pch (or
your source files) and replace them with:

#import "ZBarSDK.h"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ZBar iOS 条形码