Merge pull request #267 from SDWebImage/feature/visionOS

(Part 1) Support compile for visionOS (no package manager support)
This commit is contained in:
DreamPiggy 2023-09-02 22:53:17 +08:00 committed by GitHub
commit 67f6e20972
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
29 changed files with 910 additions and 526 deletions

View File

@ -14,9 +14,9 @@ permissions:
jobs:
Pods:
name: Cocoapods Lint
runs-on: macos-11
runs-on: macos-12
env:
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
DEVELOPER_DIR: /Applications/Xcode_14.1.app
steps:
- name: Checkout
uses: actions/checkout@v2
@ -34,9 +34,9 @@ jobs:
Demo:
name: Run Demo
runs-on: macos-11
runs-on: macos-12
env:
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
DEVELOPER_DIR: /Applications/Xcode_14.1.app
WORKSPACE_NAME: SDWebImageSwiftUI.xcworkspace
OSXSCHEME: SDWebImageSwiftUIDemo-macOS
iOSSCHEME: SDWebImageSwiftUIDemo
@ -45,7 +45,7 @@ jobs:
strategy:
matrix:
iosDestination: ["name=iPhone 13 Pro"]
tvOSDestination: ["name=Apple TV 4K"]
tvOSDestination: ["name=Apple TV"]
watchOSDestination: ["platform=watchOS Simulator,name=Apple Watch Series 7 - 45mm"]
macOSDestination: ["platform=macOS"]
macCatalystDestination: ["platform=macOS,arch=x86_64,variant=Mac Catalyst"]
@ -92,9 +92,9 @@ jobs:
Test:
name: Unit Test
runs-on: macos-11
runs-on: macos-12
env:
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
DEVELOPER_DIR: /Applications/Xcode_14.1.app
WORKSPACE_NAME: SDWebImageSwiftUI.xcworkspace
OSXSCHEME: SDWebImageSwiftUITests macOS
iOSSCHEME: SDWebImageSwiftUITests
@ -154,9 +154,9 @@ jobs:
Build:
name: Build Library
runs-on: macos-11
runs-on: macos-12
env:
DEVELOPER_DIR: /Applications/Xcode_13.2.1.app
DEVELOPER_DIR: /Applications/Xcode_14.1.app
PROJECT_NAME: SDWebImageSwiftUI.xcodeproj
OSXSCHEME: SDWebImageSwiftUI macOS
iOSSCHEME: SDWebImageSwiftUI

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:SDWebImageSwiftUI.xcodeproj">
location = "self:">
</FileRef>
</Workspace>

View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "32D5D15F2A445B250098BDFC"
BuildableName = "SDWebImageSwiftUIDemo-visionOS.app"
BlueprintName = "SDWebImageSwiftUIDemo-visionOS"
ReferencedContainer = "container:SDWebImageSwiftUI.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "32D5D15F2A445B250098BDFC"
BuildableName = "SDWebImageSwiftUIDemo-visionOS.app"
BlueprintName = "SDWebImageSwiftUIDemo-visionOS"
ReferencedContainer = "container:SDWebImageSwiftUI.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "32D5D15F2A445B250098BDFC"
BuildableName = "SDWebImageSwiftUIDemo-visionOS.app"
BlueprintName = "SDWebImageSwiftUIDemo-visionOS"
ReferencedContainer = "container:SDWebImageSwiftUI.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

View File

@ -0,0 +1,46 @@
/*
* This file is part of the SDWebImage package.
* (c) DreamPiggy <lizhuoli1126@126.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
import SwiftUI
import UIKit
import SDWebImage
import SDWebImageWebPCoder
import SDWebImageSVGCoder
import SDWebImagePDFCoder
// no changes in your AppDelegate class
class AppDelegate: NSObject, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
// Add WebP/SVG/PDF support
SDImageCodersManager.shared.addCoder(SDImageWebPCoder.shared)
SDImageCodersManager.shared.addCoder(SDImageSVGCoder.shared)
SDImageCodersManager.shared.addCoder(SDImagePDFCoder.shared)
// Dynamic check to support vector format for both WebImage/AnimatedImage
SDWebImageManager.shared.optionsProcessor = SDWebImageOptionsProcessor { url, options, context in
var options = options
if let _ = context?[.animatedImageClass] as? SDAnimatedImage.Type {
// AnimatedImage supports vector rendering, should not force decode
options.insert(.avoidDecodeImage)
}
return SDWebImageOptionsResult(options: options, context: context)
}
return true
}
}
@main
struct SDWebImageSwiftUIDemo: App {
// inject into SwiftUI life-cycle via adaptor
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate
var body: some Scene {
WindowGroup {
ContentView()
}
}
}

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "reality",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,17 @@
{
"info" : {
"author" : "xcode",
"version" : 1
},
"layers" : [
{
"filename" : "Front.solidimagestacklayer"
},
{
"filename" : "Middle.solidimagestacklayer"
},
{
"filename" : "Back.solidimagestacklayer"
}
]
}

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "reality",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,12 @@
{
"images" : [
{
"idiom" : "reality",
"scale" : "2x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
</dict>
</plist>

View File

@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

View File

@ -95,7 +95,7 @@ struct ContentView: View {
NavigationLink(destination: DetailView(url: url, animated: self.animated)) {
HStack {
if self.animated {
#if os(macOS) || os(iOS) || os(tvOS)
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS)
AnimatedImage(url: URL(string:url), isAnimating: .constant(true))
.onViewUpdate { view, context in
#if os(macOS)
@ -140,6 +140,20 @@ struct ContentView: View {
var body: some View {
#if os(visionOS)
return NavigationView {
contentView()
.navigationBarTitle(animated ? "AnimatedImage" : "WebImage")
.navigationBarItems(leading:
Button(action: { self.reloadCache() }) {
Text("Reload")
}, trailing:
Button(action: { self.switchView() }) {
Text("Switch")
}
)
}
#endif
#if os(iOS)
return NavigationView {
contentView()

View File

@ -44,7 +44,7 @@ struct DetailView: View {
var body: some View {
VStack {
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
zoomView()
.navigationBarItems(trailing: Button(isAnimating ? "Stop" : "Start") {
self.isAnimating.toggle()
@ -62,7 +62,7 @@ struct DetailView: View {
}
func zoomView() -> some View {
#if os(macOS) || os(iOS)
#if os(macOS) || os(iOS) || os(visionOS)
return contentView()
.scaleEffect(self.scale)
.gesture(MagnificationGesture(minimumScaleDelta: 0.1).onChanged { value in
@ -94,7 +94,7 @@ struct DetailView: View {
func contentView() -> some View {
HStack {
if animated {
#if os(macOS) || os(iOS) || os(tvOS)
#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS)
AnimatedImage(url: URL(string:url), options: [.progressiveLoad, .delayPlaceholder], isAnimating: $isAnimating)
.resizable()
.placeholder(.wifiExclamationmark)

View File

@ -18,6 +18,20 @@ It brings all your favorite features from SDWebImage, like async image loading,
The framework provide the different View structs, which API match the SwiftUI framework guideline. If you're familiar with `Image`, you'll find it easy to use `WebImage` and `AnimatedImage`.
## Apple VisionOS
From v3.0.0 (beta), SDWebImageSwiftUI can be compiled for visionOS platform. However, due to the lacking package manager support (need tools update), we don't support CocoaPods/SPM yet.
You can only use the Xcode's built-in package manager dependency to build on visionOS.
To run the visionOS example, you need to clone and add both `SDWebImage` and `SDWebImageSwiftUI`, open the `SDWebImageSwiftUI.xcworkspace` and drag those folders to become local package dependency, see: [Editing a package dependency as a local package](https://developer.apple.com/documentation/xcode/editing-a-package-dependency-as-a-local-package)
If you really want to build framework instead of using Xcode's package dependency, following the manual steps below:
1. Clone SDWebImage, open `SDWebImage.xcodeproj` and build `SDWebImage` target for visionOS platform (Change `MACH_O_TYPE` to static library if you need)
2. Clone SDWebImageSwiftUI, create directory at `Carthage/Build/visionOS` and copy `SDWebImage.framework` into it
3. Open `SDWebImageSwiftUI.xcodeproj` and build `SDWebImageSwiftUI visionOS` target
## Features
Since SDWebImageSwiftUI is built on top of SDWebImage, it provide both the out-of-box features as well as advanced powerful features you may want in real world Apps. Check our [Wiki](https://github.com/SDWebImage/SDWebImage/wiki/Advanced-Usage) when you need:
@ -50,32 +64,17 @@ All issue reports, feature requests, contributions, and GitHub stars are welcome
## Requirements
+ Xcode 12+
+ Xcode 14+
+ iOS 14+
+ macOS 11+
+ tvOS 14+
+ watchOS 7+
## SwiftUI 2.0 Compatibility
## for SwiftUI 1.0 (iOS 13)
iOS 14(macOS 11) introduce the SwiftUI 2.0, which keep the most API compatible, but changes many internal behaviors, which breaks the SDWebImageSwiftUI's function.
From v2.0.0, we adopt SwiftUI 2.0 and iOS 14(macOS 11)'s behavior. You can use `WebImage` and `AnimatedImage` inside the new `LazyVStack`.
```swift
var body: some View {
ScrollView {
LazyVStack {
ForEach(urls, id: \.self) { url in
AnimatedImage(url: url)
}
}
}
}
```
Note: However, many differences behavior between iOS 13/14 is hard to fixup. Due to maintain issue, from SDWebImageSwiftUI v3.0, iOS 13 is no longer supported. We always match SwiftUI 2.0's behavior.
From v3.0.0 (Beta), SDWebImageSwiftUI drop iOS 13 support. To use on iOS 13, checkout the latest v2.x version (or using `2.x` branch) instead.
## Installation
@ -610,9 +609,10 @@ struct ContentView : View {
To run the example using SwiftUI, following the steps:
1. Run `pod install` on root directory to install the dependency.
2. Open `SDWebImageSwiftUI.xcworkspace`, wait for SwiftPM finishing downloading the test dependency.
3. Choose `SDWebImageSwiftUIDemo` scheme and run the demo application.
1. Open `SDWebImageSwiftUI.xcworkspace`, wait for SwiftPM finishing downloading the test dependency.
2. Choose `SDWebImageSwiftUIDemo` (or other platforms) scheme and run the demo application.
Note: The `Podfile` here is because history we use CocoaPods to integrate libs into Demo, but now we use SPM.
Since SwiftUI is aimed to support all Apple platforms, our demo does this as well, one codebase including:
@ -620,6 +620,7 @@ Since SwiftUI is aimed to support all Apple platforms, our demo does this as wel
+ macOS
+ tvOS
+ watchOS
+ visionOS
Demo Tips:

View File

@ -7,22 +7,25 @@
objects = {
/* Begin PBXBuildFile section */
3243AFE62AA37EFF0049A43B /* SwiftUICompatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32B79C9428DB40430088C432 /* SwiftUICompatibility.swift */; };
3243AFE72AA37EFF0049A43B /* WebImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C43DDE22FD54C600BE87F5 /* WebImage.swift */; };
3243AFE82AA37EFF0049A43B /* ImagePlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32CBA77E25E4D7D800C6A8DC /* ImagePlayer.swift */; };
3243AFE92AA37EFF0049A43B /* ImageViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326E480923431C0F00C633E9 /* ImageViewWrapper.swift */; };
3243AFEA2AA37EFF0049A43B /* Image.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32D26A012446B546005905DA /* Image.swift */; };
3243AFEB2AA37EFF0049A43B /* AnimatedImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C43DDF22FD54C600BE87F5 /* AnimatedImage.swift */; };
3243AFEC2AA37EFF0049A43B /* ImageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C43DDC22FD54C600BE87F5 /* ImageManager.swift */; };
3243AFED2AA37EFF0049A43B /* SDWebImageSwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32C43E3122FD5DE100BE87F5 /* SDWebImageSwiftUI.swift */; };
3243AFEE2AA37F010049A43B /* Indicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B84812363350C0011BDFB /* Indicator.swift */; };
3243AFEF2AA37F030049A43B /* Transition.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32B933E423659A1900BB7CAD /* Transition.swift */; };
326B84822363350C0011BDFB /* Indicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B84812363350C0011BDFB /* Indicator.swift */; };
326B84832363350C0011BDFB /* Indicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B84812363350C0011BDFB /* Indicator.swift */; };
326B84842363350C0011BDFB /* Indicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B84812363350C0011BDFB /* Indicator.swift */; };
326B84852363350C0011BDFB /* Indicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B84812363350C0011BDFB /* Indicator.swift */; };
326B8487236335110011BDFB /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B8486236335110011BDFB /* ActivityIndicator.swift */; };
326B8488236335110011BDFB /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B8486236335110011BDFB /* ActivityIndicator.swift */; };
326B8489236335110011BDFB /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B8486236335110011BDFB /* ActivityIndicator.swift */; };
326B848A236335110011BDFB /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B8486236335110011BDFB /* ActivityIndicator.swift */; };
326B848C236335400011BDFB /* ProgressIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B848B236335400011BDFB /* ProgressIndicator.swift */; };
326B848D236335400011BDFB /* ProgressIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B848B236335400011BDFB /* ProgressIndicator.swift */; };
326B848E236335400011BDFB /* ProgressIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B848B236335400011BDFB /* ProgressIndicator.swift */; };
326B848F236335400011BDFB /* ProgressIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326B848B236335400011BDFB /* ProgressIndicator.swift */; };
326E480A23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326E480923431C0F00C633E9 /* ImageViewWrapper.swift */; };
326E480B23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326E480923431C0F00C633E9 /* ImageViewWrapper.swift */; };
326E480C23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326E480923431C0F00C633E9 /* ImageViewWrapper.swift */; };
326E480D23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 326E480923431C0F00C633E9 /* ImageViewWrapper.swift */; };
329885EE2AA37FCB0071F2BA /* SDWebImage.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 329885ED2AA37FCB0071F2BA /* SDWebImage.framework */; };
32B79C9528DB40430088C432 /* SwiftUICompatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32B79C9428DB40430088C432 /* SwiftUICompatibility.swift */; };
32B79C9628DB40430088C432 /* SwiftUICompatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32B79C9428DB40430088C432 /* SwiftUICompatibility.swift */; };
32B79C9728DB40430088C432 /* SwiftUICompatibility.swift in Sources */ = {isa = PBXBuildFile; fileRef = 32B79C9428DB40430088C432 /* SwiftUICompatibility.swift */; };
@ -71,13 +74,12 @@
3211F84F23DE98E300FC757F /* WebImageTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebImageTests.swift; sourceTree = "<group>"; };
3211F85423DE9D2700FC757F /* Images.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = Images.bundle; sourceTree = "<group>"; };
322E0F4723E57F09006836DC /* TestUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestUtils.swift; sourceTree = "<group>"; };
3243AFDF2AA37EE90049A43B /* SDWebImageSwiftUI_visionOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImageSwiftUI_visionOS.framework; sourceTree = BUILT_PRODUCTS_DIR; };
326B84812363350C0011BDFB /* Indicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Indicator.swift; sourceTree = "<group>"; };
326B8486236335110011BDFB /* ActivityIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ActivityIndicator.swift; sourceTree = "<group>"; };
326B848B236335400011BDFB /* ProgressIndicator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ProgressIndicator.swift; sourceTree = "<group>"; };
326E480923431C0F00C633E9 /* ImageViewWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageViewWrapper.swift; sourceTree = "<group>"; };
329885ED2AA37FCB0071F2BA /* SDWebImage.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SDWebImage.framework; path = Carthage/Build/visionOS/SDWebImage.framework; sourceTree = "<group>"; };
32B79C9428DB40430088C432 /* SwiftUICompatibility.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftUICompatibility.swift; sourceTree = "<group>"; };
32B933E423659A1900BB7CAD /* Transition.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Transition.swift; sourceTree = "<group>"; };
32BD9C4623E03B08008D5F6A /* IndicatorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndicatorTests.swift; sourceTree = "<group>"; };
32C43DCC22FD540D00BE87F5 /* SDWebImageSwiftUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SDWebImageSwiftUI.framework; sourceTree = BUILT_PRODUCTS_DIR; };
32C43DDC22FD54C600BE87F5 /* ImageManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageManager.swift; sourceTree = "<group>"; };
32C43DDE22FD54C600BE87F5 /* WebImage.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebImage.swift; sourceTree = "<group>"; };
@ -98,6 +100,14 @@
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
3243AFDC2AA37EE90049A43B /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
329885EE2AA37FCB0071F2BA /* SDWebImage.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
32C43DC922FD540D00BE87F5 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@ -140,7 +150,6 @@
3211F84823DE984D00FC757F /* Info.plist */,
3211F84623DE984D00FC757F /* AnimatedImageTests.swift */,
3211F84F23DE98E300FC757F /* WebImageTests.swift */,
32BD9C4623E03B08008D5F6A /* IndicatorTests.swift */,
32ED4825242A13030053338E /* ImageManagerTests.swift */,
322E0F4723E57F09006836DC /* TestUtils.swift */,
);
@ -151,8 +160,6 @@
isa = PBXGroup;
children = (
326B84812363350C0011BDFB /* Indicator.swift */,
326B8486236335110011BDFB /* ActivityIndicator.swift */,
326B848B236335400011BDFB /* ProgressIndicator.swift */,
);
path = Indicator;
sourceTree = "<group>";
@ -184,6 +191,7 @@
32C43DF422FD57FD00BE87F5 /* SDWebImageSwiftUI.framework */,
32C43E0122FD581400BE87F5 /* SDWebImageSwiftUI.framework */,
32C43E0E22FD581C00BE87F5 /* SDWebImageSwiftUI.framework */,
3243AFDF2AA37EE90049A43B /* SDWebImageSwiftUI_visionOS.framework */,
);
name = Products;
sourceTree = "<group>";
@ -216,6 +224,7 @@
32C43DE822FD577300BE87F5 /* Frameworks */ = {
isa = PBXGroup;
children = (
329885ED2AA37FCB0071F2BA /* SDWebImage.framework */,
32C43E2D22FD586E00BE87F5 /* SDWebImage.framework */,
32C43E2922FD586200BE87F5 /* SDWebImage.framework */,
32C43E2522FD585300BE87F5 /* SDWebImage.framework */,
@ -227,6 +236,13 @@
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
3243AFDA2AA37EE90049A43B /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
32C43DC722FD540D00BE87F5 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
@ -262,6 +278,24 @@
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
3243AFDE2AA37EE90049A43B /* SDWebImageSwiftUI visionOS */ = {
isa = PBXNativeTarget;
buildConfigurationList = 3243AFE32AA37EEA0049A43B /* Build configuration list for PBXNativeTarget "SDWebImageSwiftUI visionOS" */;
buildPhases = (
3243AFDA2AA37EE90049A43B /* Headers */,
3243AFDB2AA37EE90049A43B /* Sources */,
3243AFDC2AA37EE90049A43B /* Frameworks */,
3243AFDD2AA37EE90049A43B /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = "SDWebImageSwiftUI visionOS";
productName = "SDWebImageSwiftUI visionOS";
productReference = 3243AFDF2AA37EE90049A43B /* SDWebImageSwiftUI_visionOS.framework */;
productType = "com.apple.product-type.framework";
};
32C43DCB22FD540D00BE87F5 /* SDWebImageSwiftUI */ = {
isa = PBXNativeTarget;
buildConfigurationList = 32C43DD422FD540D00BE87F5 /* Build configuration list for PBXNativeTarget "SDWebImageSwiftUI" */;
@ -344,6 +378,9 @@
LastUpgradeCheck = 1100;
ORGANIZATIONNAME = SDWebImage;
TargetAttributes = {
3243AFDE2AA37EE90049A43B = {
CreatedOnToolsVersion = 15.0;
};
32C43DCB22FD540D00BE87F5 = {
CreatedOnToolsVersion = 11.0;
LastSwiftMigration = 1100;
@ -371,8 +408,6 @@
Base,
);
mainGroup = 32C43DC222FD540D00BE87F5;
packageReferences = (
);
productRefGroup = 32C43DCD22FD540D00BE87F5 /* Products */;
projectDirPath = "";
projectRoot = "";
@ -381,11 +416,19 @@
32C43DF322FD57FD00BE87F5 /* SDWebImageSwiftUI macOS */,
32C43E0022FD581400BE87F5 /* SDWebImageSwiftUI tvOS */,
32C43E0D22FD581C00BE87F5 /* SDWebImageSwiftUI watchOS */,
3243AFDE2AA37EE90049A43B /* SDWebImageSwiftUI visionOS */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
3243AFDD2AA37EE90049A43B /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
32C43DCA22FD540D00BE87F5 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@ -417,6 +460,23 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
3243AFDB2AA37EE90049A43B /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
3243AFEF2AA37F030049A43B /* Transition.swift in Sources */,
3243AFE92AA37EFF0049A43B /* ImageViewWrapper.swift in Sources */,
3243AFE72AA37EFF0049A43B /* WebImage.swift in Sources */,
3243AFEC2AA37EFF0049A43B /* ImageManager.swift in Sources */,
3243AFEB2AA37EFF0049A43B /* AnimatedImage.swift in Sources */,
3243AFE82AA37EFF0049A43B /* ImagePlayer.swift in Sources */,
3243AFED2AA37EFF0049A43B /* SDWebImageSwiftUI.swift in Sources */,
3243AFE62AA37EFF0049A43B /* SwiftUICompatibility.swift in Sources */,
3243AFEE2AA37F010049A43B /* Indicator.swift in Sources */,
3243AFEA2AA37EFF0049A43B /* Image.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
32C43DC822FD540D00BE87F5 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@ -424,12 +484,10 @@
32B933E523659A1900BB7CAD /* Transition.swift in Sources */,
32CBA78025E4D7D800C6A8DC /* ImagePlayer.swift in Sources */,
32C43E1722FD583700BE87F5 /* WebImage.swift in Sources */,
326B848C236335400011BDFB /* ProgressIndicator.swift in Sources */,
326B84822363350C0011BDFB /* Indicator.swift in Sources */,
32C43E3222FD5DE100BE87F5 /* SDWebImageSwiftUI.swift in Sources */,
326E480A23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */,
32B79C9528DB40430088C432 /* SwiftUICompatibility.swift in Sources */,
326B8487236335110011BDFB /* ActivityIndicator.swift in Sources */,
32C43E1622FD583700BE87F5 /* ImageManager.swift in Sources */,
32C43E1822FD583700BE87F5 /* AnimatedImage.swift in Sources */,
32D26A022446B546005905DA /* Image.swift in Sources */,
@ -443,12 +501,10 @@
32B933E623659A1900BB7CAD /* Transition.swift in Sources */,
32CBA78125E4D7D800C6A8DC /* ImagePlayer.swift in Sources */,
32C43E1A22FD583700BE87F5 /* WebImage.swift in Sources */,
326B848D236335400011BDFB /* ProgressIndicator.swift in Sources */,
326B84832363350C0011BDFB /* Indicator.swift in Sources */,
32C43E3322FD5DF400BE87F5 /* SDWebImageSwiftUI.swift in Sources */,
326E480B23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */,
32B79C9628DB40430088C432 /* SwiftUICompatibility.swift in Sources */,
326B8488236335110011BDFB /* ActivityIndicator.swift in Sources */,
32C43E1922FD583700BE87F5 /* ImageManager.swift in Sources */,
32C43E1B22FD583700BE87F5 /* AnimatedImage.swift in Sources */,
32D26A032446B546005905DA /* Image.swift in Sources */,
@ -462,12 +518,10 @@
32B933E723659A1900BB7CAD /* Transition.swift in Sources */,
32CBA78225E4D7D800C6A8DC /* ImagePlayer.swift in Sources */,
32C43E1D22FD583800BE87F5 /* WebImage.swift in Sources */,
326B848E236335400011BDFB /* ProgressIndicator.swift in Sources */,
326B84842363350C0011BDFB /* Indicator.swift in Sources */,
32C43E3422FD5DF400BE87F5 /* SDWebImageSwiftUI.swift in Sources */,
326E480C23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */,
32B79C9728DB40430088C432 /* SwiftUICompatibility.swift in Sources */,
326B8489236335110011BDFB /* ActivityIndicator.swift in Sources */,
32C43E1C22FD583800BE87F5 /* ImageManager.swift in Sources */,
32C43E1E22FD583800BE87F5 /* AnimatedImage.swift in Sources */,
32D26A042446B546005905DA /* Image.swift in Sources */,
@ -481,12 +535,10 @@
32B933E823659A1900BB7CAD /* Transition.swift in Sources */,
32CBA78325E4D7D800C6A8DC /* ImagePlayer.swift in Sources */,
32C43E2022FD583800BE87F5 /* WebImage.swift in Sources */,
326B848F236335400011BDFB /* ProgressIndicator.swift in Sources */,
326B84852363350C0011BDFB /* Indicator.swift in Sources */,
32C43E3522FD5DF400BE87F5 /* SDWebImageSwiftUI.swift in Sources */,
326E480D23431C0F00C633E9 /* ImageViewWrapper.swift in Sources */,
32B79C9828DB40430088C432 /* SwiftUICompatibility.swift in Sources */,
326B848A236335110011BDFB /* ActivityIndicator.swift in Sources */,
32C43E1F22FD583800BE87F5 /* ImageManager.swift in Sources */,
32C43E2122FD583800BE87F5 /* AnimatedImage.swift in Sources */,
32D26A052446B546005905DA /* Image.swift in Sources */,
@ -496,6 +548,91 @@
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
3243AFE42AA37EEA0049A43B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/visionOS",
);
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2023 SDWebImage. All rights reserved.";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
PRODUCT_BUNDLE_IDENTIFIER = "com.dreampiggy.SDWebImageSwiftUI-visionOS";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SDKROOT = xros;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "xros xrsimulator";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
3243AFE52AA37EEA0049A43B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++20";
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "@rpath";
ENABLE_MODULE_VERIFIER = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Carthage/Build/visionOS",
);
GCC_C_LANGUAGE_STANDARD = gnu17;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_KEY_NSHumanReadableCopyright = "Copyright © 2023 SDWebImage. All rights reserved.";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MARKETING_VERSION = 1.0;
MODULE_VERIFIER_SUPPORTED_LANGUAGES = "objective-c objective-c++";
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++20";
PRODUCT_BUNDLE_IDENTIFIER = "com.dreampiggy.SDWebImageSwiftUI-visionOS";
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SDKROOT = xros;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "xros xrsimulator";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
};
32C43DD222FD540D00BE87F5 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@ -566,6 +703,7 @@
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 7.0;
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Debug;
};
@ -633,6 +771,7 @@
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
WATCHOS_DEPLOYMENT_TARGET = 7.0;
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Release;
};
@ -877,6 +1016,15 @@
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
3243AFE32AA37EEA0049A43B /* Build configuration list for PBXNativeTarget "SDWebImageSwiftUI visionOS" */ = {
isa = XCConfigurationList;
buildConfigurations = (
3243AFE42AA37EEA0049A43B /* Debug */,
3243AFE52AA37EEA0049A43B /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
32C43DC622FD540D00BE87F5 /* Build configuration list for PBXProject "SDWebImageSwiftUI" */ = {
isa = XCConfigurationList;
buildConfigurations = (

View File

@ -4,7 +4,4 @@
<FileRef
location = "group:Example/SDWebImageSwiftUI.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>

View File

@ -9,7 +9,7 @@
import SwiftUI
import SDWebImage
#if os(iOS) || os(tvOS) || os(macOS)
#if !os(watchOS)
/// A coordinator object used for `AnimatedImage`native view bridge for UIKit/AppKit.
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
@ -183,7 +183,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
#if os(macOS)
public typealias NSViewType = AnimatedImageViewWrapper
#elseif os(iOS) || os(tvOS)
#else
public typealias UIViewType = AnimatedImageViewWrapper
#endif
@ -205,7 +205,7 @@ public struct AnimatedImage : PlatformViewRepresentable {
public static func dismantleNSView(_ nsView: AnimatedImageViewWrapper, coordinator: Coordinator) {
dismantleView(nsView, coordinator: coordinator)
}
#elseif os(iOS) || os(tvOS)
#else
public func makeUIView(context: Context) -> AnimatedImageViewWrapper {
makeView(context: context)
}
@ -358,14 +358,14 @@ public struct AnimatedImage : PlatformViewRepresentable {
// AspectRatio && ContentMode
#if os(macOS)
let contentMode: NSImageScaling
#elseif os(iOS) || os(tvOS)
#else
let contentMode: UIView.ContentMode
#endif
if let _ = imageLayout.aspectRatio {
// If `aspectRatio` is not `nil`, always scale to fill and SwiftUI will layout the container with custom aspect ratio.
#if os(macOS)
contentMode = .scaleAxesIndependently
#elseif os(iOS) || os(tvOS)
#else
contentMode = .scaleToFill
#endif
} else {
@ -376,20 +376,20 @@ public struct AnimatedImage : PlatformViewRepresentable {
// Actually, NSImageView have no `.aspectFill` unlike UIImageView, only `CALayerContentsGravity.resizeAspectFill` have the same concept
// However, using `.scaleProportionallyUpOrDown`, SwiftUI still layout the HostingView correctly, so this is OK
contentMode = .scaleProportionallyUpOrDown
#elseif os(iOS) || os(tvOS)
#else
contentMode = .scaleAspectFill
#endif
case .fit:
#if os(macOS)
contentMode = .scaleProportionallyUpOrDown
#elseif os(iOS) || os(tvOS)
#else
contentMode = .scaleAspectFit
#endif
case .none:
// If `contentMode` is not set at all, using scale to fill as SwiftUI default value
#if os(macOS)
contentMode = .scaleAxesIndependently
#elseif os(iOS) || os(tvOS)
#else
contentMode = .scaleToFill
#endif
}

View File

@ -25,7 +25,7 @@ extension PlatformImage {
static var empty = PlatformImage()
}
#if os(iOS) || os(tvOS) || os(watchOS)
#if !os(macOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
extension PlatformImage.Orientation {
@inlinable var toSwiftUI: Image.Orientation {

View File

@ -7,6 +7,7 @@
*/
import SwiftUI
import Combine
import SDWebImage
/// A Image observable object for handle image load process. This drive the Source of Truth for image loading status.

View File

@ -7,6 +7,7 @@
*/
import SwiftUI
import Combine
import SDWebImage
/// A Image observable object for handle aniamted image playback. This is used to avoid `@State` update may capture the View struct type and cause memory leak.

View File

@ -9,7 +9,7 @@
import Foundation
import SDWebImage
#if os(iOS) || os(tvOS) || os(macOS)
#if !os(watchOS)
/// Use wrapper to solve tne `UIImageView`/`NSImageView` frame size become image size issue (SwiftUI's Bug)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)

View File

@ -6,8 +6,8 @@
* file that was distributed with this source code.
*/
import Foundation
import SwiftUI
import Combine
/// A type to build the indicator
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)

View File

@ -22,7 +22,7 @@ public typealias PlatformImage = UIImage
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformView = NSView
#endif
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformView = UIView
#endif
@ -35,7 +35,7 @@ public typealias PlatformView = WKInterfaceObject
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformViewRepresentable = NSViewRepresentable
#endif
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
public typealias PlatformViewRepresentable = UIViewRepresentable
#endif
@ -50,7 +50,7 @@ extension NSViewRepresentable {
typealias PlatformViewType = NSViewType
}
#endif
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
extension UIViewRepresentable {
typealias PlatformViewType = UIViewType

View File

@ -9,14 +9,14 @@
import Foundation
import SwiftUI
#if os(iOS) || os(tvOS) || os(macOS)
#if !os(watchOS)
@available(iOS 14.0, OSX 11.0, tvOS 14.0, watchOS 7.0, *)
struct PlatformAppear: PlatformViewRepresentable {
let appearAction: () -> Void
let disappearAction: () -> Void
#if os(iOS) || os(tvOS)
#if os(iOS) || os(tvOS) || os(visionOS)
func makeUIView(context: Context) -> some UIView {
let view = PlatformAppearView()
view.appearAction = appearAction

View File

@ -158,9 +158,11 @@ public struct WebImage : View {
// ensure CGImage is nil
if image.cgImage == nil {
// draw vector into bitmap with the screen scale (behavior like AppKit)
#if os(iOS) || os(tvOS)
#if os(visionOS)
let scale = UITraitCollection.current.displayScale
#elseif os(iOS) || os(tvOS) || os(visionOS)
let scale = UIScreen.main.scale
#else
#elseif os(watchOS)
let scale = WKInterfaceDevice.current().screenScale
#endif
UIGraphicsBeginImageContextWithOptions(image.size, false, scale)