From 4a34c7e6e6c526a18b26ea3c05601592a2a58d96 Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 2 Oct 2025 10:45:17 +0800 Subject: [PATCH 1/3] Fix release log crash issue See https://forums.swift.org/t/os-log-crash-when-forwarding-cvararg-vs-variadic-cvararg/82468/5 --- Sources/OpenSwiftUICore/Log/Logging.swift | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/Sources/OpenSwiftUICore/Log/Logging.swift b/Sources/OpenSwiftUICore/Log/Logging.swift index 2925509f5..e8031bb62 100644 --- a/Sources/OpenSwiftUICore/Log/Logging.swift +++ b/Sources/OpenSwiftUICore/Log/Logging.swift @@ -1,15 +1,12 @@ // // Logging.swift -// OpenSwiftUI +// OpenSwiftUICore // // Audited for 6.0.87 // Status: Complete -#if DEBUG import Foundation -#else -public import Foundation -#endif +import Testing #if OPENSWIFTUI_SWIFT_LOG public import Logging @@ -162,14 +159,10 @@ package enum Log { _ message: @autoclosure () -> StaticString, _ args: @autoclosure () -> [CVarArg] = [] ) { - #if DEBUG unsafeBitCast( os_log as (OSLogType, UnsafeRawPointer, OSLog, StaticString, CVarArg...) -> Void, to: ((OSLogType, UnsafeRawPointer, OSLog, StaticString, [CVarArg]) -> Void).self )(.fault, dso, runtimeIssuesLog, message(), args()) - #else - os_log(.fault, log: runtimeIssuesLog, message(), args()) - #endif } #endif From ceec5f327e42db7a72200e34ff28e4abbbdde2cb Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 2 Oct 2025 14:20:17 +0800 Subject: [PATCH 2/3] Update Logging.swift --- Sources/OpenSwiftUICore/Log/Logging.swift | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Sources/OpenSwiftUICore/Log/Logging.swift b/Sources/OpenSwiftUICore/Log/Logging.swift index e8031bb62..d324c476b 100644 --- a/Sources/OpenSwiftUICore/Log/Logging.swift +++ b/Sources/OpenSwiftUICore/Log/Logging.swift @@ -6,7 +6,7 @@ // Status: Complete import Foundation -import Testing +public import Testing #if OPENSWIFTUI_SWIFT_LOG public import Logging @@ -159,10 +159,26 @@ package enum Log { _ message: @autoclosure () -> StaticString, _ args: @autoclosure () -> [CVarArg] = [] ) { + if Test.current != nil { + let comment: Comment = #"[Runtime Issue]: message - "\#(message().description)" args: \#(args())"# + #if swift(>=6.3) + Issue.record(comment, severity: .warning) + #else + // TODO: Wait for Swift 6.2 Issue handler + // Issue.record(comment) + #endif + } + #if DEBUG unsafeBitCast( os_log as (OSLogType, UnsafeRawPointer, OSLog, StaticString, CVarArg...) -> Void, to: ((OSLogType, UnsafeRawPointer, OSLog, StaticString, [CVarArg]) -> Void).self )(.fault, dso, runtimeIssuesLog, message(), args()) + #else + unsafeBitCast( + os_log as (OSLogType, UnsafeRawPointer, OSLog, StaticString, CVarArg...) -> Void, + to: ((OSLogType, UnsafeRawPointer, OSLog, StaticString, [CVarArg]) -> Void).self + )(.fault, #dsohandle, runtimeIssuesLog, message(), args()) + #endif } #endif From e2539557ae4161464737cf0b52845071f17eb1a8 Mon Sep 17 00:00:00 2001 From: Kyle Date: Thu, 2 Oct 2025 15:24:46 +0800 Subject: [PATCH 3/3] Fix UI test target link issue --- Example/Example.xcodeproj/project.pbxproj | 25 ++++++++--------------- Sources/OpenSwiftUICore/Log/Logging.swift | 5 +++++ 2 files changed, 13 insertions(+), 17 deletions(-) diff --git a/Example/Example.xcodeproj/project.pbxproj b/Example/Example.xcodeproj/project.pbxproj index 7a06c926a..6cece0c67 100644 --- a/Example/Example.xcodeproj/project.pbxproj +++ b/Example/Example.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 27186AE32D538A76009E05F9 /* AttributeGraph.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27E6C4D12D2842740010502F /* AttributeGraph.xcframework */; }; 278EF52D2E2272F2009C32EB /* Equatable in Frameworks */ = {isa = PBXBuildFile; productRef = 278EF52C2E2272F2009C32EB /* Equatable */; }; 278EF52F2E227304009C32EB /* Equatable in Frameworks */ = {isa = PBXBuildFile; productRef = 278EF52E2E227304009C32EB /* Equatable */; }; + 279080A52E8E601B0082B5B6 /* Testing.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 279080912E8E5E7B0082B5B6 /* Testing.framework */; }; 279284972DFF136E00234D64 /* AttributeGraph.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27E6C4D12D2842740010502F /* AttributeGraph.xcframework */; }; 2792849F2DFF137400234D64 /* SnapshotTesting in Frameworks */ = {isa = PBXBuildFile; productRef = 2792849E2DFF137400234D64 /* SnapshotTesting */; }; 279FED052DF4566D00320390 /* AttributeGraph.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 27E6C4D12D2842740010502F /* AttributeGraph.xcframework */; }; @@ -32,14 +33,7 @@ /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - 279283BD2DFF11CE00234D64 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 27CD0B412AFC8D37003665EB /* Project object */; - proxyType = 1; - remoteGlobalIDString = 27CD0B482AFC8D37003665EB; - remoteInfo = Example; - }; - 279283E32DFF11F900234D64 /* PBXContainerItemProxy */ = { + 279080A32E8E600A0082B5B6 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 27CD0B412AFC8D37003665EB /* Project object */; proxyType = 1; @@ -51,6 +45,7 @@ /* Begin PBXFileReference section */ 271D81642BB1E8E300A6D543 /* OpenAttributeGraph */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = OpenAttributeGraph; path = ../../OpenAttributeGraph; sourceTree = ""; }; 275751E32DEE1441003E467C /* TestingHost.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TestingHost.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 279080912E8E5E7B0082B5B6 /* Testing.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Testing.framework; path = Platforms/MacOSX.platform/Developer/Library/Frameworks/Testing.framework; sourceTree = DEVELOPER_DIR; }; 279283B92DFF11CE00234D64 /* OpenSwiftUIUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenSwiftUIUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 27AF22B12E758F0F00D534AB /* BacklightServices.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = BacklightServices.xcframework; path = ../../DarwinPrivateFrameworks/BLS/2024/BacklightServices.xcframework; sourceTree = ""; }; 27B7FC802BB31FF500272BA5 /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; @@ -103,6 +98,7 @@ buildActionMask = 2147483647; files = ( 279FED0D2DF4567B00320390 /* OpenSwiftUI in Frameworks */, + 279080A52E8E601B0082B5B6 /* Testing.framework in Frameworks */, 27AF22B82E758F2E00D534AB /* BacklightServices.xcframework in Frameworks */, 27AF22B42E758F2900D534AB /* CoreUI.xcframework in Frameworks */, 27AF22BC2E758F3700D534AB /* RenderBox.xcframework in Frameworks */, @@ -185,6 +181,7 @@ 27D49E0C2BA60AF600F6E2E2 /* Frameworks */ = { isa = PBXGroup; children = ( + 279080912E8E5E7B0082B5B6 /* Testing.framework */, 27AF22B12E758F0F00D534AB /* BacklightServices.xcframework */, 27EE91722DD0C753006C85FD /* CoreUI.xcframework */, 27E6C4D42D2842810010502F /* RenderBox.xcframework */, @@ -230,8 +227,7 @@ buildRules = ( ); dependencies = ( - 279283BE2DFF11CE00234D64 /* PBXTargetDependency */, - 279283E42DFF11F900234D64 /* PBXTargetDependency */, + 279080A42E8E600A0082B5B6 /* PBXTargetDependency */, ); fileSystemSynchronizedGroups = ( 275751F62DEE1456003E467C /* OpenSwiftUIUITests */, @@ -407,15 +403,10 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - 279283BE2DFF11CE00234D64 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 27CD0B482AFC8D37003665EB /* Example */; - targetProxy = 279283BD2DFF11CE00234D64 /* PBXContainerItemProxy */; - }; - 279283E42DFF11F900234D64 /* PBXTargetDependency */ = { + 279080A42E8E600A0082B5B6 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 275751E22DEE1441003E467C /* TestingHost */; - targetProxy = 279283E32DFF11F900234D64 /* PBXContainerItemProxy */; + targetProxy = 279080A32E8E600A0082B5B6 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ diff --git a/Sources/OpenSwiftUICore/Log/Logging.swift b/Sources/OpenSwiftUICore/Log/Logging.swift index d324c476b..2a2418a34 100644 --- a/Sources/OpenSwiftUICore/Log/Logging.swift +++ b/Sources/OpenSwiftUICore/Log/Logging.swift @@ -6,7 +6,9 @@ // Status: Complete import Foundation +#if canImport(Testing) public import Testing +#endif #if OPENSWIFTUI_SWIFT_LOG public import Logging @@ -159,6 +161,7 @@ package enum Log { _ message: @autoclosure () -> StaticString, _ args: @autoclosure () -> [CVarArg] = [] ) { + #if canImport(Testing) if Test.current != nil { let comment: Comment = #"[Runtime Issue]: message - "\#(message().description)" args: \#(args())"# #if swift(>=6.3) @@ -168,6 +171,8 @@ package enum Log { // Issue.record(comment) #endif } + #endif + #if DEBUG unsafeBitCast( os_log as (OSLogType, UnsafeRawPointer, OSLog, StaticString, CVarArg...) -> Void,