Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #31 from tomaculum/master
Browse files Browse the repository at this point in the history
update swift 5, add missing scopes, remove warnings
  • Loading branch information
marmelroy committed Jun 19, 2019
2 parents 8777cb7 + bf8a0b5 commit cb5a72e
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.0
5.0
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
osx_image: xcode9
osx_image: xcode10.2
language: objective-c
env:
global:
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
![SpotifyLogin - Swift 4 Framework for authenticating with the Spotify API ](https://user-images.githubusercontent.com/889949/28974990-b2eb0328-7938-11e7-9d19-1ff86d77324b.png)
![SpotifyLogin - Swift 5 Framework for authenticating with the Spotify API ](https://user-images.githubusercontent.com/889949/28974990-b2eb0328-7938-11e7-9d19-1ff86d77324b.png)

[![Build Status](https://travis-ci.org/spotify/SpotifyLogin.svg?branch=master)](https://travis-ci.org/spotify/SpotifyLogin)
[![Version](http://img.shields.io/cocoapods/v/SpotifyLogin.svg)](http://cocoapods.org/?q=SpotifyLogin)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)

# SpotifyLogin
SpotifyLogin is a Swift 4 Framework for authenticating with the Spotify API.
SpotifyLogin is a Swift 5 Framework for authenticating with the Spotify API.

Usage of this framework is bound under the [Developer Terms of Use](https://developer.spotify.com/developer-terms-of-use/).

Expand All @@ -17,14 +17,14 @@ SpotifyLogin is appropriate for prototyping and non-commercial use only.
**If your app is meant for commercial production usage, SpotifyLogin can NOT be used.**

### Compatibility
SpotifyLogin requires Xcode 9.0+. It is compatible with iOS 9 or later.
SpotifyLogin requires Xcode 10.2+. It is compatible with iOS 9 or later.

### Pre-requisites
You will need to register your app in the [Developer Portal](https://developer.spotify.com/my-applications/#!/applications).

Make sure to use a unique redirect url and to supply the bundle ID from your app.

After registering, you will receive a client ID and a client secret.
After registering, you will receive a client ID and a client secret.

### Set up SpotifyLogin

Expand Down
4 changes: 4 additions & 0 deletions Sources/Scope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ public enum Scope: String {
case userModifyPlaybackState = "user-modify-playback-state"
/// Read access to user's currently playing track
case userReadCurrentlyPlaying = "user-read-currently-playing"
/// Remote control playback of Spotify. This scope is currently available to Spotify iOS and Android App Remote SDKs
case appRemoteControl = "app-remote-control"
/// Upload a Custom Playlist Cover Image
case ugcImageUpload = "ugc-image-upload"
}
7 changes: 5 additions & 2 deletions Sources/SpotifyLogin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public class SpotifyLogin {
self.clientID = clientID
self.clientSecret = clientSecret
self.redirectURL = redirectURL
self.urlBuilder = URLBuilder(clientID: clientID, clientSecret: clientSecret, redirectURL: redirectURL, showDialog: showDialog!)
self.urlBuilder = URLBuilder(clientID: clientID,
clientSecret: clientSecret,
redirectURL: redirectURL,
showDialog: showDialog!)
}

/// Asynchronous call to retrieve the session's auth token. Automatically refreshes if auth token expired.
Expand Down Expand Up @@ -164,5 +167,5 @@ public enum LoginError: Error {

public extension Notification.Name {
/// A Notification that is emitted by SpotifyLogin after a successful login. Can be used to update the UI.
public static let SpotifyLoginSuccessful = Notification.Name("SpotifyLoginSuccessful")
static let SpotifyLoginSuccessful = Notification.Name("SpotifyLoginSuccessful")
}
3 changes: 2 additions & 1 deletion Sources/SpotifyLoginPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public class SpotifyLoginPresenter {
viewController.definesPresentationContext = true
let safariViewController: SFSafariViewController = SFSafariViewController(url: webAuthenticationURL)
safariViewController.modalPresentationStyle = .pageSheet
safariViewController.delegate = SafariDelegate()
let delegate = SafariDelegate()
safariViewController.delegate = delegate
viewController.present(safariViewController, animated: true, completion: nil)
SpotifyLogin.shared.safariVC = safariViewController
} else {
Expand Down
6 changes: 3 additions & 3 deletions SpotifyLogin.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
Pod::Spec.new do |s|
s.name = "SpotifyLogin"
s.version = "0.1.6"
s.summary = "Swift 4 Framework for authenticating with the Spotify API."
s.summary = "Swift 5 Framework for authenticating with the Spotify API."

# This description is used to generate tags and improve search results.
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
SpotifyLogin provides a modern Swift 4 Framework for authenticating with the Spotify API.
SpotifyLogin provides a modern Swift 5 Framework for authenticating with the Spotify API.
DESC

s.homepage = "https://github.com/spotify/SpotifyLogin"
Expand All @@ -27,7 +27,7 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/spotify/SpotifyLogin.git", :tag => s.version.to_s }
s.social_media_url = "http://twitter.com/marmelroy"

s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' }
s.pod_target_xcconfig = { 'SWIFT_VERSION' => '5.0' }

s.ios.deployment_target = '9.0'
s.requires_arc = true
Expand Down
13 changes: 7 additions & 6 deletions SpotifyLogin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -206,13 +206,13 @@
3479D2841EC1ADEE00FF4EE2 = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 2FNC3A47ZF;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
3479D28D1EC1ADEE00FF4EE2 = {
CreatedOnToolsVersion = 8.3.2;
DevelopmentTeam = 2FNC3A47ZF;
LastSwiftMigration = 0910;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
Expand All @@ -222,6 +222,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = 3479D27B1EC1ADEE00FF4EE2;
Expand Down Expand Up @@ -440,7 +441,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -461,7 +462,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.spotify.SpotifyLogin;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -474,7 +475,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.spotify.SpotifyLoginTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -487,7 +488,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.spotify.SpotifyLoginTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
15 changes: 12 additions & 3 deletions SpotifyLoginTests/SpotifyLoginTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ import XCTest
class SpotifyLoginTests: XCTestCase {

func testURLParsing() {
let urlBuilder = URLBuilder(clientID: "id", clientSecret: "secret", redirectURL: URL(string: "spotify.com")!, showDialog: false)
let urlBuilder = URLBuilder(clientID: "id",
clientSecret: "secret",
redirectURL: URL(string: "spotify.com")!,
showDialog: false)
// Parse valid url
let validURL = URL(string: "scheme://?code=spotify")!
let parsedValidURL = urlBuilder.parse(url: validURL)
Expand All @@ -32,7 +35,10 @@ class SpotifyLoginTests: XCTestCase {
}

func testCanHandleURL() {
let urlBuilder = URLBuilder(clientID: "id", clientSecret: "secret", redirectURL: URL(string: "spotify://")!, showDialog: false)
let urlBuilder = URLBuilder(clientID: "id",
clientSecret: "secret",
redirectURL: URL(string: "spotify://")!,
showDialog: false)
// Handle valid URL
let validURL = URL(string: "spotify://")!
XCTAssertTrue(urlBuilder.canHandleURL(validURL))
Expand All @@ -42,7 +48,10 @@ class SpotifyLoginTests: XCTestCase {
}

func testAuthenticationURL() {
let urlBuilder = URLBuilder(clientID: "id", clientSecret: "secret", redirectURL: URL(string: "spotify://")!, showDialog: false)
let urlBuilder = URLBuilder(clientID: "id",
clientSecret: "secret",
redirectURL: URL(string: "spotify://")!,
showDialog: false)
let webAuthenticationURL = urlBuilder.authenticationURL(type: .web, scopes: [])
XCTAssertNotNil(webAuthenticationURL)
let appAuthenticationURL = urlBuilder.authenticationURL(type: .app, scopes: [.streaming])
Expand Down
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# **** Update me when new Xcode versions are released! ****
PLATFORM="platform=iOS Simulator,OS=11.0,name=iPhone 7"
PLATFORM="platform=iOS Simulator,OS=12.0,name=iPhone 7"
SDK="iphonesimulator"


Expand Down

0 comments on commit cb5a72e

Please sign in to comment.