Skip to content
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

Xcode 15 and related feature support #2108

Merged
merged 14 commits into from
Jul 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions Cartfile.project

This file was deleted.

62 changes: 31 additions & 31 deletions Demo/Demo/Kingfisher-Demo/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions Demo/Kingfisher-Demo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,11 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.onevcat.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Debug;
};
Expand All @@ -1074,8 +1078,12 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.onevcat.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2,7";
};
name = Release;
};
Expand Down
2 changes: 2 additions & 0 deletions Kingfisher.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Pod::Spec.new do |s|
s.tvos.deployment_target = "12.0"
s.osx.deployment_target = "10.14"
s.watchos.deployment_target = "5.0"
# Wait for CocoaPods 1.13.0 (visionOS support)
# s.visionos.deployment_target = "1.0"

s.source = { :git => "https://github.com/onevcat/Kingfisher.git", :tag => s.version }
s.source_files = ["Sources/**/*.swift"]
Expand Down
26 changes: 22 additions & 4 deletions Kingfisher.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
D1A37BF1215D3850009B39B7 /* SizeExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SizeExtensions.swift; sourceTree = "<group>"; };
D1BA781C2174D07800C69D7B /* CallbackQueue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CallbackQueue.swift; sourceTree = "<group>"; };
D1BFED94222ACC6B009330C8 /* ImageProcessorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageProcessorTests.swift; sourceTree = "<group>"; };
D1C04A3E2A45D20500B3775F /* PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
D1D2C3291C70A3230018F2F9 /* single-frame.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = "single-frame.gif"; sourceTree = "<group>"; };
D1DC4B401D60996D00DFDFAA /* StringExtensionTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtensionTests.swift; sourceTree = "<group>"; };
D1E564402199C21E0057AAE3 /* StorageExpirationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StorageExpirationTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -323,6 +324,7 @@
isa = PBXGroup;
children = (
D12AB6A9215D2BB50013BA68 /* Info.plist */,
D1C04A3E2A45D20500B3775F /* PrivacyInfo.xcprivacy */,
D12AB6B0215D2BB50013BA68 /* General */,
D12AB6A2215D2BB50013BA68 /* Image */,
D12AB69C215D2BB50013BA68 /* Networking */,
Expand Down Expand Up @@ -1079,8 +1081,13 @@
PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
PRODUCT_NAME = Kingfisher;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
Expand Down Expand Up @@ -1128,7 +1135,12 @@
PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK;
PRODUCT_NAME = Kingfisher;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;
Expand All @@ -1146,10 +1158,13 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.onevcat.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/KingfisherTests/KingfisherTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
};
name = Debug;
};
Expand All @@ -1162,10 +1177,13 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.onevcat.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx watchos watchsimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_OBJC_BRIDGING_HEADER = "Tests/KingfisherTests/KingfisherTests-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
TARGETED_DEVICE_FAMILY = "1,2,3,4";
TARGETED_DEVICE_FAMILY = "1,2,3,4,7";
};
name = Release;
};
Expand Down
22 changes: 22 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// swift-tools-version:5.9
import PackageDescription

let package = Package(
name: "Kingfisher",
platforms: [
.iOS(.v12),
.macOS(.v10_14),
.tvOS(.v12),
.watchOS(.v5),
.visionOS(.v1)
],
products: [
.library(name: "Kingfisher", targets: ["Kingfisher"])
],
targets: [
.target(
name: "Kingfisher",
path: "Sources"
)
]
)
16 changes: 13 additions & 3 deletions Sources/General/ImageSource/AVAssetImageDataProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,21 @@ public struct AVAssetImageDataProvider: ImageDataProvider {

extension CGImage {
var jpegData: Data? {
guard let mutableData = CFDataCreateMutable(nil, 0),
let destination = CGImageDestinationCreateWithData(mutableData, kUTTypeJPEG, 1, nil)
else {
guard let mutableData = CFDataCreateMutable(nil, 0) else {
return nil
}
#if os(xrOS)
guard let destination = CGImageDestinationCreateWithData(
mutableData, UTType.jpeg.identifier as CFString , 1, nil
) else {
return nil
}
#else
guard let destination = CGImageDestinationCreateWithData(mutableData, kUTTypeJPEG, 1, nil) else {
return nil
}
#endif

CGImageDestinationAddImage(destination, self, nil)
guard CGImageDestinationFinalize(destination) else { return nil }
return mutableData as Data
Expand Down
11 changes: 11 additions & 0 deletions Sources/Image/Image.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ import CoreImage
import CoreGraphics
import ImageIO

#if canImport(UniformTypeIdentifiers)
import UniformTypeIdentifiers
#endif

private var animatedImageDataKey: Void?
private var imageFrameCountKey: Void?

Expand Down Expand Up @@ -274,10 +278,17 @@ extension KingfisherWrapper where Base: KFCrossPlatformImage {
/// - Returns: An `Image` object represents the animated image. It is in form of an array of image frames with a
/// certain duration. `nil` if anything wrong when creating animated image.
public static func animatedImage(data: Data, options: ImageCreatingOptions) -> KFCrossPlatformImage? {
#if os(xrOS)
let info: [String: Any] = [
kCGImageSourceShouldCache as String: true,
kCGImageSourceTypeIdentifierHint as String: UTType.gif.identifier
]
#else
let info: [String: Any] = [
kCGImageSourceShouldCache as String: true,
kCGImageSourceTypeIdentifierHint as String: kUTTypeGIF
]
#endif

guard let imageSource = CGImageSourceCreateWithData(data as CFData, info as CFDictionary) else {
return nil
Expand Down
19 changes: 19 additions & 0 deletions Sources/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?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>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>Calculate cache expiring date for disk files based on developer settings and cache policy.</string>
</array>
</dict>
</array>
<key>NSPrivacyTracking</key>
<false/>
</dict>
</plist>
4 changes: 4 additions & 0 deletions Sources/Views/AnimatedImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,11 @@ open class AnimatedImageView: UIImageView {
private func reset() {
animator = nil
if let image = image, let frameSource = image.kf.frameSource {
#if os(xrOS)
let targetSize = bounds.scaled(UITraitCollection.current.displayScale).size
#else
let targetSize = bounds.scaled(UIScreen.main.scale).size
#endif
let animator = Animator(
frameSource: frameSource,
contentMode: contentMode,
Expand Down
2 changes: 2 additions & 0 deletions Sources/Views/Indicator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ final class ActivityIndicator: Indicator {
} else {
indicatorStyle = UIActivityIndicatorView.Style.white
}
#elseif os(xrOS)
indicatorStyle = UIActivityIndicatorView.Style.medium
#else
if #available(iOS 13.0, * ) {
indicatorStyle = UIActivityIndicatorView.Style.medium
Expand Down
9 changes: 6 additions & 3 deletions fastlane/Fastfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,8 @@ platform :ios do

lane :xcframework do |options|
target_version = "Kingfisher-#{options[:version]}"
supporting_root = "../build/#{target_version}/Supporting Files"

xcversion(version: "~> 14.0")
xcversion(version: "~> 15.0")
FileUtils.rm_rf '../build'

frameworks = {}
Expand All @@ -104,7 +103,9 @@ platform :ios do
"appletvos",
"appletvsimulator",
"watchos",
"watchsimulator"
"watchsimulator",
"xros",
"xrsimulator"
].each do |sdk|
archive_path = "build/Kingfisher-#{sdk}.xcarchive"
xcodebuild(
Expand All @@ -127,6 +128,8 @@ platform :ios do
output: "build/#{target_version}/Kingfisher.xcframework"
)

Actions.sh("codesign --timestamp -v --sign 'Apple Distribution: Wei Wang (A4YJ9MRZ66)' ../build/#{target_version}/Kingfisher.xcframework")

zip(
path: "build/#{target_version}",
output_path: "build/#{target_version}.zip"
Expand Down