phonegap + xcode5.0.2 配置开发环境

时间:2024-07-05 12:08:08

phonegap官网:  http://phonegap.com/

第一部:安装nodejs

安装地址:http://nodejs.org/

安装phoneGap 官网下载http://phonegap.com/install/

$ sudo npm install -g phonegap   这部安装可能慢些,耐心等待下

安装成功

usr/local/bin/phonegap -> /usr/local/lib/node_modules/phonegap/bin/phonegap.js

phonegap@3.4.0-0.19.11 /usr/local/lib/node_modules/phonegap

├── pluralize@0.0.4

├── colors@0.6.0-1

├── semver@1.1.0

├── qrcode-terminal@0.9.4

├── shelljs@0.1.4

├── optimist@0.6.0 (wordwrap@0.0.2, minimist@0.0.8)

├── phonegap-build@0.8.4 (qrcode-terminal@0.8.0, optimist@0.3.7, shelljs@0.0.9, phonegap-build-api@0.3.3)

├── prompt@0.2.11 (revalidator@0.1.6, pkginfo@0.3.0, read@1.0.5, utile@0.2.1, winston@0.6.2)

├── cordova@3.4.0-0.1.2 (mime@1.2.11, q@0.9.7, semver@2.0.11, underscore@1.4.4, plist-with-patches@0.5.1, xcode@0.6.6, elementtree@0.1.5, npmconf@0.1.13, tar@0.1.19, request@2.21.0, plugman@0.20.1)

└── connect-phonegap@0.8.3 (home-dir@0.1.2, connect-inject@0.3.2, address@0.0.3, shelljs@0.2.6, request-progress@0.3.1, node-static@0.7.0, tar@0.1.19, useragent@2.0.8, request@2.33.0, gaze@0.4.3, connect@2.12.0)

第二部 修改local 文件夹权限

sudo chown -R $USER /usr/local

sudo chmod -R 0775 /usr/local

第三部分

npm install -g cordova

第四部分

cd   /usr/local/lib/node_modules/phonegap/lib/phonegap

$ phonegap create my-app

安装成功

[phonegap] missing library phonegap/www/3.4.0

[phonegap] downloading https://github.com/phonegap/phonegap-app-hello-world/archive/3.4.0.tar.gz...

[phonegap] the options undefined /usr/local/lib/node_modules/phonegap/lib/phonegap/my-app com.phonegap.helloworld HelloWorld

[phonegap] created project at /usr/local/lib/node_modules/phonegap/lib/phonegap/my-app

localhost:my-app lsr$ ls

hooks merges platformspluginswww

www目录中存放的是HTML/JS/CSS

以及一个res子目录。其中res目录存放多个平台的图标与启动画面。

platforms目录目前是空的,建立多个平台的工程时会在此目录中新增相应的工程目录。

plugins目录目前是空的,新增插件的时候会下载到此目录中。

第五部分

phonegap run ios

创建成功

detecting iOS SDK environment...

[phonegap] using the local environment

[phonegap] adding the iOS platform...

[phonegap] missing library cordova/ios/3.4.0

[phonegap] downloading https://git-wip-us.apache.org/repos/asf?p=cordova-ios.git;a=snapshot;h=3.4.0;sf=tgz...

[phonegap] compiling iOS...

Build settings from command line:

ARCHS = i386

CONFIGURATION_BUILD_DIR = /usr/local/lib/node_modules/phonegap/lib/phonegap/my-app/platforms/ios/build/emulator

SDKROOT = iphonesimulator7.0

VALID_ARCHS = i386

=== BUILD TARGET CordovaLib OF PROJECT CordovaLib WITH CONFIGURATION Debug ===

** BUILD SUCCEEDED **

[phonegap] successfully compiled iOS app

[phonegap] trying to install app onto device

Error: ios-deploy was not found. Please download, build and install version 1.0.4 or greater from https://github.com/phonegap/ios-deploy into your path. Or 'npm install -g ios-deploy' using node.js: http://nodejs.org/

[phonegap] no device was found

[phonegap] trying to install app onto emulator

[warning] missing ios-sim

[warning] install ios-sim from http://github.com/phonegap/ios-sim

Error: ios-sim was not found. Please download, build and install version 1.7 or greater from https://github.com/phonegap/ios-sim into your path. Or 'npm install -g ios-sim' using node.js: http://nodejs.org/

[error] /usr/local/lib/node_modules/phonegap/lib/phonegap/my-app/platforms/ios/cordova/run: Command failed with exit code 1

我们在platforms 文件夹里打开工程

phonegap + xcode5.0.2 配置开发环境