在 IOS 上调试 Ionic 应用程序?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25689270/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:14:24  来源:igfitidea点击:

Debug Ionic app on IOS?

iosiphonedebuggingcordovaionic-framework

提问by Ben Taliadoros

My HTML5 app is packaged by Ionic (using Cordova) and loads onto my iPhone like a normal app.

我的 HTML5 应用程序由 Ionic(使用 Cordova)打包并像普通应用程序一样加载到我的 iPhone 上。

Can I debug whilst connected to the device? I know with Android you have logcat and in the browser I have dev tools but there are differences between the app on device and the browser and I want to know why.

我可以在连接到设备时进行调试吗?我知道在 Android 上你有 logcat,在浏览器中我有开发工具,但设备上的应用程序和浏览器之间存在差异,我想知道为什么。

Any help appreciated.

任何帮助表示赞赏。

Thanks

谢谢

回答by Jeremy Wilken

There are three primary options.

有三个主要选项。

  1. Debug using Safari. This is good for debugging a hybrid app, but cannot tell you output related to native plugins. http://webdesign.tutsplus.com/articles/quick-tip-using-web-inspector-to-debug-mobile-safari--webdesign-8787
  2. Open the project and build to device in Xcode. This shows the output of the entire device http://cordova.apache.org/docs/en/3.5.0/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide
  3. Debug with Ionic CLI. Using ionic run ios -l -c -swith the flags will use live reload and print the logs to the console. http://ionicframework.com/blog/live-reload-all-things-ionic-cli/
  1. 使用 Safari 进行调试。这对于调试混合应用程序很有用,但无法告诉您与本机插件相关的输出。http://webdesign.tutsplus.com/articles/quick-tip-using-web-inspector-to-debug-mobile-safari--webdesign-8787
  2. 在 Xcode 中打开项目并构建到设备。这显示了整个设备的输出http://cordova.apache.org/docs/en/3.5.0/guide_platforms_ios_index.md.html#iOS%20Platform%20Guide
  3. 使用 Ionic CLI 进行调试。使用ionic run ios -l -c -s带有标志将采用现场重装和打印日志到控制台上。http://ionicframework.com/blog/live-reload-all-things-ionic-cli/

回答by littlequest

Similar to the first answer, here's how I debug on iOS.

与第一个答案类似,这是我在 iOS 上调试的方式。

ionic emulate ios -lc

Which runs app using simulator and outputs console logs and errors to terminal with live reloading.

它使用模拟器运行应用程序,并通过实时重新加载将控制台日志和错误输出到终端。

回答by vuhung3990

i'm using ionic 2 and typescript. you can use debuggerkeyword to debug on ios like this:

我正在使用 ionic 2 和打字稿。您可以使用debugger关键字在 ios 上进行调试,如下所示:

enter image description here

enter image description here

then open safari -> developer -> simulate -> index.html, good luck

然后打开 safari -> developer -> 模拟 -> index.html,祝你好运

enter image description here

enter image description here

回答by jdnichollsc

You can use Visual Studio Code with the following extension: https://marketplace.visualstudio.com/items?itemName=vsmobile.cordova-tools

您可以使用具有以下扩展名的 Visual Studio Code:https: //marketplace.visualstudio.com/items?itemName=vsmobile.cordova-tools

Regards, Nicholls

问候, 尼科尔斯

回答by Raymond Camden

I'd also add that in Ionic 1.2, you can get console/error output right in Terminal via ionic serveor ionic emulate.

我还要补充一点,在 Ionic 1.2 中,您可以通过ionic serve或直接在终端中获得控制台/错误输出ionic emulate