iphone 开发中使用zbar时遇到的几个典型问题解决方法。
 
在近期的一个ios项目中使用到了一个二维码扫描库(Qrcode)--ZBar, 期间遇到2个问题。
 
1. zbar下载后使用其libzbar.a 发现无法再arm7上运行。
2. zbar使用过程中,如果多次打开摄像头扫描Qrcode,会出现memory leak problem, 导致其内存指数型增长,大概8次调用后即耗费了85M 左右的内存, 最后导致app崩溃。
3. libzbar.a 在重新编译后, 无法再在simulator中运行,编译链接时出现错误提示:
Undefined symbols for architecture armv7:
  "_OBJC_CLASS_$_ZBarReaderViewController", referenced from:
      objc-class-ref in HelloWorldViewController.o
  "_ZBarReaderControllerResults", referenced from:
      -[HelloWorldViewController imagePickerController:didFinishPickingMediaWithInfo:] in HelloWorldViewController.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
 
 
1.libzbar.a无法编译链接成功的问题。
打开zbar.xcodeprj ,在指定的a7 simulator平台或者实机上重新编译,将libzbar.a替换原有的。
 
 
2. mem leak 问题的解决。
找到ZBarReaderViewController.m 修改其loadView方法,改成如下形式。
 
- (void) loadView
{
   self.view = [[[UIView alloc]
                    ,  ,  ,  )] autorelease ];
}
 
添加了autorelease之后, 其内存使用状况就可以稳定在0.1M的范围内。
 
3. zbar的此问题出现的原因是: 在我解决上面的第二个问题时,只提取了Debug-iphoneos文件夹下的libzbar.a,此文件只能被实机link, 若要使得编译结果能device 和 simulator都能link, 可以依照如下方法解决。
主要思路:
1. 重编译时,设置Build Settings下的Architectures 和 valid Architectures为 arm64, armv7 , armv7s.
2. 重编译时,设置iOs deployment target 为ios 7.0 .
3. 在Product菜单中选择Schema->Edit Schema->Run->Build Configuration 为: Release。
4. 选择libzbar 分别选择不同实机和设备, 点击三角Run。
5. 在Xcode 工作区Products下非红色的libzbar.a ,右键找到其所在目录。 返回上一级
6. 运行: lipo -create Release-iphoneos/libzbar.a Release-iphonesimulator/libzbar.a -o libzbar.a
7. 拖拽 生成的libzbar.a 到 xcode 工程目录中, 选择copy到工作区。 
8. 完成!
 
 
参考:
http://stackoverflow.com/questions/22560899/xcode-5-1-undefined-symbols-for-architecture-x86-64-zbar
http://stackoverflow.com/questions/5387076/running-a-release-build-with-xcode-4
http://stackoverflow.com/questions/5287213/how-can-i-build-for-release-distribution-on-the-xcode-4
http://stackoverflow.com/questions/5706548/how-do-i-create-a-release-build-in-xcode-4
http://stackoverflow.com/questions/12339969/zbar-ifdef-issue-with-minizip-in-ios
http://stackoverflow.com/questions/18638319/zbar-memory-leak-on-ios
 

iphone 开发中使用zbar时遇到的几个典型问题解决方法。的更多相关文章

  1. iPhone开发中从一个视图跳到另一个视图有三种方法:

    iPhone开发中从一个视图跳到另一个视图有三种方法:   1.self.view addSubView:view .self.window addSubView,需要注意的是,这个方法只是把页面加在 ...

  2. Html开发中document.getElementByTagName无法找到所有DOM元素的问题解决方法

    let eleList = document.querySelectorAll('li') for (let i = 0; i < eleList.length; i++) { // 遍历操作 ...

  3. iPhone开发中,关于视图跳转的总结(转)

    iPhone开发中,关于视图跳转的总结 iPhone开发中从一个视图跳到另一个视图有三种方法: 1. self.view addSubView:view .self.window addSubView ...

  4. 在iPhone开发中实现解压缩gzip

    在iPhone开发中实现解压缩gzip是本文要介绍的内容,最近做的一个东西中,需要从网络获取xml文件,但是该文件用了gzip压缩的.搜索一 下有人说gzip压缩的用urlrequest可以自己解压, ...

  5. iphone开发中调用系统打电话功能

    iphone开发中调用打电话功能,一般有2种: 1.系统的打电话代码,不返回当前程序: Java代码 [[UIApplication sharedApplication] openURL:[NSURL ...

  6. WEB开发中一些常见的攻击方式及简单的防御方法

    WEB开发中一些常见的攻击方式及简单的防御方法 转载:http://blog.csdn.net/seven__________7/article/details/70896913

  7. IOS开发中滑动页面时NSTimer停止的问题

    我们在做倒计时的时候,发现当你手指按着屏幕不放,拖动tableView滑动的时候,写在cell上得倒计时停止倒计时,松开继续倒计时.研究发现就是拖动tableView滑动时,NSTimer停止了. 这 ...

  8. iPhone开发中的技巧整理

    1.NSCalendar用法 -(NSString *) getWeek:(NSDate *)d { NSCalendar *calendar = [[NSCalendar alloc] initWi ...

  9. iphone开发中数据持久化之——属性列表序列化(一)

    数据持久化是应用程序开发过程中的一个基本问题,对应用程序中的数据进行持久化存储,有多重不同的形式.本系列文章将介绍在iphone开发过程中数据持久化的三种主要形式,分别是属性列表序列号.对象归档化以及 ...

随机推荐

  1. jQuery Jcrop 图像裁剪

    jQuery Jcrop 图像裁剪 http://code.ciaoca.com/jquery/jcrop/ cropper.js 实现HTML5 裁剪图片并上传(裁剪上传头像.) https://b ...

  2. [UIView setShowsFPS:]: unrecognized selector sent to instance XXX

    今天在做sprite Kit game时遇到一个问题. 新建一个项目运行时发现就加了这几句代码无法运行.后来一查原来是storyboard uiview要改一下.改成SKview In your st ...

  3. 使用devenv/MSBuild在命令行编译sln或csproj

    一 使用devenv来build单个project   devenv是VisualStudio的可执行程序,一般安装在“C:\Program Files (x86)\Microsoft Visual ...

  4. FILTER——JAVA

    一.概念 Filter也称之为过滤器,它是Servlet技术中比较激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp, Servlet, 静态图片文件或 ...

  5. vue初始化数据加载

    使用created钩子 import AppLayout from '@/components/app-layout' import axios from 'axios' export default ...

  6. poj 1664 放苹果(递推)

    题目链接:http://poj.org/problem? id=1664 放苹果 Time Limit: 1000MS   Memory Limit: 10000K Total Submissions ...

  7. cocos2d-js V3.0 V3.1使用DragonBones

    DragonBones是Adobe支持的一个开源项目,用于制作和播放骨骼动画,官网地址是:http://dragonbones.effecthub.com/.DragonBones首先在Flash和S ...

  8. urllib2特点--超时设置

    # -*- coding: cp936 -*- #python 27 #xiaodeng #urllib2特点--超时设置 import urllib2 def urlopen(): url='htt ...

  9. CentOS 6.4 安装 rabbitmq(3.6.15)

    安装废了一番周折,中间需要装一个socat,网上各种过时的地址. 无奈去socat官网,结果提供编译安装,编译安装完yum install rabbitmq的时候仍然提示缺少需要的依赖,烦,好在折腾两 ...

  10. Linux系统下批量创建用户

    Linux批量创建用户 [root@ldapserver ~]# ) ; do useradd -d /home/ldapuser$i ldapuser#i; done [root@ldapserve ...