PhoneGap在iOS开发下的注意事项:
如果看过我之前写的关于个人应用开发的博客,应该知道我使用的是Phoengap。那么Phonegap在iOS下开发会遇到一些什么需要注意的事项呢?下面简要记录一下这次我遇到的一些问题,方便初次使用PhoenGap进行iOS下开发的朋友们。
* 开发环境: Xcode 6.1 PhoneGap 4.1.2-0.22.7*
生成iOS项目 :$ cordova platform add iOS
添加插件 :$ cordova plugin add org.apache.cordova.device
配置Phonegap PhoneGap的配置文件 :
1、在 【Staging】目录下的config.xml
2、设置启动页:
3、添加可访问页面:,否则会出现类似 ERROR whitelist rejection: url=’http://www.zhoujingen.cn/ 的错误
设置Xcode 项目
1、ARC forbids explicit messag send f’release’
1.1、Targets-[Build settings]- CLANG_ENABLE_OBJC_ARC :No
2、整个窗口与ToolBar重合了,解决这个问题是设置Target: General :”Hide during…” will work
2.2、 XCode6后是找到plist文件,添加一项:View controller-based status bar appearance,设置为no
3、遇到类似“ Undefined symbols for architecture x86_64:
3.1、”_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.
/bin/sh -c \”/Users/Shared/Jenkins/Home/jobs/myMobile\ -\ iOS/workspace/build/TDE.build/Release-iphoneos/TDE.build/Script-304B58A110DAC018002A0835.sh\”
/Users/Shared/Jenkins/Home/jobs/myMobile - iOS/workspace/build/TDE.build/Release-iphoneos/TDE.build/Script-304B58A110DAC018002A0835.sh: line 2: cordova/lib/copy-www-build-step.sh: Permission denied
* BUILD FAILED *
The following build commands failed:
PhaseScriptExecution Copy\ www\ directory build/TDE.build/Release-iphoneos/TDE.build/Script-304B58A110DAC018002A0835.sh
(1 failure)
Build step ‘XCode’ marked build as failure
Finished: FAILURE
权限错误:解决方法 在命令行数组:cd platforms/ios/cordova/lib(找到phoneGap的路径)
sudo chmod +x copy-www-build-step.sh(执行命令)