什么是 SAObjects.framework?

What is SAObjects.framework?

我已经将 SACalendar 自定义 类 添加到我的 Xcode 项目中,现在当我 运行 应用程序时,我得到了这个日志:

objc[3230]: Class SACalendar is implemented in both /System/Library/PrivateFrameworks/SAObjects.framework/SAObjects and /private/var/mobile/Containers/Bundle/Application/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/MyApp.app/MyApp. One of the two will be used. Which one is undefined.

这是什么SAObjects.framework?这种冲突实际上会导致问题吗?

谢谢

正如消息所说,它是一个私有框架(意味着它包含没有 public API 的东西)。我想这个是从 iOS7.

开始发货的

IMO,Apple 应该更好地命名他们的私人 classes,并在他们前面加上下划线或其他东西,但他们没有。该框架甚至有 classes 没有特定的前缀(如 AceObject)。

由于 ObjectiveC 不支持名称空间,您可能(并且将会)遇到名称冲突。您所能做的就是重命名与系统框架冲突的 classes...并希望您选择的前缀没有被系统附带的其他框架选择。

我建议您重命名您的 SACalendar class,以及任何其他导致冲突的 classes。

如果您想了解该框架的内容,只需加载它并使用 objc 运行时来发现它的属性...或者使用许多已经可用的工具之一(例如 this one)。

好像是这样的:https://github.com/nopshusang/SACalendar

是的,这是一个问题。

但是,您遇到此问题是因为您和许多其他开发人员没有阅读 Objective-C 和 Cocoa 的命名约定。通常有两个错误:

  • 两个字母的前缀是为Apple保留的。你不被允许使用它。我真的不知道,为什么不尊重这个。这就是你的问题。

  • 前缀不是表示主题,而是代码的来源。因此,第三方开发人员从 Cocoa(NS-Prefix)扩展(subclass,类别)a class not 具有前缀NS。但是随处可见。

我真的不知道,为什么这么简单的规则就这么难接受。

Your own classes should use three letter prefixes. These might relate to a combination of your company name and your app name, or even a specific component within your app. As an example, if your company were called Whispering Oak, and you were developing a game called Zebra Surprise, you might choose WZS or WOZ as your class prefix.

至于SAObjects.framework实际上是做什么的,根据https://www.theiphonewiki.com/wiki/Siri,它包含"Resources for Siri objects"。