vtourraine / AcknowList

Acknowledgements screen displaying a list of licenses, for example from CocoaPods and Swift Package Manager dependencies.
MIT License
807 stars 60 forks source link

Xcode 13, DocC #86

Closed vtourraine closed 2 years ago

vtourraine commented 3 years ago
melle commented 3 years ago

Problem

I noticed build errors on Xcode 12.5 when building my project for Any iOS Device (arm64) like the Archive step does. AcknowList is included via SPM:

.package(name: "AcknowList", url: "https://github.com/vtourraine/AcknowList.git", .branch("xcode-13")),

It looks like SwiftUI is not available:

AcknowList/Sources/AcknowList/AcknowListSwiftUI.swift:72:24: cannot find type 'View' in scope
         var body: some View {
                                   ^~~~~~~

However, AcknowListSwiftUIView is guarded by @available(iOS 13.0.0, macOS 10.15.0, watchOS 7.0.0, tvOS 13.0.0, *) so I don't understand why this is a problem.

Steps to reproduce:

Workaround:

Require iOS 13 for AcknowList:

--- a/Package.swift
+++ b/Package.swift
@@ -6,7 +6,7 @@ let package = Package(
     name: "AcknowList",
     defaultLocalization: "en",
     platforms: [
-        .iOS(.v9), .tvOS(.v9), .watchOS(.v7), .macOS(.v10_15)
+        .iOS(.v13), .tvOS(.v9), .watchOS(.v7), .macOS(.v10_15)
     ],

I assume this is not a viable solution as the most users stick with older iOS versions.

vtourraine commented 3 years ago

Oh... you’re right. I hadn’t tested “Archive” since adding the SwiftUI classes. And I don’t understand either why the @available statements don’t solve that. That’s really unfortunate.

There can only be one Package.swift by repository, so we can’t even define an alternate package to satisfy both cases.

If we can’t find a solution, I think I would set the platform requirement at iOS 13 for SPM, and explain in the README that you can support earlier versions by using CocoaPods or importing the library manually. But that’s not great.

Any Swift compiler magician out there who could help us with this?

melle commented 3 years ago

I wonder why wrapping the SwiftUI code in #if canImport(SwiftUI) is not working.

vtourraine commented 2 years ago

Finally resigned myself to the solution of requiring iOS 13, just to make sure the SwiftUI code is supported. Not ideal, but it looks like the only way forward (manual integration is always possible for older versions).