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 16 - SnapshotTesting in a Swift Package #879

Open
kelvinlauKL opened this issue Jul 29, 2024 · 3 comments
Open

Xcode 16 - SnapshotTesting in a Swift Package #879

kelvinlauKL opened this issue Jul 29, 2024 · 3 comments

Comments

@kelvinlauKL
Copy link

kelvinlauKL commented Jul 29, 2024

I'm building a UI library as a Swift Package. Attempting to use SnapshotTesting gives me this:

Screenshot 2024-07-28 at 8 38 23 PM

Here's my package file:

// swift-tools-version: 6.0
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
  name: "ChatDesignSystem",
  platforms: [.macOS(.v15), .iOS(.v18), .tvOS(.v18), .watchOS(.v11), .macCatalyst(.v18)],
  products: [
    .library(
      name: "ChatDesignSystem",
      targets: ["ChatDesignSystem"]),
  ],
  dependencies: [
    .package(url: "https://github.com/pointfreeco/swift-snapshot-testing", branch: "main")
  ],
  targets: [
    .target(
      name: "ChatDesignSystem"),
    .testTarget(
      name: "ChatDesignSystemTests",
      dependencies: [
        "ChatDesignSystem",
        .product(name: "SnapshotTesting", package: "swift-snapshot-testing")
      ]
    ),
  ]
)

Is this not supported in a Swift Package?

@stephencelis
Copy link
Member

@kelvinlauKL The screenshot has the error message mostly truncated. It looks like a compile failure but it's not easy to troubleshoot as is. Can you share sample code reproducing the issue?

@kelvinlauKL
Copy link
Author

kelvinlauKL commented Jul 29, 2024

My bad - the error message is Type of expression is ambiguous without a type annotation. I realized this compiler error is happening when my device is set to "My Mac". The compiler error goes away if I set it to an iOS device.

I've updated the screenshot.

Is that expected behaviour?

@doozMen
Copy link
Contributor

doozMen commented Aug 5, 2024

I have the same issue and was looking into it. I found out to my surprise that the current library does not seam to have the image not compiled for MacOS as the current snapshot implementation seams to rely on making the view a UIImage and embedding it in a viewController. Both do not exist on macOS.

So SwiftUI view support is limited to iOS like platforms
Screenshot 2024-08-05 at 14 45 20

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@stephencelis @doozMen @kelvinlauKL and others