I am the maintainer of Kingfisher, which is an image loading library for Apple platforms. In my project, I have a subclass of UIImageView. When I plan to release a new version, I found that our creating xcframework step fails under the new Xcode/Swift compiler version due to the subclass.
When using xcodebuild archive to create archive of a framework target for tvOS with UIImageView subclass, it causes a failure, says:
..../Release-appletvos/Kingfisher.build/Objects-normal/arm64/Kingfisher.swiftinterface:158:18:
error: expected ',' in 'available' attribute
@available(tvOS)
^
Steps to reproduce
Choose Xcode 14.3 or Xcode 14.3.1 as the command line tool, then run:
git clone https://github.com/onevcat/Kingfisher.git
cd Kingfisher
# This is the current latest commit
git checkout 00b7d50
xcodebuild archive -archivePath "build/Kingfisher-appletvos.xcarchive" -scheme "Kingfisher" -sdk "appletvos" BUILD_LIBRARY_FOR_DISTRIBUTION="YES" SKIP_INSTALL="NO" -workspace "Kingfisher.xcworkspace"
You got the error above in the generated "swiftinterface" file. The related content in the interface file is:
@objc @_inheritsConvenienceInitializers @_Concurrency.MainActor(unsafe) open class AnimatedImageView : UIKit.UIImageView {
// ...
@_Concurrency.MainActor(unsafe) @objc override dynamic open func didMoveToWindow()
@_Concurrency.MainActor(unsafe) @objc override dynamic open func didMoveToSuperview()
@_Concurrency.MainActor(unsafe) @objc override dynamic public init(image: UIKit.UIImage?)
@available(tvOS) <-- Errored here
@_Concurrency.MainActor(unsafe) @objc override dynamic public init(image: UIKit.UIImage?, highlightedImage: UIKit.UIImage?)
@_Concurrency.MainActor(unsafe) @objc override dynamic public init(frame: CoreFoundation.CGRect)
@_Concurrency.MainActor(unsafe) @objc required dynamic public init?(coder: Foundation.NSCoder)
Expected behavior
The archive action should finish without issues, as in previous Xcode/Swift versions or on other platform SDKs (such as "iphoneos").
Environment
Swift compiler version info
swift-driver version: 1.75.2 Apple Swift version 5.8.1 (swiftlang-5.8.0.124.5 clang-1403.0.22.11.100) Target: arm64-apple-macosx13.0
Xcode version info
Xcode 14.3.1 Build version 14E300b
Deployment target: tvOS 12.0
Additional context
The archive succeeds with either of these changes:
Instead of -sdk "appletvos", use -sdk "iphoneos"
Instead of Xcode 14.3 or Xcode 14.3.1, use Xcode 14.2 or earlier.
Remove BUILD_LIBRARY_FOR_DISTRIBUTION="YES", so do not create the interface file.
Re-implement the initializers to override the ones in UIImageView, especially the init(image: UIKit.UIImage?, highlightedImage: UIKit.UIImage?).
Description
I am the maintainer of Kingfisher, which is an image loading library for Apple platforms. In my project, I have a subclass of
UIImageView
. When I plan to release a new version, I found that our creating xcframework step fails under the new Xcode/Swift compiler version due to the subclass.When using
xcodebuild archive
to create archive of a framework target for tvOS withUIImageView
subclass, it causes a failure, says:Steps to reproduce
Choose Xcode 14.3 or Xcode 14.3.1 as the command line tool, then run:
You got the error above in the generated "swiftinterface" file. The related content in the interface file is:
Expected behavior
The archive action should finish without issues, as in previous Xcode/Swift versions or on other platform SDKs (such as "iphoneos").
Environment
Additional context
The archive succeeds with either of these changes:
-sdk "appletvos"
, use-sdk "iphoneos"
BUILD_LIBRARY_FOR_DISTRIBUTION="YES"
, so do not create the interface file.UIImageView
, especially theinit(image: UIKit.UIImage?, highlightedImage: UIKit.UIImage?)
.