Skip to content

Commit

Permalink
Fix issue where LottieLogger.shared.assertionFailure would unexpected…
Browse files Browse the repository at this point in the history
…ly crash in release builds (#1665)
  • Loading branch information
calda authored Jul 26, 2022
1 parent b898735 commit 9467b0d
Showing 1 changed file with 13 additions and 2 deletions.
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

0 comments on commit 9467b0d

Please sign in to comment.