You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On recent SDK of Darwin platform, Apple has moved the definition of many CG symbols(CGFloatCGSizeCGRect) from CoreGraphic to CoreFoundation.
So when we use import CoreFoundation, we can use CGFloat on Darwin now. But it will require use to import the whole Foundation module on non-Darwin platform.
Also, to avoid source breaking change, we may apply some trick which Apple use on Darwin platform to avoid import struct CoreGraphics.CGFloat failing to build issue.
// Currently valid on Darwin platform with macOS 14/iOS 17 SDK
import struct CoreGraphics.CGFloat
import struct CoreFoundation.CGFloat
And besides it I also facing some issue on my other project:
eg.
I used to use the following code before assuming CGXX is defined in CoreGraphics
#if canImport(Darwin)
import CoreGraphics
#else
import Foundation // swift-corelibs-foundation#endif
Then after the transition of CGXX from CoreGraphics to CoreFoundation
I changed to use the following code
import Foundation
And assume I have a CKit which reexported CoreFoundation.
The following code compiles on Darwin platform but not on Linux nor WASM.
import CKit // or import CoreFoundationleta:CGFloat= 0.0 // error: cannot find type 'CGFloat' in scope
Considering we will migrate to use swift-foundation later, I'm always try to avoid the direct dependency of Foundation here.
Would it be great if we can align the behavior on all platforms?
The text was updated successfully, but these errors were encountered:
Kyle-Ye
changed the title
Move CGFloat/CGSize/CGRect to CoreFoundation to match Darwin behavior
Move CG symbols to CoreFoundation to match Darwin behavior
Mar 10, 2024
Issue
On recent SDK of Darwin platform, Apple has moved the definition of many CG symbols(
CGFloat
CGSize
CGRect
) fromCoreGraphic
toCoreFoundation
.So when we use
import CoreFoundation
, we can useCGFloat
on Darwin now. But it will require use to import the wholeFoundation
module on non-Darwin platform.Also, to avoid source breaking change, we may apply some trick which Apple use on Darwin platform to avoid
import struct CoreGraphics.CGFloat
failing to build issue.Background/Context
I have found it first in this discussion https://forums.swift.org/t/need-compiler-expert-is-there-a-way-to-workaround-symbol-not-found-crash-on-ios-15-sim-for-apis-available-since-ios-13/69527/17
And besides it I also facing some issue on my other project:
eg.
I used to use the following code before assuming
CGXX
is defined inCoreGraphics
Then after the transition of
CGXX
fromCoreGraphics
toCoreFoundation
I changed to use the following code
And assume I have a
CKit
which reexportedCoreFoundation
.The following code compiles on Darwin platform but not on Linux nor WASM.
Considering we will migrate to use
swift-foundation
later, I'm always try to avoid the direct dependency ofFoundation
here.Would it be great if we can align the behavior on all platforms?
Other
https://forums.swift.org/t/move-cg-symbols-to-corefoundation-to-match-darwin-behavior/70554
The text was updated successfully, but these errors were encountered: