An intuitive and comprehensive Swift framework for the Spotify Web API.
Unfortunately this framework was built around Spotify's legacy iOS streaming SDK, which has since been replaced by their new metadata-focused SDK. As a result, this repository will be archived and will no longer be maintained.
- SpotifyKit is a protocol-oriented, value-type Spotify Web API wrapper that adheres to the Swift API Design Guidelines, providing streamlined interoperability between your Swift app and the entire Spotify catalog.
Compatible with Spotify's iOS SDK.
- In addition to accessing catalog content, SpotifyKit plays nicely with the Spotify iOS SDK, providing extensions and convenience methods for using SpotifyKit types with the Audio Playback and Authentication interface.
- SpotifyKit also streamlines the inclusion of the iOS SDK frameworks in your Swift application: just embed the dependencies into your project, include
SpotifyKitin your code, and you're good to go. No Objective-C, bridging headers, or frustrating compatibility issues to deal with.
⚠️ Important: This framework currently only supports an iOS deployment target of 10.3 or higher.
If you use Carthage to manage your project's dependencies, add the following line to your Cartfile:
github "haversnail/SpotifyKit" ~> 1.1and run carthage update to check out and build SpotifyKit and its dependencies.
Note that since the
spotify/ios-sdkrepository contains pre-compiled binaries instead of a buildable Xcode project, Carthage will skip the build process for this dependency.
Once the build process is finished, follow the rest of the Carthage installation steps and make sure you've linked the following frameworks to your project, taking note of where the different binaries are located:
| Framework | Path |
|---|---|
SpotifyKit.framework |
Carthage/Build/iOS/SpotifyKit/ |
SpotifyAudioPlayback.framework |
Carthage/Checkouts/ios-sdk/ |
SpotifyAuthentication.framework |
Carthage/Checkouts/ios-sdk/ |
And don't forget to link the AVFoundation.framework if you intend to use the Spotify Audio Playback interface.
✨ Coming soon to a repository near you! ✨
-
Check out or download the
haversnail/SpotifyKitrepository. -
Using Carthage, run
carthage bootstrap --no-buildfrom the repo's root directory. This will check out the iOS SDK dependency without attempting to build the already-built framework binaries.
- If for some reason you cannot use Carthage, you could download the contents of the SDK yourself, so long as those contents are copied to
Carthage/Checkouts/ios-sdk/from the SpotifyKit root directory.
- From the repo's root directory, run the following commands:
chmod +x modulemaps.sh
./modulemaps.shThis creates module maps for the newly checked-out frameworks, which should eliminate any initial "missing module" errors encountered in the Xcode project.
- Open the Xcode project and select "Product" > "Build" or press ⌘ + B. You're good to go! 👍
As of the
beta-25release, Spotify's pre-compiled iOS SDK frameworks have not been built as importable modules, which prevents Swift targets from using them out-of-the-box. However, SpotifyKit fixes this by checking for and creating module maps for each framework by running themodulemaps.shscript before each build. As explained above, you can run this script yourself if you come across any "missing module" errors while working with the frameworks.Alternatively, you can manually create these module maps by browsing to the respective
.frameworkfile, creating aModulesfolder, and within that folder, creating a file calledmodule.modulemapwith the following contents:framework module SpotifyAudioPlayback { // or `SpotifyAuthentication` umbrella header "SpotifyAudioPlayback.h" // ditto export * module * { export * } }
- 🛠 Check out the Xcode Playground for a detailed walkthrough of the SpotifyKit framework.
-
Add
Equatableconformance to all SpotifyKit value types (waiting on complete implementation of synthesizing Equatable and Hashable conformance in Swift 4.2 to ship with Xcode).- This would allow for something like:
public struct Page<Element>: OffsetPagingCollection { // ... } // Implementation can be synthesized at build time in Swift 4.2: extension Page: Equatable where Element: Equatable {}
-
Remove the
allproperty fromSKSearchResultTypeand instead conform it to the newCaseIterableprotocol in Swift 4.2. -
Add Audio Analysis type and related request methods.
-
Consider removing iOS SDK dependencies and migrating to an alternative authentication mechanism (cf. SpotifyLogin) for those wanting commercial use.
-
As pointed out by @slashmo, consider abstracting away the networking component into a separate framework/dependency altogether.
📋 See the contribution guidelines.
✌️ SpotifyKit was created by Alex Havermale.
⚖️ See LICENSE for more details.

