由于集成测试包,无法在 Bash 上使用 Flutter 构建 IPA 文件

问题描述 投票:0回答:1

我正在尝试通过 Bash 使用 Flutter 构建 IPA 文件。但它返回错误

building for 'iOS', but linking in dylib (/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libobjc.A.tbd) built for 'macOS macCatalyst zippered(macOS/Catalyst)'

所以我尝试使用

--verbose
打印调试日志 Ans 这是结果。

Ld /Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/integration_test.framework/integration_test normal (in target 'integration_test' from project 'Pods')
                cd /Users/tcbdevbuild/Documents/trade-in-mobile-app/ios/Pods
                /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -Xlinker -reproducible -target arm64-apple-ios15.5 -dynamiclib -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS17.0.sdk -Os -L/Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/EagerLinkingTBDs/Release-iphoneos -L/Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/integration_test -F/Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/EagerLinkingTBDs/Release-iphoneos -F/Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/BuildProductsPath/Release-iphoneos/integration_test -F/Users/tcbdevbuild/Documents/flutter/bin/cache/artifacts/engine/ios-release/Flutter.xcframework/ios-arm64 -filelist /Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/integration_test.build/Objects-normal/arm64/integration_test.LinkFileList -install_name @rpath/integration_test.framework/integration_test -Xlinker -rpath -Xlinker @executable_path/Frameworks -Xlinker -rpath -Xlinker @loader_path/Frameworks -dead_strip -Xlinker -object_path_lto -Xlinker /Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/integration_test.build/Objects-normal/arm64/integration_test_lto.o -fobjc-arc -fobjc-link-runtime -framework UIKit -framework Flutter -framework Foundation -framework UIKit -compatibility_version 1 -current_version 1 -Xlinker -dependency_info -Xlinker /Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Pods.build/Release-iphoneos/integration_test.build/Objects-normal/arm64/integration_test_dependency_info.dat -o /Users/tcbdevbuild/Library/Developer/Xcode/DerivedData/Techswop-hcgdxzbupbdesybvyqnrorjdyarb/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/integration_test.framework/integration_test
            ld: building for 'iOS', but linking in dylib (/Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib/libobjc.A.tbd) built for 'macOS macCatalyst zippered(macOS/Catalyst)'
            clang: error: linker command failed with exit code 1 (use -v to see invocation)

这个问题在 zsh 中不会发生,并且我确实确保 zsh 和 Bash 使用相同的 env PATH。 Gitlab-Runner 仅使用 Bash,所以我需要修复才能运行 CI/CD 管道。有谁知道怎么解决吗?

ios flutter xcode macos
1个回答
0
投票

我解决了!这实际上很有趣,因为这确实是与 Bash 相关的问题。具有讽刺意味的是,主持人没有提供帮助,而是决定他/她应该否决我的问题,编辑掉 Bash 标签,而不是真正尝试提供帮助。如果我在问 ChatGPT 时敲头的话,我的发现速度会提前大约 3 个小时。讽刺的是,在这种情况下这也更有帮助。

我将 zsh 和 bash

env > bash/zsh_path.txt
中的环境路径放入 ChatGPT 中,并询问其差异在哪里。事实证明,由于某种原因,Bash env 路径有
SDKROOT
LIBRARY_PATH
默认为 Bash 中的 MacOSX 库。这两个路径在 zsh 中都不存在。所以我设法解决这个问题的方法是进入 .bashrc
nano ~/.bashrc
并在顶部添加这两行。

unset SDKROOT
unset LIBRARY_PATH

我不知道这是否是Xcode在做什么,或者到底是什么,如果有人知道更多,我非常欢迎进一步解释!

© www.soinside.com 2019 - 2024. All rights reserved.