简体   繁体   English

xamarin for Visual Studio 未显示模拟器列表

[英]xamarin for visual studio not showing simulator list

I'm pretty new to xamarin, tried to run a sample application (IOS).我对 xamarin 很陌生,试图运行一个示例应用程序(IOS)。 But Visual Studio says: "Please select a valid device before running the application"但是 Visual Studio 说: "Please select a valid device before running the application"

I know on the IOS toolbar, there should be option to select which device to simulate (list of supported IOS devices like iphone 6, 5s etc), but I don't get that.我知道在 IOS 工具栏上,应该有选项可以选择要模拟的设备(支持的 IOS 设备列表,如 iphone 6、5s 等),但我不明白。

EDIT: To be more precise, TARGET IOS Device not shown on IOS Tool bar编辑:更准确地说,目标 IOS 设备未显示在 IOS 工具栏上

I had the same problem a year back - please check the following:一年前我遇到了同样的问题 - 请检查以下内容:

  • XCode is installed已安装 XCode
  • you have started XCode once (to accept license agreement)你已经启动了一次 XCode(接受许可协议)
  • Xamarin Build Host is installed Xamarin 构建主机已安装
  • Visual Studio and Mac Build Host are connected Visual Studio 和 Mac Build Host 已连接
  • Simulators work on MAC-side when started with XCode (just use a sample project)使用 XCode 启动时,模拟器在 MAC 端工作(只需使用示例项目)
  • Check that you are using latest versions of Xamarin (often, there are major bugs in intermediate versions of Xamarin that are updated relatively quickly), also check that they are compatible with your XCode version and that VS and Mac versions are compatible (only certain versions can cooperate)检查您是否使用最新版本的 Xamarin(通常,Xamarin 的中间版本中存在更新相对较快的主要错误),还要检查它们是否与您的 XCode 版本兼容以及 VS 和 Mac 版本是否兼容(仅某些版本可以合作)
  • using non-latest versions on Mac side can help (eg new XCode releases often are unsupported for a few days till there is an update on Xamarin side)在 Mac 端使用非最新版本会有所帮助(例如,新的 XCode 版本通常在几天内不受支持,直到 Xamarin 端有更新)
  • Make sure that iOS project is selected for start确保选择了 iOS 项目进行启动
  • Sometimes, you need to re-establish connection with Build host for things to work properly有时,您需要重新建立与 Build 主机的连接才能正常工作
  • Sometimes, you need to restart your systems有时,您需要重新启动系统
  • You got correct licenses (you need Business or Enterprise on both Windows and Mac)您获得了正确的许可证(您需要在 Windows 和 Mac 上使用 Business 或 Enterprise)

I think for me it was outdated versions and a hickup in the software, after a reboot it worked.我认为对我来说这是过时的版本和软件中的故障,重新启动后它可以工作。

  1. Quit Visual Studio.退出 Visual Studio。
  2. Open your XCode.打开你的 XCode。
  3. Restart Visual Studio.重新启动 Visual Studio。
  4. Select your ios app > Debug > "Now you can see list of simulators"选择您的 ios 应用程序 > 调试 > “现在您可以看到模拟器列表”
  5. Quit Xcode.退出 Xcode。

OR If above steps do not work then try adding new build configuration as shown in following image by selecting iphoneSimulator.或如果上述步骤不起作用,则尝试通过选择 iphoneSimulator 添加新的构建配置,如下图所示。

在此处输入图片说明

Once in a while I always used to have this issue and solves it by starting Xcode first and then opening VS after.偶尔我总是遇到这个问题,并通过先启动 Xcode 然后再打开 VS 来解决它。 But recently it became consistent after Xcode 12.5 update.但最近在 Xcode 12.5 更新后变得一致。 So as a trial, I uninstalled VS and reinstalled and now this workaround also stopped working.因此,作为试用,我卸载了 VS 并重新安装,现在此解决方法也停止工作。 It's very annoying and there is a bug already reported to Microsoft to fix this.这很烦人,并且已经向微软报告了一个错误来解决这个问题。

The solution that worked for me is to对我有用的解决方案是

  1. Create a multi platform sample project in VS, and viola!在VS中创建一个多平台示例项目,中提琴! I could see all my simulators in my sample project.我可以在我的示例项目中看到我所有的模拟器。
  2. Now, close this solution (no need to close VS) and open your solution.现在,关闭此解决方案(无需关闭 VS)并打开您的解决方案。 All your simulators are back.你所有的模拟器都回来了。

Unfortunately, you always have to open your sample sln first (but no need to create new sln every time) whenever you want to open your solution.不幸的是,每当您想打开您的解决方案时,您总是必须首先打开您的示例 sln(但无需每次都创建新的 sln)。 But it solves the problem.但它解决了问题。

If you're using the latest XCode version, be sure it's compatible with your Xamarin.iOS and Visual Studio.如果你使用的是最新的 XCode 版本,请确保它与你的 Xamarin.iOS 和 Visual Studio 兼容。 For me, XCode 13 came out a few days ago and wasn't compatible with the latest Visual Studio.对我来说,XCode 13 几天前发布,与最新的 Visual Studio 不兼容。 You can download an older version of XCode at https://developer.apple.com/download/more/ , just be sure to change visual studio to point to the downgraded version in Visual Studio > Preferences > SDK Locations > Apple您可以在https://developer.apple.com/download/more/下载旧版本的 XCode,只需确保在 Visual Studio > Preferences > SDK Locations > Apple 中将 Visual Studio 更改为指向降级版本

I had a similar issue.我有一个类似的问题。 However, I was able to resolve it by going to XCode>Preferences>Accounts>ViewDetails>Download all.但是,我可以通过转到 XCode>Preferences>Accounts>ViewDetails>Download all 来解决它。 This caused visual studio to now display my device IOS name in the dropdown menu.这导致 Visual Studio 现在在下拉菜单中显示我的设备 IOS 名称。

另一个可能的原因:在编辑 iOS 平台项目的 info.plist 时出错可能会导致这种情况发生。

This has started helping me out a lot with VS for Mac when all other options have failed!当所有其他选项都失败时,这已经开始帮助我使用 VS for Mac 了!

  • Quit VS for Mac退出 VS for Mac
  • Run this in your terminal: sudo xcode-select --switch /Applications/Xcode.app在终端中运行: sudo xcode-select --switch /Applications/Xcode.app
  • Reopen solution in VS for Mac, and you should be able to see the option在 VS for Mac 中重新打开解决方案,您应该能够看到该选项

My issue was that I needed to log into my Apple developer account in XCode again.我的问题是我需要再次在 XCode 中登录我的 Apple 开发者帐户。 For some reason it was showing an error state in XCode>Preferences>Account出于某种原因,它在 XCode>Preferences>Account 中显示错误状态

I logged into my account again then clicked the "download manual" button and now the devices show up in VS.我再次登录我的帐户,然后单击“下载手册”按钮,现在设备显示在 VS 中。

Are you sure that the device is connected to the right machine?您确定该设备已连接到正确的机器吗? When I have a VM open on my iMac, I get prompted for which machine I want to connect a device to.当我在 iMac 上打开 VM 时,系统会提示我要将设备连接到哪台机器。

Also make sure that you have Debug and iPhone Simulator selected.还要确保您选择了DebugiPhone Simulator

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

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