简体   繁体   English

如何在 iOS 模拟器上打开开发者工具?

[英]How do I open developer tools on iOS Simulator?

I am wanting to open developer tools on an iOS simulator我想在 iOS 模拟器上打开开发者工具

I have taken the following steps, on a 2016 MacBook running macOS Sierra 10.12.1 and don't know how to get any further:我在运行macOS Sierra 10.12.1的 2016 MacBook 上采取了以下步骤,但不知道如何进一步:

  • I have Xcode installed我已经安装了 Xcode
  • I create a new playground我创建了一个新的游乐场
  • Right click on the Xcode dock icon and click Open Developer Tool > Simulator右键单击 Xcode 停靠栏图标,然后单击 Open Developer Tool > Simulator
  • I now have an iOS simulator running whichever device I need, in my case iPhone 6 running IOS 10.0我现在有一个 iOS 模拟器,可以运行我需要的任何设备,在我的情况下是运行 IOS 10.0 的 iPhone 6

Now I am wondering what steps do I take to debug, and inspect elements on a webpage as I would in Safari or Chrome developer tools?现在我想知道我需要采取哪些步骤来调试和检查网页上的元素,就像在 Safari 或 Chrome 开发人员工具中一样?

Open Safari and go to Preferences.打开 Safari 并转到首选项。 Under the Advanced tab, at the bottom, you'll see "Show Develop menu in menu bar".在“高级”选项卡的底部,您将看到“在菜单栏中显示开发菜单”。 Make sure that is checked like in the image below.确保如下图所示进行检查。

高级偏好

Once that is checked, you'll see a new menu bar item named "Develop" between "Bookmarks" and "Window" in Safari's menu.选中后,您将在 Safari 菜单中的“书签”和“窗口”之间看到一个名为“开发”的新菜单栏项。 Under the Develop menu, select "Simulator" and then select the site you want to debug.在“开发”菜单下,选择“模拟器”,然后选择要调试的站点。 A new window with the developer tools will then pop up:然后会弹出一个带有开发者工具的新窗口:

开发者工具

Download https://developer.apple.com/safari/technology-preview/下载https://developer.apple.com/safari/technology-preview/

Open the website you want on your simulator.在模拟器上打开您想要的网站。

On "Safari Technology Preview", under在“Safari Technology Preview”上,在

Develop > Simulator --- [SimulatorName] > select your website from the list. Develop > Simulator --- [SimulatorName] >从列表中选择您的网站。

If you are on a mac, press CMD + G while running the Simulator on XCode.如果您使用的是 Mac,请在 XCode 上运行模拟器时按CMD + G This will allow you to Inspect element like you can on a web browser.这将允许您像在 Web 浏览器上一样Inspect element

To hide the menu, press CMD + D .要隐藏菜单,请按CMD + D

It looks like the most accepted answer incorrectly assumes the asker is wondering about Safari Simulator, not XCode Simulator.看起来最被接受的答案错误地假设提问者想知道 Safari Simulator,而不是 XCode Simulator。

If you're using React Native then you can install react-devtools globally and access devtools that way.如果您使用的是 React Native,那么您可以全局安装react-devtools并以这种方式访问​​ devtools。 To do this:去做这个:

  1. Install it by running npm install -g react-devtools from your terminal通过从终端运行npm install -g react-devtools来安装它
  2. Run react-devtools from your terminal从终端运行react-devtools
  3. Make sure your app is running in the simulator确保您的应用程序在模拟器中运行
  4. Open the in-app developer menu in the simulator by pressing cmd + Dcmd + D在模拟器中打开应用内开发者菜单

You should now see the components list from the React Devtools Electron app.您现在应该看到来自 React Devtools Electron 应用程序的组件列表。

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

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