Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue where LottieLogger.shared.assertionFailure would unexpectedly crash in release builds #1665

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions Sources/Public/Logging/LottieLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,19 @@ public final class LottieLogger {
// MARK: Lifecycle

public init(
assert: @escaping Assert = Swift.assert,
assertionFailure: @escaping AssertionFailure = Swift.assertionFailure,
assert: @escaping Assert = { condition, message, file, line in
// If we default to `Swift.assert` directly with `assert: Assert = Swift.assert`,
// the call will unexpectedly not respect the -O flag and will crash in release
// https://github.com/apple/swift/issues/60249
Swift.assert(condition(), message(), file: file, line: line)
},
assertionFailure: @escaping AssertionFailure = { message, file, line in
// If we default to `Swift.assertionFailure` directly with
// `assertionFailure: AssertionFailure = Swift.assertionFailure`,
// the call will unexpectedly not respect the -O flag and will crash in release
// https://github.com/apple/swift/issues/60249
Swift.assertionFailure(message(), file: file, line: line)
},
warn: @escaping Warn = { message, _, _ in
#if DEBUG
// swiftlint:disable:next no_direct_standard_out_logs
Expand Down