Skip to content

Commit

Permalink
Merge pull request #310 from BalestraPatrick/xcframework
Browse files Browse the repository at this point in the history
Add XCFramework
  • Loading branch information
danielgronlund committed Feb 17, 2021
2 parents 447dfa2 + e51b77b commit f9a7d53
Show file tree
Hide file tree
Showing 104 changed files with 4,103 additions and 47 deletions.
20 changes: 14 additions & 6 deletions DemoProjects/SPTLoginSampleApp/SPTLoginSampleApp/ViewController.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
// Copyright 2017-present Spotify AB
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#import "ConnectView.h"
#import "ViewController.h"

Expand All @@ -18,12 +32,6 @@ - (void)viewDidLoad
*/
SPTConfiguration *configuration = [SPTConfiguration configurationWithClientID:SpotifyClientID
redirectURL:[NSURL URLWithString:SpotifyRedirectURLString]];

// Set these url's to your backend which contains the secret to exchange for an access token
// You can use the provided ruby script spotify_token_swap.rb for testing purposes
configuration.tokenSwapURL = [NSURL URLWithString: @"http://localhost:1234/swap"];
configuration.tokenRefreshURL = [NSURL URLWithString: @"http://localhost:1234/refresh"];

/*
The session manager lets you authorize, get access tokens, and so on.
*/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Follow these steps to make sure you are prepared to start coding.
### Add Dependencies
1. Add the `SpotifyiOS.framework` to your Xcode project.
1. Add the `SpotifyiOS.framework` or `SpotifyiOS.xcframework` to your Xcode project.
![Import SpotifyiOS.framework](img/import_sdk.png)
Expand Down
Binary file modified SpotifyiOS.framework/Versions/A/SpotifyiOS
Binary file not shown.
42 changes: 42 additions & 0 deletions SpotifyiOS.xcframework/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>AvailableLibraries</key>
<array>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_armv7</string>
<key>LibraryPath</key>
<string>SpotifyiOS.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>armv7</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
</dict>
<dict>
<key>LibraryIdentifier</key>
<string>ios-arm64_i386_x86_64-simulator</string>
<key>LibraryPath</key>
<string>SpotifyiOS.framework</string>
<key>SupportedArchitectures</key>
<array>
<string>arm64</string>
<string>i386</string>
<string>x86_64</string>
</array>
<key>SupportedPlatform</key>
<string>ios</string>
<key>SupportedPlatformVariant</key>
<string>simulator</string>
</dict>
</array>
<key>CFBundlePackageType</key>
<string>XFWK</string>
<key>XCFrameworkFormatVersion</key>
<string>1.0</string>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
#import <Foundation/Foundation.h>

@class SPTAppRemote;
@class SPTAppRemoteConnectionParams;
@class SPTConfiguration;

@protocol SPTAppRemoteImageAPI;
@protocol SPTAppRemotePlayerAPI;
@protocol SPTAppRemoteUserAPI;
@protocol SPTAppRemoteContentAPI;

NS_ASSUME_NONNULL_BEGIN

extern NSString * const SPTAppRemoteAccessTokenKey;
extern NSString * const SPTAppRemoteErrorDescriptionKey;

/// The severity of log messages that the App Remote should log to console.
typedef NS_ENUM(NSUInteger, SPTAppRemoteLogLevel) {
/// Do not log at all.
SPTAppRemoteLogLevelNone = 0,
/// Log debug, info and error messages.
SPTAppRemoteLogLevelDebug = 1,
/// Log info and error messages.
SPTAppRemoteLogLevelInfo = 2,
/// Log only error messages.
SPTAppRemoteLogLevelError = 3,
};

/**
* The `SPTAppRemoteDelegate` receives updates from the `SPTAppRemote` whenever something has
* happened with the connection.
*/
@protocol SPTAppRemoteDelegate <NSObject>

/**
* Called when the App Remote has established connection with the Spotify app.
*
* @param appRemote The transport that has connected.
*/
- (void)appRemoteDidEstablishConnection:(SPTAppRemote *)appRemote;

/**
* Called when the connection attempt made by the App Remote failed.
*
* @param appRemote The App Remote that failed to connect.
* @param error The error that occurred.
*/
- (void)appRemote:(SPTAppRemote *)appRemote didFailConnectionAttemptWithError:(nullable NSError *)error;

/**
* Called when the App Remote has disconnected.
*
* @note All APIs will be released by the App Remote at this point. The will no longer be usable,
* and so you should release them as well.
*
* @param appRemote The App Remote that disconnected.
* @param error The error that caused the disconnect, or `nil` if the disconnect was explicit.
*/
- (void)appRemote:(SPTAppRemote *)appRemote didDisconnectWithError:(nullable NSError *)error;

@end

/**
* The `SPTAppRemote` is the main entry point for interacting with the Spotify app using the Spotify App Remote for iOS.
*/
@interface SPTAppRemote : NSObject

#pragma mark Lifecycle

/**
* Convenience Initializer for a new App Remote instance
*
* @param configuration The `SPTConfiguration` to use for client-id's and redirect URLs
* @param logLevel The lowest severity to log to console.
*
* @return A fresh new App Remote, ready to connect.
*/
- (instancetype)initWithConfiguration:(SPTConfiguration *)configuration logLevel:(SPTAppRemoteLogLevel)logLevel;

/**
* Designated Initializer for a new App Remote instance
*
* @param configuration The `SPTConfiguration` to use for client-id's and redirect URLs
* @param connectionParameters `SPTAppRemoteConnectionParams` for custom image sizes and types, and to hold the accessToken
* @param logLevel The lowest severity to log to console.
*
* @return A fresh new App Remote, ready to connect.
*/
- (instancetype)initWithConfiguration:(SPTConfiguration *)configuration
connectionParameters:(SPTAppRemoteConnectionParams *)connectionParameters
logLevel:(SPTAppRemoteLogLevel)logLevel NS_DESIGNATED_INITIALIZER;
#pragma mark Class Methods

/**
* Checks if the Spotify app is active on the user's device. You can use this to determine if maybe you should prompt
* the user to connect to Spotify (because you know they are already using Spotify if it is active). The Spotify app
* will be considered active if music is playing or the app is active in the background.
*
* @param completion Completion block for determining the result of the check. YES if Spotify is active, othewise NO.
*/
+ (void)checkIfSpotifyAppIsActive:(void (^)(BOOL active))completion;

/**
* Determine the current version of the Spotify App Remote
*
* @return The current version of the Spotify App Remote
*/
+ (NSString *)appRemoteVersion;

/**
* The Spotify app iTunes item identifier for use with `SKStoreProductViewController` for installing Spotify from the App Store.
*
* @return An `NSNumber` representing the Spotify iTunes item identifier to be used for the `SKStoreProductParameterITunesItemIdentifier` key
*/
+ (NSNumber *)spotifyItunesItemIdentifier;

#pragma mark Connection

/**
* The parameters to use during connection.
*/
@property (nonatomic, strong, readonly) SPTAppRemoteConnectionParams *connectionParameters;

/**
* `YES` if the App Remote is connected to the Spotify application, otherwise `NO`.
*
* @note Not KVO’able.
*
* See The `SPTAppRemoteDelegate` in order to receive updates when the connection status changes.
*/
@property (nonatomic, assign, readonly, getter=isConnected) BOOL connected;

/**
* The delegate to notify for connection status changes and other events originating from the App Remote.
*/
@property (nonatomic, weak) id<SPTAppRemoteDelegate> delegate;

/**
* Attempts to connect to the Spotify application.
*
* @discussion If the Spotify app is not running you will need to use authorizeAndPlayURI: to wake it up
*/
- (void)connect;

/**
* Disconnect from the Spotify application
*/
- (void)disconnect;

/**
* Open Spotify app to obtain access token and start playback.
*
* @param URI The URI to play. Use a blank string to attempt to play the user's last song
*
* @return `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise `NO`.
* Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
* the Spotify app is installed and can attempt to handle the authorization request.
*/
- (BOOL)authorizeAndPlayURI:(NSString *)URI;

/**
* Open Spotify app to obtain access token and start playback.
*
* @param playURI The URI to play. Use a blank string to attempt to play the user's last song
* @param asRadio `YES` to start radio for the given URI.
*
* @return `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise `NO`.
* Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
* the Spotify app is installed and can attempt to handle the authorization request.
*/
- (BOOL)authorizeAndPlayURI:(NSString *)playURI asRadio:(BOOL)asRadio;

/**
* Open Spotify app to obtain access token and start playback.
*
* @param playURI The URI to play. Use a blank string to attempt to play the user's last song
* @param asRadio `YES` to start radio for the given URI.
* @param additionalScopes An array of scopes in addition to `app-remote-control`. Can be nil if you only need `app-remote-control`
*
* @return `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise `NO`.
* Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
* the Spotify app is installed and can attempt to handle the authorization request.
*/
- (BOOL)authorizeAndPlayURI:(NSString *)playURI
asRadio:(BOOL)asRadio
additionalScopes:(nullable NSArray<NSString *> *)additionalScopes;

/**
* Parse out an access token or error description from a url passed to application:openURL:options:
*
* @param url The URL returned from the Spotify app after calling authorizeAndPlayURI
*
* @return A dictionary containing the access token or error description from the provided URL.
* Will return nil if the URL Scheme does not match the redirect URI provided.
* Use `SPTAppRemoteAccessTokenKey` and `SPTAppRemoteErrorDescriptionKey` to get the appropriate values.
*/
- (nullable NSDictionary<NSString *, NSString *> *)authorizationParametersFromURL:(NSURL *)url;

#pragma mark APIs

/**
* The API used to control the Spotify player.
*
* @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
* disconnect.
*/
@property (nullable, nonatomic, strong, readonly) id<SPTAppRemotePlayerAPI> playerAPI;

/**
* The API used to fetch images from the Spotify app.
*
* @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
* disconnect.
*/
@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteImageAPI> imageAPI;

/**
* The API used to fetch user data from the Spotify app.
*
* @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
* disconnect.
*/
@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteUserAPI> userAPI;

/**
* The API used to fetch content from the Spotify app.
*
* @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
* disconnect.
*/
@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteContentAPI> contentAPI;

#pragma mark Unavailable initializers

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* The `SPTAppRemoteAlbum` represents an Album entity.
*/
@protocol SPTAppRemoteAlbum <NSObject>

/// The name of the album.
@property (nonatomic, copy, readonly) NSString *name;

/// The URI of the album.
@property (nonatomic, copy, readonly) NSString *URI;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* The `SPTAppRemoteArtist` represents an artist.
*/
@protocol SPTAppRemoteArtist <NSObject>

/// The name of the artist.
@property (nonatomic, copy, readonly) NSString *name;

/// The URI of the artist.
@property (nonatomic, copy, readonly) NSString *URI;

@end

NS_ASSUME_NONNULL_END
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Common header definitions
*/

NS_ASSUME_NONNULL_BEGIN

/// The error domain for user facing errors that occur in the App Remote.
extern NSString * const SPTAppRemoteErrorDomain;

/// The error codes in the `SPTAppRemoteErrorDomain` domain.
typedef NS_ENUM(NSInteger, SPTAppRemoteErrorCode) {
/// An unknown error.
SPTAppRemoteUnknownError = -1,

/// The background wakeup of the Spotify app failed.
SPTAppRemoteBackgroundWakeupFailedError = -1000,
/// The connection attempt to the Spotify app failed.
SPTAppRemoteConnectionAttemptFailedError = -1001,
/// The conncetion to the Spotify app was terminated.
SPTAppRemoteConnectionTerminatedError = -1002,
/// The arguments supplied are invalid.
SPTAppRemoteInvalidArgumentsError = -2000,
/// The request has failed for some reason.
SPTAppRemoteRequestFailedError = -2001,
};

/**
* A callback block used by many App Remote API methods.
*
* @param result The result of the operation, or `nil` if the operation failed.
* @param error An error object, or `nil` if the operation was a success.
*/
typedef void (^SPTAppRemoteCallback)(id _Nullable result, NSError * _Nullable error);

NS_ASSUME_NONNULL_END

Loading

0 comments on commit f9a7d53

Please sign in to comment.