I cant get my ionic app to open in iOS emulator

My new ionic app won’t run in the iOS emulator.

Its a fresh install of ionic and Xcode, these are my steps:

npm install -g ionic

ionic start myApp tabs

ionic cordova platform add ios

ionic cordova build ios

ionic cordova emulate ios

Then I get the following error:

No target specified for emulator. Deploying to undefined simulator
/localhost/myApp/platforms/ios/build/emulator/MyApp.app/Info.plist
file not found.

According to this thread (Fresh Ionic Fails to Emulate iOS 12 - Info.plist file not found) it should work with the following command:

ionic cordova emulate ios -- --buildFlag="-UseModernBuildSystem=0"

But then I get the following error:

No target specified for emulator. Deploying to undefined simulator
Device type “com.apple.CoreSimulator.SimDeviceType.undefined” could not be found.

And then according to this thread (Issues starting iOS simulator from CLI) it should work by updating ios-sim like this:

cd platforms/ios/cordova && npm install ios-sim@latest

But I still get the following error:

No target specified for emulator. Deploying to undefined simulator
Device type “com.apple.CoreSimulator.SimDeviceType.undefined” could not be found.

How do I proceed from here?

Ionic:

   ionic (Ionic CLI)             : 4.10.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.0.1
   @angular-devkit/build-angular : 0.12.4
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.2.4
   @ionic/angular-toolkit        : 1.4.0

Cordova:

   cordova (Cordova CLI) : 8.1.2 (cordova-lib@8.1.1)
   Cordova Platforms     : ios 5.0.0
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 3.1.2, (and 4 other plugins)

System:

   ios-sim : 7.0.0
   NodeJS  : v10.15.1 (/usr/local/bin/node)
   npm     : 6.4.1
   OS      : macOS Mojave
   Xcode   : Xcode 10.1 Build version 10B61

This doesn’T match the description of how you added your Cordova platforms. Particular reason why you are not telling the whole story? (cordova platform add ios still installs 4.x)

You’re right. I think I’ve tried to manually update ios-sim to 5.0.0 by someones suggestions.

But it didn’t work before either, so any other suggestions?

I’ve just tried without updating ios-sim and its the same issue as written in the topic:

No target specified for emulator. Deploying to undefined simulator
Device type “com.apple.CoreSimulator.SimDeviceType.undefined” could not be found.

I haven’t mentioned ios-sim in my reply at all. My comment was about the wrong cordova-ios version.

Oh ok, so what do I do to try and fix it?

Step 1 would be to get your story straight. Did you do the steps you mentioned in your initial post or did you do other? If you are using cordova-ios 5.0.0, no need to not use the modern build system.

I tried a bunch of different stuff which is why cordova ios 5.0.0 was installed at the time I created this topic.

I did more debugging myself and there is an issue with ios-sim:

But my sake, could you try and start a ionic project with all latest versions and see if it’s working for you?

1 Like

ios-sim is a great piece of software, but also a brittle one :confused:

Could you paste your setup?

Versions of ionic, cordova, ios-sim and Xcode?
Then I can manually downgrade to get it working again. Right now I’m awfully stuck.

Hi, if you using xcode,folllow the steps,
1.ionic cordova platform add ios.
when platform add was completed.then goto xcode->open another project.where you put platform open platform inside of ios folder select.will automatically open our roject in xcode the n we want device run to our application.
Thank you this is xcode 10.0 and ionic 3 project.

Yes, I am aware of this but I need the livereload functionality. Otherwise it takes way to long for me to progress.

Hi,
Ya it will take long progress time.but what can we do?i know that way only.but you try to any other easy way.
Thank you!.

I had the same exact error, and the only way I could fix it was to factory reset my mac.
Now at this very moment, I just updated my xcode and this problem came to my face again.

In my case, this issue is caused by the latest XCode update. After the update ios-sim can’t fetch list of available simulators.

For example the following command returns nothing:

ionic cordova emulate --list

This issue is discussed here List empty of devices simulator with Xcode 10 · Issue #234 · ios-control/ios-sim · GitHub and it is fixed in ios-sim@next. However updating ios-sim won’t help because the module structure has changed and it causes issues in cordova scripts.

Have you tried this method? I’m gonna try it right after my xcode installs.

yes! I replaced all occurances of runtime.name to runtime.identifier in platforms/ios/cordova/node_modules/ios-sim/src/lib.js file. it worked!

Now I’m getting a new cordova error. Any idea?

Cannot read property ‘name’ of undefined

I didn’t see such an error but running an app with --verbose helped me to a lot:

ionic cordova run ios -l – --buildFlag=“-UseModernBuildSystem=0” --verbose

There is work around, simply run the below command you can specify target device and iOS version of your choice -

ionic cordova emulate ios --livereload --consolelogs --target="iPhone-X,com.apple.CoreSimulator.SimRuntime.iOS-12-2"