ionic serve on iOS 14 device. Error “Invalid Service”

心已入冬 提交于 2021-01-21 10:22:15

问题


After upgrading an iPhone6s to iOS 14 and Xcode to the latest version, I am unable to serve the app.

The error stack is as following

Error: InvalidService
    at LockdownProtocolReader.parseBody (/usr/local/lib/node_modules/native-run/node_modules/node-ioslib/dist/protocol/lockdown.js:35:19)
    at LockdownProtocolReader.onData (/usr/local/lib/node_modules/native-run/node_modules/node-ioslib/dist/protocol/protocol.js:52:40)
    at TLSSocket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)
    at TLSSocket.Readable.push (_stream_readable.js:212:10)
    at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)

running with --verbose shows the origin of the error

client:lockdownd startService: com.apple.debugserver +898ms
  protocol:lockdown socket write: {"Request":"StartService","Service":"com.apple.debugserver"} +206ms
  protocol:lockdown Response: {"Error":"InvalidService","Request":"StartService","Service":"com.apple.debugserver"} +6ms
  native-run Caught fatal error: Error: InvalidService

my serve script is

ionic cordova run iOS --l --debug --device --address=0.0.0.0 --sourceMap=true

Ionic info:

Ionic:

   Ionic CLI                     : 6.11.8 (/usr/local/lib/node_modules/@ionic/cli)
   Ionic Framework               : @ionic/angular 5.2.2
   @angular-devkit/build-angular : 0.900.7
   @angular-devkit/schematics    : 9.1.4
   @angular/cli                  : 9.1.4
   @ionic/angular-toolkit        : 2.2.0

Cordova:

   Cordova CLI       : 9.0.0 (cordova-lib@9.0.1)
   Cordova Platforms : ios 5.1.1
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 4.2.1, (and 20 other plugins)

Utility:

   cordova-res                          : not installed
   native-run (update available: 1.1.0) : 1.0.0

System:

   ios-deploy : 1.10.0
   ios-sim    : 8.0.2
   NodeJS     : v12.18.0 (/usr/local/bin/node)
   npm        : 6.14.5
   OS         : macOS Catalina
   Xcode      : Xcode 12.0 Build version 12A7209

what I have tried so far.

  • reboot Mac
  • reboot iPhone
  • make sure latest iOS/Mac/Xcode version is installed
  • clean build

running on emulator is working fine btw. I can also perform ionic build and run via Xcode on the device.


回答1:


I solved it by updating native-run to 1.2.1 (see https://github.com/ionic-team/native-run/issues/60, support for iOS 14 has been added in 1.2.0 on 2020-09-28):

npm i -g native-run@latest



回答2:


Try commenting

     if (isLockdownErrorResponse(resp)) {
         throw new Error(resp.Error);
     }

inside the file

/usr/local/lib/node_modules/native-run/node_modules/node-ioslib/dist/lockdown.js

It worked for me




回答3:


Got the same error while i was using native-run.

So i tried to run it without native-run and used cordova instead with the flag --no-native-run. The command that worked for me:

ionic cordova run ios -l --address=0.0.0.0 --no-native-run



回答4:


So native-run seems buggy.

But in fact in ionic-cli, you can pass a param to use cordova instead of native-run and it's work :

ionic cordova run ios --no-native-run

My personal command :

ionic cordova run ios --livereload --consolelogs --buildFlag='-UseModernBuildSystem=0'  --external --no-native-run



回答5:


I am having the same problem. According to this post https://github.com/ios-control/ios-deploy/issues/469 an update to ios-deploy 1.11.2 should solve the problem. I've tried it, multiple times + reinstalling Xcode and other options but nothing works. I am curious if an update to ios-deploy will work for you, so let me know please!



来源:https://stackoverflow.com/questions/63956106/ionic-serve-on-ios-14-device-error-invalid-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!