An intuitive and comprehensive Swift framework for the Spotify Web API.
⛔ DEPRECATED
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.
Getting Started
"Why Should I Use This?"
The entire Spotify catalog, at your disposal.
- 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.
iOS SDK.
Compatible with Spotify's- 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.
Integrate with ease.
- SpotifyKit also streamlines the inclusion of the iOS SDK frameworks in your Swift application: just embed the dependencies into your project, include
SpotifyKit
in your code, and you're good to go. No Objective-C, bridging headers, or frustrating compatibility issues to deal with.
Installation
⚠️ Important: This framework currently only supports an iOS deployment target of 10.3 or higher.
Carthage
If you use Carthage to manage your project's dependencies, add the following line to your Cartfile
:
github "haversnail/SpotifyKit" ~> 1.1
and run carthage update
to check out and build SpotifyKit and its dependencies.
Note that since the
spotify/ios-sdk
repository 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.
CocoaPods
✨ Coming soon to a repository near you! ✨
Manual Setup
-
Check out or download the
haversnail/SpotifyKit
repository. -
Using Carthage, run
carthage bootstrap --no-build
from 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.sh
This 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! 👍
A Note on Module Maps
As of the
beta-25
release, 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.sh
script 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
.framework
file, creating aModules
folder, and within that folder, creating a file calledmodule.modulemap
with the following contents:framework module SpotifyAudioPlayback { // or `SpotifyAuthentication` umbrella header "SpotifyAudioPlayback.h" // ditto export * module * { export * } }
Usage
Examples
- 🛠 Check out the Xcode Playground for a detailed walkthrough of the SpotifyKit framework.
Documentation
Roadmap
Current stable release:
Pending future release:
-
Add
Equatable
conformance 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
all
property fromSKSearchResultType
and instead conform it to the newCaseIterable
protocol 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.
Contributing
📋 See the contribution guidelines.
Credits
✌️ SpotifyKit was created by Alex Havermale.
License
⚖️ See LICENSE for more details.