PhoneGap在iOS开发下的注意事项

敏捷个人应用主要是在Andorid下开发,发布的也主要是Andorid。之所以没有急着退出iOS版本,主要是因为开发iOS需要iOS的开发环境,发布还需要开发者账号,这些都需要资源或钱。而最近越来越多的敏友们期待着iOS版本的出现,为了感谢会员们的加入,所以还是决定投入开发iOS版本。

如果看过我之前写的关于敏捷个人应用开发的博客,应该知道我使用的是Phoengap。那么Phonegap在iOS下开发会遇到一些什么需要注意的事项呢?下面简要记录一下这次我遇到的一些问题,方便初次使用PhoenGap进行iOS下开发的朋友们。

敏捷个人手机应用截图

开发环境

  1. XCode 6.1
  2. PhoneGap 4.1.2-0.22.7

生成iOS项目

 $ cordova platform add ios

添加插件 

$ cordova plugin add org.apache.cordova.device

配置Phonegap 

  1. PhoneGap的配置文件在 【Staging】目录下的config.xml
  2. 设置启动页:   <content src="html/login.html"/>
  3. 添加可访问页面:    <access origin="http://www.zhoujingen.cn/*" />  ,否则会出现类似 ERROR whitelist rejection: url='http://www.zhoujingen.cn/ 的错误

 

设置XCode 项目

  • ARC forbids explicit messag send of'release' 
    • Targets-[Build settings]- CLANG_ENABLE_OBJC_ARC :No 
  • 整个窗口与ToolBar重合了,解决这个问题是设置Target: General :"Hide during..."  will work 

    • XCode6后是找到plist文件,添加一项:View controller-based status bar appearance,设置为no
  • 遇到类似“ Undefined symbols for architecture x86_64:

      "_SCNetworkReachabilityCreateWithAddress", referenced from:

          +[AFNetworkReachabilityManager managerForAddress:] in AFNetworkReachabilityManager.o”的错误,就上网找一下是缺少什么类库,例如这个示例显示的错误解决办法就是添加 CFNetwork.framework 类库

SVN在XCode放弃所有改变后

cordova/lib/copy-www-build-step.sh: Permission denied

解决办法:

cd platforms/ios/cordova/lib

sudo chmod 777 copy-www-build-step.sh

 

在Chrome下调试

Mac下打开Chrome跨域调试:open -a "Google Chrome" --args --disable-web-security 

ARC forbids explicit message send of release

在ios中经常会遇到:ARC forbids explicit message send of 'autorelease' 或“ARC forbids explicit message send of release”这样的错误。原因可能是项目使用了arc机制而有些文件禁止使用而报错,

解决方法:

1.禁用在Xcode中的特定文件的ARC

点击项目名,在中间一栏选择targets,然后选择build phases选项。

展开Compile Sources,找到你报错的文件名,然后双击添加-fno-objc-arc:如下图:

Undefined symbols for architecture armv7s:
  "_OBJC_CLASS_$_CATransaction", referenced from:
      objc-class-ref in CDVBarcodeScanner.o
ld: symbol(s) not found for architecture armv7s
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Try to add QuartzCore framework to link with your project. Go Build Phases -> Link Binary With Libraries and add QuartzCore.

 

posted on 2014-12-01 10:04  周 金根  阅读(7008)  评论(0编辑  收藏  举报

导航