Run game on iPhone real device

Hi,

How can I run the game on an attached iPhone?
I execute:
cocos run -p ios

But It opens the simulator (that not support metal), so I want specify the iOS real device.

Thank you.

Hi,

I’m using with device in Xcode, so I didn’t use “cocos run” command. I create a folder that called “ios-build” and run below code, (docs: https://github.com/cocos2d/cocos2d-x/blob/v4/cmake/README.md#generate-macos-project)

cmake … -Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_SYSROOT=iphoneos

You will see xcodeproj file in ios-build folder. You can open this file via Xcode. I know that you need to Apple developer account for run in device. But, I read that Apple allow one device without Apple Developer Account before. If you have an account, you need to select provision file according to bundle identifier. Later, you can run in device.

I hope, this helps.
Thanks.

By default the command

cocos compile -p ios  

…will use the iPhone simulator. You can get a device build (which will fail the first time if you haven’t set up signing yet) but which will have all the CMake files set up:

cocos compile -p ios -sdk iphoneos

That I guess basically does what @kemalb above 's command does, but its a bit easier to type. Note that I found a few other gotcha’s after doing the above - I’ve been putting my notes on my blog.

1 Like

Thank you!