-
Notifications
You must be signed in to change notification settings - Fork 61
Add NamedImage API support #806
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
3d08ab5
Add NamedImage support
Kyle-Ye fbfaf35
Add ArchivedView
Kyle-Ye 66db78e
Update NamedImage
Kyle-Ye 5b96e4c
Update Image+ImageResource
Kyle-Ye 183e483
Update ResolvedImage
Kyle-Ye 4f8933c
Update CUI type usage in NamedImage
Kyle-Ye f52d0c5
Update symbolSizeScale
Kyle-Ye 21f625e
Clean up NamedImage.Cache subscript structure
Kyle-Ye e507ab0
Add missing Image.Location members
Kyle-Ye f918c3f
Fix Image.Location implementation based on Hopper analysis
Kyle-Ye 71e0aeb
Refine SystemAssetManager for cross-platform availability
Kyle-Ye 0690f5d
Update NamedImageProvider
Kyle-Ye 9288674
Implement NamedImageProvider
Kyle-Ye c508aa7
Update Image.Location + PB support
Kyle-Ye 7ce3b46
Update Image.HashableScale
Kyle-Ye 09c4779
Add UUIDImageProvider
Kyle-Ye 0cd243a
Add NamedImage.Key + ProtobufMessage
Kyle-Ye 668f4b2
Update Package.resolved
Kyle-Ye 5447cf3
Add SFSymbolsShims
Kyle-Ye File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| // | ||
| // SFSymbolsShims.swift | ||
| // OpenSwiftUICore | ||
| // | ||
| // Status: WIP | ||
|
|
||
| // MARK: - SFSymbols Framework Access | ||
| // | ||
| // Currently uses dlopen/dlsym for dynamic symbol resolution at | ||
| // runtime. This avoids a hard link dependency on the private SFSymbols | ||
| // framework. | ||
| // | ||
| // TODO: Migrate to add SFSymbols in DarwinPrivateFrameworks package and link it with a new | ||
| // OPENSWIFTUI_LINK_SFSYMBOLS build flag (following the CoreUI pattern). | ||
| // When that migration happens: | ||
| // 1. Add `import SFSymbols` under `#if OPENSWIFTUI_LINK_SFSYMBOLS`. | ||
| // 2. Replace the dlopen-based implementations with direct calls. | ||
| // 3. Call sites using `SFSymbols.symbol_order` etc. remain unchanged | ||
| // because Swift resolves `SFSymbols.x` identically whether `SFSymbols` | ||
| // is a local enum or a qualified module name. | ||
|
|
||
| #if canImport(Darwin) | ||
| import Foundation | ||
|
|
||
| /// Shim for the private SFSymbols framework. | ||
| /// | ||
| /// Property names intentionally use snake_case to match the framework's | ||
| /// original API surface, ensuring a seamless migration to direct linking | ||
| /// (Option C) with no source-breaking changes at call sites. | ||
| package enum SFSymbols { | ||
| // MARK: - Module-level Properties | ||
|
|
||
| /// All system symbol names in their canonical order. | ||
| package static var symbol_order: [String] { | ||
| _lookup("$s9SFSymbols12symbol_orderSaySSGvg", as: Getter_ArrayString.self)?() ?? [] | ||
| } | ||
|
|
||
| /// Private system symbol names in their canonical order. | ||
| package static var private_symbol_order: [String] { | ||
| _lookup("$s9SFSymbols20private_symbol_orderSaySSGvg", as: Getter_ArrayString.self)?() ?? [] | ||
| } | ||
|
|
||
| /// Mapping of alias names to their canonical symbol names. | ||
| package static var name_aliases: [String: String] { | ||
| _lookup("$s9SFSymbols12name_aliasesSDyS2SGvg", as: Getter_DictStringString.self)?() ?? [:] | ||
| } | ||
|
|
||
| /// Mapping of private alias names to their canonical symbol names. | ||
| package static var private_name_aliases: [String: String] { | ||
| _lookup("$s9SFSymbols20private_name_aliasesSDyS2SGvg", as: Getter_DictStringString.self)?() ?? [:] | ||
| } | ||
|
|
||
| /// Mapping from nofill symbol names to their fill variants. | ||
| package static var nofill_to_fill: [String: String] { | ||
| _lookup("$s9SFSymbols14nofill_to_fillSDyS2SGvg", as: Getter_DictStringString.self)?() ?? [:] | ||
| } | ||
|
|
||
| /// Mapping from private nofill symbol names to their fill variants. | ||
| package static var private_nofill_to_fill: [String: String] { | ||
| _lookup("$s9SFSymbols22private_nofill_to_fillSDyS2SGvg", as: Getter_DictStringString.self)?() ?? [:] | ||
| } | ||
|
|
||
| // MARK: - Private | ||
|
|
||
| private typealias Getter_ArrayString = @convention(thin) () -> [String] | ||
| private typealias Getter_DictStringString = @convention(thin) () -> [String: String] | ||
|
|
||
| private static let handle: UnsafeMutableRawPointer? = { | ||
| dlopen("/System/Library/PrivateFrameworks/SFSymbols.framework/SFSymbols", RTLD_LAZY) | ||
| }() | ||
|
|
||
| private static func _lookup<T>(_ name: String, as type: T.Type) -> T? { | ||
| guard let handle, let sym = dlsym(handle, name) else { return nil } | ||
| return unsafeBitCast(sym, to: type) | ||
| } | ||
| } | ||
| #endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // | ||
| // ArchivedView.swift | ||
| // OpenSwiftUICore | ||
| // | ||
| // Audited for 6.5.4 | ||
| // Status: Complete | ||
|
|
||
| public import Foundation | ||
|
|
||
| // MARK: - ArchivedViewDelegate | ||
|
|
||
| @_spi(Private) | ||
| @available(OpenSwiftUI_v4_0, *) | ||
| public protocol ArchivedViewDelegate { | ||
| mutating func resolveImage(uuid: UUID) throws -> Image.ResolvedUUID | ||
| } | ||
|
|
||
| // MARK: - AnyArchivedViewDelegate | ||
|
|
||
| @_spi(ForOpenSwiftUIOnly) | ||
| @available(OpenSwiftUI_v6_0, *) | ||
| open class AnyArchivedViewDelegate { | ||
| package init() { | ||
| _openSwiftUIEmptyStub() | ||
| } | ||
|
|
||
| @_spi(ForSwiftUIOnly) | ||
| open func resolveImage(uuid: UUID) throws -> Image.ResolvedUUID { | ||
| _openSwiftUIBaseClassAbstractMethod() | ||
| } | ||
| } | ||
|
|
||
| @_spi(ForOpenSwiftUIOnly) | ||
| @available(*, unavailable) | ||
| extension AnyArchivedViewDelegate: @unchecked Sendable {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change force-unwraps
CUIDeviceIdiom(rawValue: environment.cuiAssetIdiom)!; ifcuiAssetIdiomever contains an unexpected value, this will crash (previously it safely fell back to.universal).Severity: medium
🤖 Was this useful? React with 👍 or 👎, or 🚀 if it prevented an incident/outage.