I am experimenting with Swift Testing and Xcode Cloud and would like to write some tests that require to use MusicKit functionality. For example I'd like to fetch an album via MusicCatalogRessourceRequest
to test an initializer of another struct.
However this test fails because the permission to access the music library is not granted. Once the permission is granted, the test works as expected.
Things I have tried:
- Add NSPrivacyAccessedAPITypes to the Info.plist. This did not show any effect. Below is the corresponding snippet
- Trying to tap the button programmatically. Once again this did not show any effect.
The Info.plist snippet:
<key>NSPrivacyAccessedAPITypes</key>
<array>
<string>NSPrivacyAccessedAPIMediaLibrary</string>
</array>
The code snippet to tap the button:
let systemAlerts = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let allowButton = systemAlerts.buttons["Allow"]
if allowButton.exists {
allowButton.tap()
}
What am I doing wrong here? I need access to MusicKit functionalities to write meaningful tests. Thank you