Xcode6でcocos runからシミュレーターを起動させる
社内でCocos2d-xの勉強会しようとプレゼン資料作りながら社内にある適当なmacとwindowsマシンで動作確認してたところ
どうやらXcode6入ってるmacだとcocos runでビルドは通るんだけどシミュレーターが起動しない
こんなエラーが出て止まってしまう
/usr/bin/touch -c /Users/matsuda/MyCppGame/bin/debug/ios/MyCppGame\ iOS.app ** BUILD SUCCEEDED ** build succeeded. Running command: deploy Deploying mode: debug Running command: run starting application running: '/Users/matsuda/cocos2d-x-3.2/tools/cocos2d-console/bin/../plugins/project_run/bin/ios-sim launch /Users/matsuda/MyCppGame/bin/debug/ios/MyCppGame.app &' ilojpt23589j3:MyCppGame matsuda$ 2014-09-27 18:40:27.667 ios-sim[6666:507] -[__NSArrayM localizedDescription]: unrecognized selector sent to instance 0x7fa1bad021a0 2014-09-27 18:40:27.670 ios-sim[6666:507] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM localizedDescription]: unrecognized selector sent to instance 0x7fa1bad021a0' *** First throw call stack: ( 0 CoreFoundation 0x00007fff980dc25c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x00007fff92819e75 objc_exception_throw + 43 2 CoreFoundation 0x00007fff980df12d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205 3 CoreFoundation 0x00007fff9803a272 ___forwarding___ + 1010 4 CoreFoundation 0x00007fff98039df8 _CF_forwarding_prep_0 + 120 5 ios-sim 0x0000000106f28e29 -[iPhoneSimulator LoadSimulatorFramework:] + 245 6 ios-sim 0x0000000106f2a8e0 -[iPhoneSimulator runWithArgc:argv:] + 2271 7 ios-sim 0x0000000106f2acb2 main + 101 8 ios-sim 0x0000000106f28ce4 start + 52 ) libc++abi.dylib: terminating with uncaught exception of type NSException
同じように困ってた人
解決方法
Error emulating IOS exit code 134 - Ionic
これを入力すれば良いらしい
sudo npm install ios-sim -g
npmてなんやねんって話ですが、
Node.jsのバージョン管理とかするやつっぽい
Node.js使うわけでないのでnpmだけ入れる方法探してみるも難航
素直に全部いれるのであればnodebrew入れてnodebrew install latestとかでいけるそう
HomeBrew入れる
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)" Whoops, the Homebrew installer has moved! Please instead run: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Also, please ask wherever you got this link from to update it to the above. Thanks!
リンク先変わったって教えてくれる!素晴らしい対応!素直に叩きなおす
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" ==> This script will install: /usr/local/bin/brew /usr/local/Library/... /usr/local/share/man/man1/brew.1 ==> The following directories will be made group writable: /usr/local/. /usr/local/bin ==> The following directories will have their group set to admin: /usr/local/. /usr/local/bin Press RETURN to continue or any other key to abort ==> /usr/bin/sudo /bin/chmod g+rwx /usr/local/. /usr/local/bin Password: ==> /usr/bin/sudo /usr/bin/chgrp admin /usr/local/. /usr/local/bin ==> /usr/bin/sudo /bin/mkdir /Library/Caches/Homebrew ==> /usr/bin/sudo /bin/chmod g+rwx /Library/Caches/Homebrew ==> Downloading and installing Homebrew... remote: Counting objects: 199994, done. remote: Compressing objects: 100% (54010/54010), done. remote: Total 199994 (delta 144802), reused 199994 (delta 144802) Receiving objects: 100% (199994/199994), 41.97 MiB | 1.15 MiB/s, done. Resolving deltas: 100% (144802/144802), done. From https://github.com/Homebrew/homebrew * [new branch] master -> origin/master HEAD is now at 5057268 ledger: update 3.0.3_1 bottle. ==> Installation successful! ==> Next steps Run `brew doctor` before you install anything Run `brew help` to get started
確認
$ brew -v
Homebrew 0.9.5
出来てる
ios-sim入れる
$ brew install ios-sim ==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/ios-sim-2.0.1.mavericks.bottle.tar.gz ######################################################################## 100.0% ==> Pouring ios-sim-2.0.1.mavericks.bottle.tar.gz /usr/local/Cellar/ios-sim/2.0.1: 4 files, 116K
確認
$ ios-sim --version
2.0.1
ちなみにこけてたやつはと言うと
$ /Users/matsuda/cocos2d-x-3.2/tools/cocos2d-console/bin/../plugins/project_run/bin/ios-sim --version
1.9.0
新しいバージョンのもので試してみる
$ ios-sim launch /Users/matsuda/MyCppGame/bin/debug/ios/MyCppGame.app &
出来た( ・`д・´)
なので、こいつを
~/cocos2d-x-3.2/tools/cocos2d-console/bin/../plugins/project_run/bin/ios-sim
新しいやつに置き換えれば良い
インストールしたios-simがどこにあるか確認
$ which ios-sim /usr/local/bin/ios-sim $ ls -la /usr/local/bin/ total 48 drwxrwxr-x 7 root admin 238 9 28 22:58 . drwxrwxr-x 15 root admin 510 9 28 22:58 .. -rw-r--r--@ 1 matsuda admin 6148 9 28 22:58 .DS_Store -rwxr-xr-x 1 matsuda admin 743 9 27 19:27 brew -rwxr-xr-x@ 1 root wheel 3811 9 20 15:14 diff-highlight lrwxr-xr-x 1 matsuda admin 35 9 27 19:28 ios-sim -> ../Cellar/ios-sim/2.0.1/bin/ios-sim -rwxr-xr-x 1 root wheel 2672 6 4 10:41 pstorm
ここにあるらしい
/usr/local/Cellar/ios-sim/2.0.1/bin/ios-sim
$cp /usr/local/Cellar/ios-sim/2.0.1/bin/ios-sim ~/cocos2d-x-3.2/tools/cocos2d-console/bin/../plugins/project_run/bin/ios-sim
これでcocos runでシミュレータが起動するようになりました。
めでたしめでたし
別にシンボリックリンク外したパス指定する必要ないよね(´・ω・`)
ということに気づいたけどまぁいいやw