cordova使用笔记_在本地项目中添加cordova

2017-11-21  本文已影响277人  Dawn_wdf

创建一个cordova项目:http://www.jianshu.com/p/8773ab98a833
config.xml文件分析:http://www.jianshu.com/p/518e55452821

两种方式来使本地项目支持cordova

使用carthage来配置

git "git://git.apache.org/cordova-ios.git" "<version_or_tag>" # Apache

然而:

A shell task (/usr/bin/env git clone --bare --quiet git://git.apache.org/cordova-ios.git /Users/dawnwang/Library/Caches/org.carthage.CarthageKit/dependencies/cordova-ios) failed with exit code 128:
fatal: remote error: access denied or repository not exported: /cordova-ios.git

感受一下我内心的羊驼。。。。。。

手动加入

  1. 如果Xcode在运行,则先退出(官方这么说,虽然我不知道为啥)
  2. 拷贝config.xml和CordovaLib/CordovaLib.xcodeproj文件进入工程
  3. 打开Xcode,右键点击添加文件,将上面两个文件加入工程
  4. 在other linker flags中配置-force_load 和 -ObjC
  5. Build Phases->Link Binaries with Libraries.添加
AssetsLibrary.framework
CoreLocation.framework
CoreGraphics.framework
MobileCoreServices.framework
libCordova.a
  1. Target Dependencies中添加CordovaLib
  2. Header Search Paths
"$(TARGET_BUILD_DIR)/usr/local/lib/include"
"$(OBJROOT)/UninstalledProducts/include"
"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include"
"$(BUILT_PRODUCTS_DIR)"

运行报错

ld: file not found: -ObjC
clang: error: linker command failed with exit code 1 (use -v to see invocation)

解决:我的第4步的other linker flags是配置在了本地工程的target下,事实上应该放在CordovaLib.xcodeproj工程下
此时Command+R运行正常

使用CDVViewController

demo传送门:https://github.com/DawnWdf/DW_TestCordovaManully

后续:http://www.jianshu.com/p/43895cc97a01

参考:http://www.jianshu.com/p/e982b9a85ae8

上一篇 下一篇

猜你喜欢

热点阅读