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

SpotifyExampleContent included in my app #25

Closed toothbrush closed 3 years ago

toothbrush commented 3 years ago

I'm not sure if this is something i can control as a project consuming your library, but i noticed that when i use Product > Archive to create a .app bundle which i can distribute, it contains lots of files as follows:

$ zip -r Spotiqueue.zip Spotiqueue.app 
...
  adding: Spotiqueue.app/Contents/Resources/SpotifyAPI_SpotifyExampleContent.bundle/ (stored 0%)
  adding: Spotiqueue.app/Contents/Resources/SpotifyAPI_SpotifyExampleContent.bundle/Contents/ (stored 0%)
  adding: Spotiqueue.app/Contents/Resources/SpotifyAPI_SpotifyExampleContent.bundle/Contents/Resources/ (stored 0%)
  adding: Spotiqueue.app/Contents/Resources/SpotifyAPI_SpotifyExampleContent.bundle/Contents/Resources/Sam Harris - Show.json (deflated 81%)
...

Is it possible to configure my project to exclude that part of your library? Or is it something caused by this setting?

https://github.com/Peter-Schorn/SpotifyAPI/blob/1e37a426f5198cc4bde71ccdd434a7b187809d9c/Package.swift#L13

Peter-Schorn commented 3 years ago

Do you import the SpotifyExampleContent module anywhere?

toothbrush commented 3 years ago

Nope! I have run grep on my entire project, and i don't find mentions of it. Is it because of the way i'm importing SpotifyAPI, as a Swift package manager module? (I don't know if it helps, but the project is https://github.com/toothbrush/Spotiqueue)

Peter-Schorn commented 3 years ago

Both the SpotifyExampleContent and SpotifyWebAPI targets are part of the SpotifyAPI library:

https://github.com/Peter-Schorn/SpotifyAPI/blob/1e37a426f5198cc4bde71ccdd434a7b187809d9c/Package.swift#L11-L14

As shown below, package products are linked against projects on a per-library basis, not a per-target basis. There may still be a way to exclude these resources from your app, but I'm not sure how.

Screen Shot 2021-06-16 at 11 25 31 PM

Notice that the "Link Libraries with Binaries" section contains the SpotifyAPI library, not the targets.

Peter-Schorn commented 3 years ago

If you're really concerned about these resources ballooning the size of your app (how much space do they take up in total?), you could fork my library and remove them straight from the source. Let me know if this is something you're interested in.

toothbrush commented 3 years ago

Fair enough! I don't think it's making a big difference to my final binary size at all, i just thought i'd ask if i'm doing something wrong or whether this is intentional. Stupid question maybe, but is it simply possible to remove "SpotifyExampleContent" from the package definition?

https://github.com/Peter-Schorn/SpotifyAPI/blob/1e37a426f5198cc4bde71ccdd434a7b187809d9c/Package.swift#L13

Peter-Schorn commented 3 years ago

Yes, you can do that in your fork. It's that module which contains the resources.