[英]SwiftUI previews not working when using Firebase/Analytics pod
Seems that after updating Xcode 12 to beta 5, SwiftUI previews are not working anymore when using Firebase/Analytics pod.似乎在将 Xcode 12 更新到 beta 5 后,SwiftUI 预览在使用 Firebase/Analytics pod 时不再起作用。 Previews are failing with error:预览失败并出现错误:
linker command failed with exit code 1 (use -v to see invocation)
----------------------------------------
SchemeBuildError: Failed to build the scheme "Boo"
linker command failed with exit code 1 (use -v to see invocation)
Link Boo (arm64):
ld: in /Users/../Boo/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRAnalyticsConnector_e321ed8e3db06efc9803f6c008e67a34.o), building for iOS Simulator, but linking in object file built for iOS, file '/Users/.../Boo/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any suggestions how to fix this?任何建议如何解决这个问题?
To exclude the arm64 architecture only when running on a simulator, add the "Any iOS Simulator SDK" qualifier in the build settings.要仅在模拟器上运行时排除 arm64 架构,请在构建设置中添加“Any iOS Simulator SDK”限定符。 Then you won't have to remove this setting when testing on a physical device.然后,在物理设备上进行测试时,您不必删除此设置。
To add the qualifier, click on the little plus button, as shown.要添加限定符,请单击小加号按钮,如图所示。
The following workaround (credit to user on Apple Developer forums) worked for me:以下解决方法(感谢 Apple Developer 论坛上的用户)对我有用:
Add "arm64" to the excluded architectures for the debug scheme for any targets that have Firebase Analytics.对于具有 Firebase Analytics 的任何目标,将“arm64”添加到调试方案的排除架构中。
This will cause you problems if you need to debug to an actual iOS device, obviously.如果您需要调试到实际的 iOS 设备,这显然会给您带来问题。 But you can remove it when you need to test on a device.但是当您需要在设备上进行测试时,您可以将其移除。
The accepted answer also worked for me.接受的答案也对我有用。 But I didn't know how to do this as I have never done it before so I wanted to show you the steps I took to accomplish this.但我不知道如何做到这一点,因为我以前从未这样做过,所以我想向你展示我为实现这一目标所采取的步骤。
Xcode 12, beta 6 Xcode 12,测试版 6
The Valid Architectures build setting has been removed in Xcode 12. If you had values in this build setting, they're causing a problem and need to be removed. Xcode 12 中删除了有效架构构建设置。如果您在此构建设置中有值,则它们会导致问题,需要将其删除。
I was able to "clear out" the VALID_ARCHS build setting by adding it back in as a User-Defined build setting (with no values), running the project (which failed), and then deleting the VALID_ARCHS build setting.我能够通过将 VALID_ARCHS 构建设置重新添加为用户定义的构建设置(没有值),运行项目(失败),然后删除 VALID_ARCHS 构建设置来“清除”它。
My Architectures build setting is Standard Architectures.我的架构构建设置是标准架构。
Add this check at start of didFinishLaunchingWithOptions
and preview mod will ignoring external modules在didFinishLaunchingWithOptions
开始时添加此检查,并且预览模式将忽略外部模块
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1" {
return true
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.