Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Swift 4.2 #45

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .swift-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0
4.2
8 changes: 4 additions & 4 deletions Simplicity.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

Pod::Spec.new do |s|
s.name = "Simplicity"
s.version = "2.0.1"
s.version = "2.0.4"
s.summary = "A simple way to login with Facebook or Google on iOS"

s.description = <<-DESC
Expand All @@ -15,13 +15,13 @@ Simplicity can be easily extended to support other external login providers, inc

DESC

s.homepage = "https://github.com/SimplicityMobile/Simplicity"
s.homepage = "https://github.com/ppaulojr/Simplicity"
s.license = 'Apache 2.0'
s.author = { "Edward Jiang" => "[email protected]" }
s.source = { :git => "https://github.com/SimplicityMobile/Simplicity.git", :tag => s.version.to_s }
s.source = { :git => "https://github.com/ppaulojr/Simplicity.git", :tag => s.version.to_s }
s.social_media_url = 'https://twitter.com/EdwardStarcraft'

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '9.0'

s.source_files = 'Simplicity/**/*.swift'

Expand Down
13 changes: 7 additions & 6 deletions Simplicity.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
);
mainGroup = DF74EC261CE2A8BB008F16BF;
Expand Down Expand Up @@ -254,7 +255,7 @@
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down Expand Up @@ -299,7 +300,7 @@
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
TARGETED_DEVICE_FAMILY = "1,2";
VALIDATE_PRODUCT = YES;
VERSIONING_SYSTEM = "apple-generic";
Expand All @@ -318,13 +319,13 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Simplicity/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stormpath.Simplicity;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -339,12 +340,12 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Simplicity/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.stormpath.Simplicity;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
6 changes: 3 additions & 3 deletions Simplicity/Helpers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class Helpers {
}

// Convert the complex dictionary into an array of URL schemes
let urlSchemes = urlTypes.flatMap({($0["CFBundleURLSchemes"] as? [String])?.first })
let urlSchemes = urlTypes.compactMap({($0["CFBundleURLSchemes"] as? [String])?.first })

return urlSchemes.flatMap({closure($0) ? $0 : nil})
return urlSchemes.compactMap({closure($0) ? $0 : nil})
}

/**
Expand All @@ -36,7 +36,7 @@ class Helpers {
- returns: A query string
*/
static func queryString(_ parts: [String: String?]) -> String? {
return parts.flatMap { key, value -> String? in
return parts.compactMap { key, value -> String? in
if let value = value {
return key + "=" + value
} else {
Expand Down
2 changes: 1 addition & 1 deletion Simplicity/LoginProviders/Facebook.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class Facebook: OAuth2 {
let range = urlScheme.range(of: "\\d+", options: .regularExpression) else {
preconditionFailure("You must configure your Facebook URL Scheme to use Facebook login.")
}
let clientId = urlScheme.substring(with: range)
let clientId = String(urlScheme[range])
let authorizationEndpoint = URL(string: "https://www.facebook.com/dialog/oauth")!
let redirectEndpoint = URL(string: urlScheme + "://authorize")!

Expand Down
2 changes: 1 addition & 1 deletion Simplicity/LoginProviders/VKontakte.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class VKontakte: OAuth2 {
let range = urlScheme.range(of: "\\d+", options: .regularExpression) else {
preconditionFailure("You must configure your VK URL Scheme to use VK login.")
}
let clientId = urlScheme.substring(with: range)
let clientId = String(urlScheme[range])
let authorizationEndpoint = URL(string: "https://oauth.vk.com/authorize")!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you have error about undeclared URL? because Foundation is not imported here.

let redirectEndpoint = URL(string: urlScheme + "://authorize")!

Expand Down
2 changes: 1 addition & 1 deletion Simplicity/OAuth2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class OAuth2: LoginProvider {

var url = URLComponents(url: authorizationEndpoint, resolvingAgainstBaseURL: false)!

url.queryItems = authorizationURLParameters.flatMap({key, value -> URLQueryItem? in
url.queryItems = authorizationURLParameters.compactMap({key, value -> URLQueryItem? in
return value != nil ? URLQueryItem(name: key, value: value) : nil
})

Expand Down
4 changes: 2 additions & 2 deletions Simplicity/Simplicity.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public final class Simplicity {
}

/// Deep link handler (iOS9)
public static func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool {
public static func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
safari?.dismiss(animated: true, completion: nil)
guard let callback = callback, url.scheme == currentLoginProvider?.urlScheme else {
return false
Expand All @@ -48,7 +48,7 @@ public final class Simplicity {

/// Deep link handler (<iOS9)
public static func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
return self.application(application, open: url, options: [UIApplicationOpenURLOptionsKey: Any]())
return self.application(application, open: url, options: [UIApplication.OpenURLOptionsKey: Any]())
}

private static func presentSafariView(_ url: URL) {
Expand Down