Peter-Schorn / SpotifyAPI

A Swift library for the Spotify web API. Supports all endpoints.
https://peter-schorn.github.io/SpotifyAPI/documentation/spotifywebapi
MIT License
251 stars 32 forks source link

Xcode Previews crash when using SpotifyAPI as a dependency #9

Closed Ivorforce closed 3 years ago

Ivorforce commented 3 years ago

Here's an odd one.

My previews currently aren't working. I've generated a diagnostics report and got this:

Error Domain=NSCocoaErrorDomain Code=516 "“resource_bundle_accessor.swift” couldn’t be linked to “Intermediates” because an item with the same name already exists." UserInfo={
    NSSourceFilePathErrorKey=/Users/lukas/Library/Developer/Xcode/DerivedData/ElevenTunes-gjysmmlfnagvqcginmznydrhcrcd/Build/Intermediates.noindex/Previews/ElevenTunes/Intermediates.noindex/SpotifyAPI.build/Debug/SpotifyExampleContent.build/DerivedSources/resource_bundle_accessor.swift, 
    NSUserStringVariant=(
        Link
    ), 
    NSDestinationFilePath=/var/folders/hz/m7z40m4x72d08f_7q265dn080000gn/T/previews-diagnostics-20210401-231950/Intermediates/resource_bundle_accessor.swift, 
    NSFilePath=/Users/lukas/Library/Developer/Xcode/DerivedData/ElevenTunes-gjysmmlfnagvqcginmznydrhcrcd/Build/Intermediates.noindex/Previews/ElevenTunes/Intermediates.noindex/SpotifyAPI.build/Debug/SpotifyExampleContent.build/DerivedSources/resource_bundle_accessor.swift, 
    NSUnderlyingError=0x7febb7518620 {Error Domain=NSPOSIXErrorDomain Code=17 "File exists"}
}

I've traced the error back and found this thread. Apparently, when declaring views referencing dependencies using Bundle.module, previews crash.

They have a workaround for this, where Bundle.module accesses are replaced. I'm not sure how this hasn't been addressed yet months later though...

Peter-Schorn commented 3 years ago

Are there any changes I can make to my library to fix it?

Ivorforce commented 3 years ago

I don't know if it works yet - I'll test it today - but as mentioned they do have a workaround where you replace Bundle.module accesses by a custom implementation. This would have to be applied everywhere in the repo.

Ivorforce commented 3 years ago

Yep, it works. I'll open an MR.

Peter-Schorn commented 3 years ago

Go ahead.

Ivorforce commented 3 years ago

I understand closing the PR, if you don't want to fix this now, but the issue persists. You still cannot render previews if depending on this API (to none of your own fault, mind you).

Peter-Schorn commented 3 years ago

I closed it because I assumed you had given up trying to find a solution. If you find one, then open another pull request. I'm always open to suggestions.