依赖于第三方xcframeworks的CANT COMPILE XCFRAMEWORKS

发布于 2025-02-02 22:09:36 字数 1668 浏览 4 评论 0原文

我目前正在尝试编译Swift软件包(我已将其包裹在Xcodeproj中,专门为能够以二进制Swift软件包发布软件包,并且仍在示例应用程序中运行本地代码)中的我也可以将其释放为可可录。该项目构建良好,并在同一存储库中的示例应用程序中运行,因此我对代码本身非常有信心。但是,我在存档时遇到问题。来自依赖项的类别未找到Swift软件包。两个dep(只有2个)都是第三方二进制Swift软件包。

▸ Compiling MySegmentLabel.swift

❌  /Users/***/Sources/Views/MySegmentLabel.swift:4:39: cannot find type 'SegmentedControlSegment' in scope

public final class MySegmentLabel: SegmentedControlSegment {
                                    ^~~~~~~~~~~~~~~~~~~~~~~

** ARCHIVE FAILED **

在上面的示例输出中,分割controlsegement是第三方二进制XCFramework依赖项之一的类。

我感觉到这是我的存档命令或Xcodeproj构建设置的问题,但是我只是不知道我需要调整哪些或以何种方式进行调整。

在我的XcodeProj构建设置中,我已经设置了skip_install = nobuild_library_for_distribution = yes正如Apple建议(明确将它们添加到Archive命令中,也无用)。这是我用来存档我的xcodeproj的命令:

# Archives the target scheme passed-in to the script
function archive () {
    local sdk=$1
    local configuration=$2
    local build_path="$build_root/$sdk"
    local xcarchive_path="$archive_root/$SCHEME-$sdk.xcarchive"

    xcodebuild \
        -workspace $xcworkspace \
        -scheme "$SCHEME" \
        -configuration $configuration \
        -archivePath $xcarchive_path \
        -derivedDataPath $build_path \
        -sdk $sdk \
        -scmProvider system \
        -showBuildTimingSummary \
        archive | xcpretty

}

archive "iphonesimulator" "Debug" # specifically this one fails. It is able to archive for non-simulators
archive "iphoneos" "Release"

因为它仅用于iphonesimulator target的编译,所以我几乎认为第三方库可能没有将x86_64框架捆绑到其xcframeworks(除了xcframeworks)这不可能是因为当我运行XcodeProj时,示例应用程序在模拟器上运行良好)。

I'm currently trying to compile a swift package (which I have wrapped in an xcodeproj specifically for the purpose of being able to release the package as a binary swift package and still run the local code in an example app) into a xcframework so that I can release it as a Cocoapod as well. The project builds fine and runs in the example app in the same repository, so I'm fairly confident in the code itself. However, I'm running into problems while archiving; the classes that come from the dependencies the swift package has can't be found. Both deps (there are only 2) are 3rd party binary swift packages.

▸ Compiling MySegmentLabel.swift

❌  /Users/***/Sources/Views/MySegmentLabel.swift:4:39: cannot find type 'SegmentedControlSegment' in scope

public final class MySegmentLabel: SegmentedControlSegment {
                                    ^~~~~~~~~~~~~~~~~~~~~~~

** ARCHIVE FAILED **

In the above sample output, SegmentedControlSegment is a class from one of the 3rd party binary xcframework dependencies.

I get the feeling that this is a problem with either my archiving command or my xcodeproj build settings, but I just can't figure out which ones I need to tweak or in what way.

In my xcodeproj build settings I have set SKIP_INSTALL=NO and BUILD_LIBRARY_FOR_DISTRIBUTION=YES as Apple recommends (explicitly adding them to the archive command doesnt help either). And this is the command I'm using to archive my xcodeproj:

# Archives the target scheme passed-in to the script
function archive () {
    local sdk=$1
    local configuration=$2
    local build_path="$build_root/$sdk"
    local xcarchive_path="$archive_root/$SCHEME-$sdk.xcarchive"

    xcodebuild \
        -workspace $xcworkspace \
        -scheme "$SCHEME" \
        -configuration $configuration \
        -archivePath $xcarchive_path \
        -derivedDataPath $build_path \
        -sdk $sdk \
        -scmProvider system \
        -showBuildTimingSummary \
        archive | xcpretty

}

archive "iphonesimulator" "Debug" # specifically this one fails. It is able to archive for non-simulators
archive "iphoneos" "Release"

Since it only doesnt compile for the iphonesimulator target, I almost think that the 3rd party libraries maybe didnt bundle the x86_64 frameworks into their xcframeworks (except that can't be because the example app runs fine on simulator when I run the xcodeproj).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一片旧的回忆 2025-02-09 22:09:36

Swift软件包管理器不允许及时依赖性。客户端应用程序要么需要直接依赖第三方SWIFT软件包,要么您的软件包需要重新表达需要传递的API。

Swift Package Manager does not allow transitive dependencies. Client apps either need to directly depend on the third party Swift packages or your package needs to re-expose the APIs that need to passed through.

稚气少女 2025-02-09 22:09:36

在我的情况下(这可能是罕见的),问题是,第三方Xcframework Deps都在设置中汇编,以将iPhonesimulators的ARM64拱门排除在外。因此,当我试图为iPhonesimulator SDK存档所有标准拱门(包括M1的ARM64)时,当它用于归档ARM64时,它将找不到第三方DEP的类参考。

理想情况下,第三方DEPS可以修复他们的黑客攻击,以将ARM64排除在模拟器中,但我不控制这些SDK,所以我只需要将这些依赖性踢到链条上,因此最终客户端(这是一个我不需要归档的应用程序)现在必须依靠那些第三方的液井,我需要重构我的Swift软件包,以不需要直接访问那些第三方的DEP。

In my case (which is probably a rare one) the issue turned out to be that the 3rd party xcframework deps had both been compiled with the setting to exclude the arm64 arch for iphonesimulators. So, when I was trying to archive my SDK for the iphonesimulator sdk for all standard archs (which includes arm64 now due to M1), it would fail to find the class references from the 3rd party deps when it got to archiving for arm64.

Ideally the 3rd party deps would fix their hack to exclude arm64 for simulators, but I dont control those SDKs, so I just had to kick those dependencies down the chain, so the end client (which is an app I'll never need to archive) now has to depend on those 3rd party libs and my swift package needs to be refactored to not need direct access to those 3rd party deps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文