Open SwiftfulThinking opened 2 months ago
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
Thanks for filing, @SwiftfulThinking. We were able to reproduce this behavior. Xcode 16 introduced a new "preview engine" (release notes) so it seems likely that there is a regressions of some sort. I have filed a feedback ticket with Apple, FB15114904
. Feel free to reference it if you happen to file one yourself.
Unfortunately, I do not have a workaround to share. I tried experimenting with detecting when Xcode was building for previews, in an effort to disable to problematic code, but was unable to come up with something that worked.
+1 for this issue. I have found running preview with iOS 17 device still works, even with new preview engine
@ncooke3 not sure if this is helpful, but supposedly
if ProcessInfo.processInfo.environment["XCODE_RUNNING_FOR_PREVIEWS"] == "1"
{
// Disable offending code
}
is a viable approach. Im also affected by a maybe similar issue on macOS 15.1 / Xcode 16.1 beta when previewing SwiftUI with Firebase and was able to work with the same project on macOS 14 / and earlier Xcodes.
I am on Swift 5 though
+1
+1
Workaround:
Editor -> Canvas -> Enable Legacy Previews Execution.
Found here: https://forums.developer.apple.com/forums/thread/756681
Workaround:
Editor -> Canvas -> Enable Legacy Previews Execution.
Found here: https://forums.developer.apple.com/forums/thread/756681
It is helped me
Enabling Legacy Preview engine is not an ideal fix though, as we would like to take advantage of the new preview engine for an improved development flow. Is there any further info on a potential real fix for this issue?
+1
Workaround:
Editor -> Canvas -> Enable Legacy Previews Execution.
Found here: https://forums.developer.apple.com/forums/thread/756681
It appears to have been removed in the latest iOS beta. 😱 (Xcode 16.1 Beta 2)
OMG. The whole day I spent on this 😢
"Enable Legacy Previews Execution" doesn't work. This is the only way I've gotten around this error.
//
// AnalyticsManager.swift
//
import FirebaseAnalytics
class AnalyticsManager {
static func logEvent(_ event: String, parameters: [String: Any]?) {
#if !targetEnvironment(simulator)
Analytics.logEvent(event, parameters: parameters)
#endif
}
}
The error persists in all three of the different analytics frameworks.
Big kudos to the reporter for finding the exact cause! I was giving up...
Same issue -- just commenting for bumping's sake
+1
Description
The code
Analytics.logEvent()
causes a compile-time crash for all SwiftUI previews in a project, resulting in:This occurs as long as the code is anywhere in the codebase, regardless of whether it is executed in the current Preview. Therefore, it breaks all SwiftUI previews in a project and has no indicator to the source of the crash.
Reproducing the issue
trackEvent
is never even called.FirebaseAnalyticsService
to astruct
orclass
makes the problem only semi-reproducible (if you restart and reset the canvas cache, only sometimes it will crash).Firebase SDK Version
11.1.0
Xcode Version
16.6 beta
Installation Method
Swift Package Manager
Firebase Product(s)
Analytics
Targeted Platforms
iOS
Relevant Log Output
If using Swift Package Manager, the project's Package.resolved
Expand
Package.resolved
snippet```json Replace this line with the contents of your Package.resolved. ```
If using CocoaPods, the project's Podfile.lock
Expand
Podfile.lock
snippet```yml Replace this line with the contents of your Podfile.lock! ```