Mac安装PhoneGap3
生活随笔
收集整理的這篇文章主要介紹了
Mac安装PhoneGap3
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Mac安裝PhoneGap3第一步需要安裝NodeJS,在Mac下有一個.pkg安裝包(Mac OS X Installer (.pkg),下載下來一路點擊就可以安裝成功了。在Terminal控制臺輸入node -v就可以看到安裝成功了。第二步是安裝PhoneGap,打開Terminal控制臺輸入:
$ sudo npm install -g phonegap安裝好了以后輸入創建第一個例子:
$ phonegap create my-app $ cd my-app $ phonegap run ios結果報錯:
[phonegap] detecting iOS SDK environment...[phonegap] using the local environment[phonegap] adding the iOS platform...[error] An error occured during creation of ios sub-project./bin/sh: /Users/umk/.cordova/lib/ios/cordova/3.3.0/bin/create: No such file or directory是因為PhoneGap用到Apache Cordova引擎,沒有安裝好,我國網絡狀況用Git的原因....只好手動下載一個Cordova,解壓,然后把內容全部復制到/Users/umk/.cordova/lib/ios/cordova/3.3.0/,然后再運行命令:
$ cd my-app $ phonegap run ios結果報錯:
[phonegap] compiling iOS...cp: copyFileSync: could not write to dest file (code=ENOENT):/Users/umk/my-app/platforms/ios/cordova/defaults.xmlevents.js:72throw er; // Unhandled 'error' event^Error: spawn ENOENTat errnoException (child_process.js:988:11)at Process.ChildProcess._handle.onexit (child_process.js:779:34)解決辦法是重新創建一個例子:
$ phonegap create my-app2 $ cd my-app2 $ phonegap run ios報錯說下載ios-sim失敗:
[phonegap] detecting iOS SDK environment...[phonegap] using the local environment[phonegap] adding the iOS platform...[phonegap] compiling iOS...[phonegap] successfully compiled iOS app[phonegap] trying to install app onto device[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] An error occurred while emulating/deploying the ios project. 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/這個好辦,下載ios-sim就可以了:
$ sudo npm install -g ios-sim再次運行成功,看到iPhone模擬器起來了:
[phonegap] detecting iOS SDK environment...[phonegap] using the local environment[phonegap] compiling iOS...[phonegap] successfully compiled iOS app[phonegap] trying to install app onto device[phonegap] no device was found[phonegap] trying to install app onto emulator[phonegap] successfully installed onto emulator?
這樣,my-app項目platforms/ios文件夾下會有xcode的porject,雙擊就可以用xcode打開。
附錄:我的版本情況
$ phonegap -v3.3.0-0.19.6$ node -vv0.10.26$ git --versiongit version 1.8.3.4 (Apple Git-47)$ cordova -v3.4.0-0.1.2?
?
轉載于:https://www.cnblogs.com/Mainz/p/3576835.html
總結
以上是生活随笔為你收集整理的Mac安装PhoneGap3的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MVC3入门教程
- 下一篇: HashMap的遍历