NotificationCenter在构建watchOS模拟器时不可用



我想在watchOS目标中使用NotificationCenter。但是当我在import NotificationCenter构建应用程序时,我得到以下错误信息:

NotificationCenter is not available when building for watchOS Simulator.
Consider using `#if !os(watchOS)` to conditionally import this framework.

你如何处理这种情况?我可以不再使用模拟器吗?

好吧,我把事情搞混了。我想在watchOs框架中做的就是这样:

NotificationCenter.default.post(...)

具有import NotificationCenter的类在错误的框架中。在watchOs框架中不需要这样的类。所以我的问题解决了。

最新更新