Skip to content

Commit f9a7d53

Browse files
Merge pull request #310 from BalestraPatrick/xcframework
Add XCFramework
2 parents 447dfa2 + e51b77b commit f9a7d53

File tree

104 files changed

+4103
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+4103
-47
lines changed

DemoProjects/SPTLoginSampleApp/SPTLoginSampleApp/ViewController.m

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
// Copyright 2017-present Spotify AB
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
115
#import "ConnectView.h"
216
#import "ViewController.h"
317

@@ -18,12 +32,6 @@ - (void)viewDidLoad
1832
*/
1933
SPTConfiguration *configuration = [SPTConfiguration configurationWithClientID:SpotifyClientID
2034
redirectURL:[NSURL URLWithString:SpotifyRedirectURLString]];
21-
22-
// Set these url's to your backend which contains the secret to exchange for an access token
23-
// You can use the provided ruby script spotify_token_swap.rb for testing purposes
24-
configuration.tokenSwapURL = [NSURL URLWithString: @"http://localhost:1234/swap"];
25-
configuration.tokenRefreshURL = [NSURL URLWithString: @"http://localhost:1234/refresh"];
26-
2735
/*
2836
The session manager lets you authorize, get access tokens, and so on.
2937
*/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ Follow these steps to make sure you are prepared to start coding.
138138
139139
### Add Dependencies
140140
141-
1. Add the `SpotifyiOS.framework` to your Xcode project.
141+
1. Add the `SpotifyiOS.framework` or `SpotifyiOS.xcframework` to your Xcode project.
142142
143143
![Import SpotifyiOS.framework](img/import_sdk.png)
144144
-3.63 MB
Binary file not shown.

SpotifyiOS.xcframework/Info.plist

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>AvailableLibraries</key>
6+
<array>
7+
<dict>
8+
<key>LibraryIdentifier</key>
9+
<string>ios-arm64_armv7</string>
10+
<key>LibraryPath</key>
11+
<string>SpotifyiOS.framework</string>
12+
<key>SupportedArchitectures</key>
13+
<array>
14+
<string>arm64</string>
15+
<string>armv7</string>
16+
</array>
17+
<key>SupportedPlatform</key>
18+
<string>ios</string>
19+
</dict>
20+
<dict>
21+
<key>LibraryIdentifier</key>
22+
<string>ios-arm64_i386_x86_64-simulator</string>
23+
<key>LibraryPath</key>
24+
<string>SpotifyiOS.framework</string>
25+
<key>SupportedArchitectures</key>
26+
<array>
27+
<string>arm64</string>
28+
<string>i386</string>
29+
<string>x86_64</string>
30+
</array>
31+
<key>SupportedPlatform</key>
32+
<string>ios</string>
33+
<key>SupportedPlatformVariant</key>
34+
<string>simulator</string>
35+
</dict>
36+
</array>
37+
<key>CFBundlePackageType</key>
38+
<string>XFWK</string>
39+
<key>XCFrameworkFormatVersion</key>
40+
<string>1.0</string>
41+
</dict>
42+
</plist>
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@class SPTAppRemote;
4+
@class SPTAppRemoteConnectionParams;
5+
@class SPTConfiguration;
6+
7+
@protocol SPTAppRemoteImageAPI;
8+
@protocol SPTAppRemotePlayerAPI;
9+
@protocol SPTAppRemoteUserAPI;
10+
@protocol SPTAppRemoteContentAPI;
11+
12+
NS_ASSUME_NONNULL_BEGIN
13+
14+
extern NSString * const SPTAppRemoteAccessTokenKey;
15+
extern NSString * const SPTAppRemoteErrorDescriptionKey;
16+
17+
/// The severity of log messages that the App Remote should log to console.
18+
typedef NS_ENUM(NSUInteger, SPTAppRemoteLogLevel) {
19+
/// Do not log at all.
20+
SPTAppRemoteLogLevelNone = 0,
21+
/// Log debug, info and error messages.
22+
SPTAppRemoteLogLevelDebug = 1,
23+
/// Log info and error messages.
24+
SPTAppRemoteLogLevelInfo = 2,
25+
/// Log only error messages.
26+
SPTAppRemoteLogLevelError = 3,
27+
};
28+
29+
/**
30+
* The `SPTAppRemoteDelegate` receives updates from the `SPTAppRemote` whenever something has
31+
* happened with the connection.
32+
*/
33+
@protocol SPTAppRemoteDelegate <NSObject>
34+
35+
/**
36+
* Called when the App Remote has established connection with the Spotify app.
37+
*
38+
* @param appRemote The transport that has connected.
39+
*/
40+
- (void)appRemoteDidEstablishConnection:(SPTAppRemote *)appRemote;
41+
42+
/**
43+
* Called when the connection attempt made by the App Remote failed.
44+
*
45+
* @param appRemote The App Remote that failed to connect.
46+
* @param error The error that occurred.
47+
*/
48+
- (void)appRemote:(SPTAppRemote *)appRemote didFailConnectionAttemptWithError:(nullable NSError *)error;
49+
50+
/**
51+
* Called when the App Remote has disconnected.
52+
*
53+
* @note All APIs will be released by the App Remote at this point. The will no longer be usable,
54+
* and so you should release them as well.
55+
*
56+
* @param appRemote The App Remote that disconnected.
57+
* @param error The error that caused the disconnect, or `nil` if the disconnect was explicit.
58+
*/
59+
- (void)appRemote:(SPTAppRemote *)appRemote didDisconnectWithError:(nullable NSError *)error;
60+
61+
@end
62+
63+
/**
64+
* The `SPTAppRemote` is the main entry point for interacting with the Spotify app using the Spotify App Remote for iOS.
65+
*/
66+
@interface SPTAppRemote : NSObject
67+
68+
#pragma mark Lifecycle
69+
70+
/**
71+
* Convenience Initializer for a new App Remote instance
72+
*
73+
* @param configuration The `SPTConfiguration` to use for client-id's and redirect URLs
74+
* @param logLevel The lowest severity to log to console.
75+
*
76+
* @return A fresh new App Remote, ready to connect.
77+
*/
78+
- (instancetype)initWithConfiguration:(SPTConfiguration *)configuration logLevel:(SPTAppRemoteLogLevel)logLevel;
79+
80+
/**
81+
* Designated Initializer for a new App Remote instance
82+
*
83+
* @param configuration The `SPTConfiguration` to use for client-id's and redirect URLs
84+
* @param connectionParameters `SPTAppRemoteConnectionParams` for custom image sizes and types, and to hold the accessToken
85+
* @param logLevel The lowest severity to log to console.
86+
*
87+
* @return A fresh new App Remote, ready to connect.
88+
*/
89+
- (instancetype)initWithConfiguration:(SPTConfiguration *)configuration
90+
connectionParameters:(SPTAppRemoteConnectionParams *)connectionParameters
91+
logLevel:(SPTAppRemoteLogLevel)logLevel NS_DESIGNATED_INITIALIZER;
92+
#pragma mark Class Methods
93+
94+
/**
95+
* Checks if the Spotify app is active on the user's device. You can use this to determine if maybe you should prompt
96+
* the user to connect to Spotify (because you know they are already using Spotify if it is active). The Spotify app
97+
* will be considered active if music is playing or the app is active in the background.
98+
*
99+
* @param completion Completion block for determining the result of the check. YES if Spotify is active, othewise NO.
100+
*/
101+
+ (void)checkIfSpotifyAppIsActive:(void (^)(BOOL active))completion;
102+
103+
/**
104+
* Determine the current version of the Spotify App Remote
105+
*
106+
* @return The current version of the Spotify App Remote
107+
*/
108+
+ (NSString *)appRemoteVersion;
109+
110+
/**
111+
* The Spotify app iTunes item identifier for use with `SKStoreProductViewController` for installing Spotify from the App Store.
112+
*
113+
* @return An `NSNumber` representing the Spotify iTunes item identifier to be used for the `SKStoreProductParameterITunesItemIdentifier` key
114+
*/
115+
+ (NSNumber *)spotifyItunesItemIdentifier;
116+
117+
#pragma mark Connection
118+
119+
/**
120+
* The parameters to use during connection.
121+
*/
122+
@property (nonatomic, strong, readonly) SPTAppRemoteConnectionParams *connectionParameters;
123+
124+
/**
125+
* `YES` if the App Remote is connected to the Spotify application, otherwise `NO`.
126+
*
127+
* @note Not KVO’able.
128+
*
129+
* See The `SPTAppRemoteDelegate` in order to receive updates when the connection status changes.
130+
*/
131+
@property (nonatomic, assign, readonly, getter=isConnected) BOOL connected;
132+
133+
/**
134+
* The delegate to notify for connection status changes and other events originating from the App Remote.
135+
*/
136+
@property (nonatomic, weak) id<SPTAppRemoteDelegate> delegate;
137+
138+
/**
139+
* Attempts to connect to the Spotify application.
140+
*
141+
* @discussion If the Spotify app is not running you will need to use authorizeAndPlayURI: to wake it up
142+
*/
143+
- (void)connect;
144+
145+
/**
146+
* Disconnect from the Spotify application
147+
*/
148+
- (void)disconnect;
149+
150+
/**
151+
* Open Spotify app to obtain access token and start playback.
152+
*
153+
* @param URI The URI to play. Use a blank string to attempt to play the user's last song
154+
*
155+
* @return `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise `NO`.
156+
* Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
157+
* the Spotify app is installed and can attempt to handle the authorization request.
158+
*/
159+
- (BOOL)authorizeAndPlayURI:(NSString *)URI;
160+
161+
/**
162+
* Open Spotify app to obtain access token and start playback.
163+
*
164+
* @param playURI The URI to play. Use a blank string to attempt to play the user's last song
165+
* @param asRadio `YES` to start radio for the given URI.
166+
*
167+
* @return `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise `NO`.
168+
* Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
169+
* the Spotify app is installed and can attempt to handle the authorization request.
170+
*/
171+
- (BOOL)authorizeAndPlayURI:(NSString *)playURI asRadio:(BOOL)asRadio;
172+
173+
/**
174+
* Open Spotify app to obtain access token and start playback.
175+
*
176+
* @param playURI The URI to play. Use a blank string to attempt to play the user's last song
177+
* @param asRadio `YES` to start radio for the given URI.
178+
* @param additionalScopes An array of scopes in addition to `app-remote-control`. Can be nil if you only need `app-remote-control`
179+
*
180+
* @return `YES` if the Spotify app is installed and an authorization attempt can be made, otherwise `NO`.
181+
* Note: The return `BOOL` here is not a measure of whether or not authentication succeeded, only a check if
182+
* the Spotify app is installed and can attempt to handle the authorization request.
183+
*/
184+
- (BOOL)authorizeAndPlayURI:(NSString *)playURI
185+
asRadio:(BOOL)asRadio
186+
additionalScopes:(nullable NSArray<NSString *> *)additionalScopes;
187+
188+
/**
189+
* Parse out an access token or error description from a url passed to application:openURL:options:
190+
*
191+
* @param url The URL returned from the Spotify app after calling authorizeAndPlayURI
192+
*
193+
* @return A dictionary containing the access token or error description from the provided URL.
194+
* Will return nil if the URL Scheme does not match the redirect URI provided.
195+
* Use `SPTAppRemoteAccessTokenKey` and `SPTAppRemoteErrorDescriptionKey` to get the appropriate values.
196+
*/
197+
- (nullable NSDictionary<NSString *, NSString *> *)authorizationParametersFromURL:(NSURL *)url;
198+
199+
#pragma mark APIs
200+
201+
/**
202+
* The API used to control the Spotify player.
203+
*
204+
* @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
205+
* disconnect.
206+
*/
207+
@property (nullable, nonatomic, strong, readonly) id<SPTAppRemotePlayerAPI> playerAPI;
208+
209+
/**
210+
* The API used to fetch images from the Spotify app.
211+
*
212+
* @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
213+
* disconnect.
214+
*/
215+
@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteImageAPI> imageAPI;
216+
217+
/**
218+
* The API used to fetch user data from the Spotify app.
219+
*
220+
* @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
221+
* disconnect.
222+
*/
223+
@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteUserAPI> userAPI;
224+
225+
/**
226+
* The API used to fetch content from the Spotify app.
227+
*
228+
* @note Will only be populated when the App Remote is connected. If you retain this object you must release it on
229+
* disconnect.
230+
*/
231+
@property (nullable, nonatomic, strong, readonly) id<SPTAppRemoteContentAPI> contentAPI;
232+
233+
#pragma mark Unavailable initializers
234+
235+
- (instancetype)init NS_UNAVAILABLE;
236+
+ (instancetype)new NS_UNAVAILABLE;
237+
238+
@end
239+
240+
NS_ASSUME_NONNULL_END
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#import <Foundation/Foundation.h>
2+
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
/**
6+
* The `SPTAppRemoteAlbum` represents an Album entity.
7+
*/
8+
@protocol SPTAppRemoteAlbum <NSObject>
9+
10+
/// The name of the album.
11+
@property (nonatomic, copy, readonly) NSString *name;
12+
13+
/// The URI of the album.
14+
@property (nonatomic, copy, readonly) NSString *URI;
15+
16+
@end
17+
18+
NS_ASSUME_NONNULL_END
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#import <Foundation/Foundation.h>
2+
3+
NS_ASSUME_NONNULL_BEGIN
4+
5+
/**
6+
* The `SPTAppRemoteArtist` represents an artist.
7+
*/
8+
@protocol SPTAppRemoteArtist <NSObject>
9+
10+
/// The name of the artist.
11+
@property (nonatomic, copy, readonly) NSString *name;
12+
13+
/// The URI of the artist.
14+
@property (nonatomic, copy, readonly) NSString *URI;
15+
16+
@end
17+
18+
NS_ASSUME_NONNULL_END
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/**
2+
* Common header definitions
3+
*/
4+
5+
NS_ASSUME_NONNULL_BEGIN
6+
7+
/// The error domain for user facing errors that occur in the App Remote.
8+
extern NSString * const SPTAppRemoteErrorDomain;
9+
10+
/// The error codes in the `SPTAppRemoteErrorDomain` domain.
11+
typedef NS_ENUM(NSInteger, SPTAppRemoteErrorCode) {
12+
/// An unknown error.
13+
SPTAppRemoteUnknownError = -1,
14+
15+
/// The background wakeup of the Spotify app failed.
16+
SPTAppRemoteBackgroundWakeupFailedError = -1000,
17+
/// The connection attempt to the Spotify app failed.
18+
SPTAppRemoteConnectionAttemptFailedError = -1001,
19+
/// The conncetion to the Spotify app was terminated.
20+
SPTAppRemoteConnectionTerminatedError = -1002,
21+
/// The arguments supplied are invalid.
22+
SPTAppRemoteInvalidArgumentsError = -2000,
23+
/// The request has failed for some reason.
24+
SPTAppRemoteRequestFailedError = -2001,
25+
};
26+
27+
/**
28+
* A callback block used by many App Remote API methods.
29+
*
30+
* @param result The result of the operation, or `nil` if the operation failed.
31+
* @param error An error object, or `nil` if the operation was a success.
32+
*/
33+
typedef void (^SPTAppRemoteCallback)(id _Nullable result, NSError * _Nullable error);
34+
35+
NS_ASSUME_NONNULL_END
36+

0 commit comments

Comments
 (0)