Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cant run ios simulator on cordova

On running the command

cordova emulate ios

I get an error, as below. I actually get rm: could not remove & permission denied errors so I use sudo. I was able to run this no problem, and then after a reboot - although nothing was changed - this function does not work. After build succeeded - deploying to emulator I get this error

 An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=159):
    Invalid device state
    ENOENT: no such file or directory, stat '/Users/user/Library/Logs/CoreSimulator/8F3C9A0F-D432-49A4-84DA-D0480829884A/system.log'
    Error code 1 for command: ios-sim with args: launch,/Users/user/helloworld/platforms/ios/build/emulator/helloworld.app,--devicetypeid,com.apple.CoreSimulator.SimDeviceType.iPhone-4s,--stderr,/Users/user/helloworld/platforms/ios/cordova/console.log,--stdout,/Users/user/helloworld/platforms/ios/cordova/console.log,--exit
    Error: /Users/user/helloworld/platforms/ios/cordova/run: Command failed with exit code 2
        at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
        at emitTwo (events.js:87:13)
        at ChildProcess.emit (events.js:172:7)
        at maybeClose (internal/child_process.js:818:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)

I have reinstalled sudo npm install ios-sim -g and same error. How can I run it properly?

like image 846
Jon Avatar asked Oct 28 '15 18:10

Jon


People also ask

Does Cordova work for iOS?

Cordova for iOS projects can be opened in Xcode. This can be useful if you wish to use Xcode built in debugging/profiling tools or if you are developing iOS plugins. Please note that when opening your project in Xcode, it is recommended that you do NOT edit your code in the IDE.

How do I run a specific iOS simulator?

Specifying a device​ You can specify the device the simulator should run with the --simulator flag, followed by the device name as a string. The default is "iPhone 13" . If you wish to run your app on an iPhone SE (2nd generation), run npx react-native run-ios --simulator='iPhone SE (2nd generation)' .

Do I need Xcode for iOS simulator?

Launching the Simulator, though, always requires opening Xcode and going to Developer Tools. Because the Simulator. app is embedded within the Xcode app bundle, apps like LaunchBar won't find it to index it.

How can I launch the iOS simulator from terminal?

Just type this command in Terminal: open -a Simulator. app to launch the most recent simulator. Type this command in Terminal to run the Simulator rigth from the its folder.


1 Answers

This happens due to the permissions on mac:

Here are the steps you can use to correct this issue:

Empty the 'platforms' folder in your Cordova project.

Re-run Cordova platform add ios, Cordova build ios, and Cordova emulate ios without sudo.

If you are on a Mac and are still getting a permissions error, make sure all the files in your user's home folder actually belong to that user by running sudo chown -R username /Users/username

like image 54
Kiat Han Avatar answered Oct 06 '22 00:10

Kiat Han