繁体   English   中英

无法在cordova上运行ios模拟器

[英]cant run ios simulator on cordova

在运行命令时

cordova emulate ios

我收到错误,如下所示。 我实际上得到rm: could not removepermission denied错误所以我使用sudo。 我能够运行这个没有问题,然后重新启动后 - 虽然没有任何改变 - 这个功能不起作用。 build succeeded - deploying to emulator我得到此错误

 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)

我重新安装了sudo npm install ios-sim -g和同样的错误。 我怎样才能正常运行?

这是因为mac上的权限:

以下是您可以用来解决此问题的步骤:

清空Cordova项目中的“platforms”文件夹。

重新运行Cordova platform add iosCordova build iosCordova emulate ios 而不使用 sudo

如果您在Mac上并且仍然收到权限错误,请通过运行sudo chown -R username /Users/username确保用户主文件夹中的所有文件实际上属于该用户

当您没有root用户的模拟器配置时,就会发生这种情况。

以下命令对我有用

sudo npm install -g ios-sim

如果它不起作用,您可以尝试以root用户身份删除平台,并将其作为普通用户添加回来。

发生这种情况是因为系统中未安装xcode命令行工具https://github.com/driftyco/ionic/issues/4657 从您的终端执行xcode-select --install并重新启动系统应该可以正常工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM