可可应用程序未在High Sierra上加载视图或运行代码 [英] Cocoa app not loading views or running code on High Sierra

查看:156
本文介绍了可可应用程序未在High Sierra上加载视图或运行代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Mac AppStore上有一个应用程序,最近有很多用户写信说它在High Sierra上不起作用(可能是10.13.6,很难从中提取特定信息)。我设法在朋友的设备上重现该问题,但是我无法使用该设备通过Xcode等进行构建。

I have an app on the Mac AppStore and many users have recently written to say it doesn't work on High Sierra (possibly 10.13.6, its hard to extract specific information from them). I managed to reproduce the issue on a friend's device, however I won't be able to use the device to build with Xcode etc.

问题似乎是 NSViewController 根本不加载它的子视图!

The issue seems to be the NSViewController doesn't load it's subviews at all! The grey view controller shown below should have dropdowns and buttons in it.

我还注意到关闭灰色窗口不会关闭红色透明窗口-在Mojave上,做到这一点按预期运行。状态栏中的自定义快捷方式/菜单项也不会运行所绑定的代码。请注意,红色窗口是通过灰色窗口中的代码显示的,因此一些代码正在运行。

I also noticed that closing the grey window doesn't close the red transparent window - on Mojave the code to do this runs as expected. A custom shortcut/menu item in the status bar also doesn't appear to run the code it's bound to. Note that the red window is presented via code from the grey window, so some code is managing to run.

这个模糊的线程似乎提到了相同的问题,正如。他们俩都没有要求编程解决方案。

This vague thread seems to mention the same issue, as does this question. Neither of them are asking for a programmatic solution however.

有人知道如何解决此问题,还是我需要告诉我的用户更新其操作系统?

Does anyone know how to fix this, or do I need to tell my users to update their OS?

编辑:设法在High Sierra上编译,并且视图仍然没有出现(视图调试器中也没有任何迹象)。控制台显示:

Edit: managed to compile on High Sierra and the views still aren't appearing (nor is there any sign of them in the view debugger). The console says:

2019-02-02 16:53:41.602178+1100 Translate This[20410:36446120] -[NSMenu setItemArray:]: unrecognized selector sent to instance 0x604000069180
2019-02-02 16:53:41.602366+1100 Translate This[20410:36446120] Failed to set (contentViewController) user defined inspected property on (NSWindow): -[NSMenu setItemArray:]: unrecognized selector sent to instance 0x604000069180
2019-02-02 16:54:57.678247+1100 Translate This[20410:36446120] -[NSStoryboard _bundle]: unrecognized selector sent to instance 0x600000000660
2019-02-02 16:54:57.728849+1100 Translate This[20410:36446120] -[NSStoryboard _bundle]: unrecognized selector sent to instance 0x600000000660

0x604000069180 NSMenu 。我没有在代码中显式地执行控制台输出中描述的任何事情。

0x604000069180 is an NSMenu. I'm not explicitly doing either of the things described in the console output in my code.

推荐答案

我遇到了相同的错误使用一个基于macOS 10.14构建的简单菜单栏应用程序,但在较早的OS版本上运行时失败:

I was having the same error with a simple menu bar app built on macOS 10.14 but failing when running on earlier OS versions:

[NSMenu setItemArray:]:无法识别的选择器发送至实例

当查看NSMenu的头文件时,我看到:

When looking at the header file for NSMenu I see:

/* Returns an array containing the receiver's menu items. 
   This property is settable in macOS 10.14 and later. */
open var items: [NSMenuItem]

所以您不能设置 menu.items = someItemsArray 而是使用其他API( menu.addItem(item) menu .removeAllItems()等)来解决此问题。

So you can't set menu.items = someItemsArray but rather use the other apis (menu.addItem(item), menu.removeAllItems(), etc) to fix the issue.

这似乎是Apple在Xcode 10中的一个疏忽,因为它没有警告您无法根据您应用的部署目标进行设置。

This appears to be an oversight by Apple in Xcode 10 by failing to warn you that it's not settable based on your app's deployment target.

https://openradar.appspot.com/45517851

这篇关于可可应用程序未在High Sierra上加载视图或运行代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆