swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.66k stars 10.38k forks source link

"expected ',' in 'available' attribute @available(tvOS)" error during archiving a framework for tvOS #66015

Open onevcat opened 1 year ago

onevcat commented 1 year ago

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 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

Additional context

The archive succeeds with either of these changes:

onevcat commented 1 year ago

The same error is still happening when archiving with Xcode 15 beta (15A5160n) and Swift 5.9.