Hey guys.
I’m working on a project where I’m using the SwiftTesting framework instead of XCTest to run my unit tests. I have a file (test.png) located in my test resources folder:
PackageName > Tests > PackageNameTests > Resources > test.png
I’m trying to access this file in my tests, but I’m running into issues when trying to load it dynamically. Here’s what I’ve tried so far:
Using Bundle.module.path(forResource:ofType:): This approach didn’t work, as Bundle.module seems to be unsupported or returns nil in Swift Testing.
Using #file Macro for Relative Paths: I tried constructing a path based on #file and navigating to the resources directory, but it also didn’t yield the correct path.
Has anyone successfully loaded test resources in the Swift Testing framework? Is there a recommended way to access resource files in Swift Testing, especially for projects where Bundle.module isn’t available?
I've gone through the Apple Docs for Swift Testing, but I can't seem to find anything that answers my question.
Thanks in advance guys!
Post
Replies
Boosts
Views
Activity
I'm using Swift 5.0, and deploying to iOS 16. I am using the native MusicKit library for Swift.
When I use the following code:
let request = MusicCatalogSearchRequest(
term: "dopamine - Version Francaise",
types: [MusicKit.Song.self]
)
let response = try await request.response()
The response is completely empty. However when I search in the Music app dopamine - Version Francaise I find the song. I have found this to occur with quite a lot of songs.
Am I doing something wrong here? I've tried messing around with the types by adding every type of MusicCatalogSearchable.Type, but still no luck.