Peter-Schorn/SpotifyAPI

Xcode Previews crash when using SpotifyAPI as a dependency

Ivorforce opened this issue · 6 comments

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...

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

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.

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

Go ahead.

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).

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.