Xcode iOS 捆绑包包含不允许的文件 'Frameworks'

Xcode iOS bundle contains disallowed file 'Frameworks'

我正在尝试发布 iOS swift 应用程序。我使用 Xcode 9.4.1。该应用程序包含一个共享扩展,可以通过 HTTP 上传文件。共享扩展使用 SwiftHTTP。应用验证失败并出现以下错误:

Invalid Bundle. The bundle at 'FooBar.app/PlugIns/FileUploadextension.appex' contains disallowed nested bundles.
An unknown error occurred.

Invalid Bundle. The bundle at 'FooBar.app/PlugIns/FileUploadextension.appex' contains disallowed file 'Frameworks'.
An unknown error occurred.

我在 StackOverfllow 上查看了有关错误消息的其他答案。

我禁用了 swift 扩展库的嵌入:

已为主应用启用嵌入:

扩展有一个框架复制步骤:

我尝试将 this script 添加到扩展构建阶段:

cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
if [[ -d "Frameworks" ]]; then
rm -fr Frameworks
fi

有了这个脚本,应用程序通过了验证,但扩展程序不起作用。它失败了:

Hub connection error Error Domain=NSCocoaErrorDomain
Code=4097 "connection to service named
xxx.FooBar.FileUploadextension"
UserInfo={NSDebugDescription=connection to service named

当我在 Finder 中打开我的 FileUploadextension.appex 时,我有一个 Frameworks 目录,里面有 SwiftHTTP.framework。 我该如何解决这个问题以通过验证并使扩展正常工作?

所以我的问题是应用程序扩展(共享扩展)需要一个库。 您的扩展程序不能嵌入库,因此您必须将库嵌入主应用程序,然后 link 从扩展程序中嵌入它。

如果您使用的是 Carthage,那么我假设您已将 Carthage 复制脚本添加为 运行 脚本。

您只能将此用于主应用程序,而不是扩展程序。扩展使用的任何库都必须列在输入文件中。

然后在您的扩展中,只需将框架添加为 linked 二进制文件

也从您的扩展程序中删除复制框架步骤。