3

我正在开发一个 Safari 应用程序扩展。以前它工作得很好。当我在 Xcode 中运行项目并在 Safari 中启用Allow Unsigned Extensions时,我可以在Safari Preferences -> Extensions页面中看到我的扩展。

在我与我的一位团队成员合并代码后,突然无法安装扩展。

我努力了:

  • 清理 Xcode 中的 build 文件夹,然后再次运行。但没有运气。
  • 重新启动 Xcode 也无济于事。
  • 使用命令pluginkit -mAvvv -p com.apple.Safari.extension检查已安装的 Safari 扩展列表。我的分机不在列表中。

Xcode 输出中有一些错误,但我无法将它们与我面临的问题联系起来:

objc[49476]: Class AMSupportURLConnectionDelegate is implemented in both /System/Library/PrivateFrameworks/EmbeddedOSInstall.framework/Versions/A/EmbeddedOSInstall (0x7fff9a2aa748) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108db2600). One of the two will be used. Which one is undefined.
objc[49476]: Class AMSupportURLSession is implemented in both /System/Library/PrivateFrameworks/OSPersonalization.framework/Versions/A/OSPersonalization (0x7fff9b5d49f0) and /System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108db2650). One of the two will be used. Which one is undefined.
2018-12-13 16:25:46.003099+0800 Safari[49476:1264277] Could not connect action, target class SecurityPreferences does not respond to -toggleJavaScriptCanOpenWindows:
2018-12-13 16:25:46.163130+0800 Safari[49476:1264277] AssertMacros: 0 (value = 0x0),  file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKitXPCClient.m, line: 75
2018-12-13 16:25:46.163219+0800 Safari[49476:1264277] AssertMacros: 0 (value = 0x0),  file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKitXPCClient.m, line: 396
2018-12-13 16:25:46.163465+0800 Safari[49476:1264277] [Framework-Internal-Legacy] AssertMacros: _xpcClient (value = 0x0),  file: /BuildRoot/Library/Caches/com.apple.xbs/Sources/BiometricKit/BiometricKit-75.71.1/BiometricKit/BiometricKit.m, line: 137
2018-12-13 16:25:47.060959+0800 Safari[49476:1264368] [RemotePlistController] The downloaded plist could not be loaded: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."
2018-12-13 16:25:47.128105+0800 Safari[49476:1264277] Scheduling the NSURLConnection loader is no longer supported.
2018-12-13 16:25:47.491811+0800 Safari[49476:1264370] NSURLConnection finished with error - code -1100
2018-12-13 16:25:47.799590+0800 Safari[49476:1264514] [CloudBookmarks] Error fetching remote migration state: Error Domain=com.apple.SafariBookmarksSync.CloudBookmarksErrorDomain Code=0 "(null)"
2018-12-13 16:25:47.953259+0800 Safari[49476:1264277] [WebKit2Callbacks] Page (pid: 0) did become unresponsive
2018-12-13 16:25:47.970927+0800 Safari[49476:1264512] NSURLConnection finished with error - code -1100
2018-12-13 16:25:48.032647+0800 Safari[49476:1264425] [RemotePlistController] The downloaded plist could not be loaded: Error Domain=NSCocoaErrorDomain Code=260 "The file couldn’t be opened because it doesn’t exist."
2018-12-13 16:25:48.125530+0800 Safari[49476:1264426] Calling IOPPFGetProperty simulator_utility_clamp!
2018-12-13 16:25:48.840769+0800 Safari[49476:1264277] [WebKit2Callbacks] Page (pid: 49481) did become responsive

现在我的选择已经不多了。它在 Apple Developer 网站中缺少官方文档。

是否有解决此类问题的常规步骤?是否有任何类型的系统日志可以帮助我解决错误?任何建议表示赞赏。

4

3 回答 3

1

确保扩展.appex被列为您的应用扩展目标的嵌入内容。否则,当您从 Xcode 构建时,它不会被捆绑。查看 Target_Name > General > Frameworks, Libraries and Embedded Content 下的项目编辑器。扩展名应该列在那里。

还要在 Build Phases 选项卡 > Dependencies 下检查您的扩展是否也添加到了那里。

于 2019-10-22T18:52:44.757 回答
0

检查您的应用程序的代码签名是否有效。否则 Safari 将拒绝列出您的扩展程序。在您构建的应用程序上运行codesign如下:

codesign -d --verify --verbose=3 ~/Library/Developer/Xcode/DerivedData/OnePassword-epeydspviethpabprcrsqenrkiin/Build/Products/Debug_WebStore/1Password\ 7.app

它应该显示valid on disksatisfies its Designated Requirement。如果没有,Safari 将完全忽略您的扩展程序,即使Allow Unsigned Extensions已启用。

于 2019-06-17T01:28:38.567 回答
0

在更新到 Xcode 13.2.1 和我认为是 MacOS 更新后,我最近遇到了类似的问题。我正在开发的 Safari Web 扩展停止显示在 Safari 中(即使启用了未签名的扩展)。

在终端/CLI shell 中,我最终运行:

PATH=/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support:"$PATH"
lsregister -f /Applications/Safari.app

突然间,我的扩展又开始出现在 Safari 中。Safari 和 LaunchServices 发生了一些奇怪的事情。

于 2021-12-19T22:01:32.087 回答