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

feat: added support for visionOS platform #859

Merged
merged 22 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
13c54dd
feat: added visionOS target, test target and a sample app
desusai7 Jun 20, 2024
511b789
feat: updated code to support visionOS as a platform
desusai7 Jun 20, 2024
8c16d16
Merge branch 'master' into feature/supportVisionOS
desusai7 Jun 20, 2024
b438c62
test: upgraded quick & nimble to latest versions and updated code to …
desusai7 Jun 25, 2024
b988913
test: replaced OHHTTPStubs with our custom implementation for stubbin…
desusai7 Jun 27, 2024
dc453f1
chore: updated build settings of visionos target, test target, sample…
desusai7 Jun 27, 2024
0939c82
fix: removed SFSafariViewController as a provider for visionos as its…
desusai7 Jul 1, 2024
1b609eb
chore: upgraded all the gems to the latest versions
desusai7 Jul 3, 2024
6c53e9c
chore: added custom networking stubs to be available for tvos test ta…
desusai7 Jul 3, 2024
1099e36
chore: added arm64-darwin-22 as a supported platform
desusai7 Jul 3, 2024
be64bfb
chore: bumped up the dependency on Quick & Nimble in Package.swift
desusai7 Jul 3, 2024
76afe51
chore: dropped support for xcode 14, swift versions [5.7, 5.8], iOS 1…
desusai7 Jul 3, 2024
48e3524
test: minor changes
desusai7 Jul 3, 2024
67249f1
chore: removed reference to Auth0.plist in sample iOS app
desusai7 Jul 3, 2024
c6b834c
chore: added cwlPreCondition swift package to tvOS tests
desusai7 Jul 4, 2024
bcb1db5
test: removed sharedExamples with Behavior from Quick
desusai7 Jul 4, 2024
59e152e
chore: removed references to OHHTTPStubs across the repository
desusai7 Jul 4, 2024
88ef7f5
chore: updated support policy in the readme
desusai7 Jul 4, 2024
de437dc
chore: added conditional blocks for visionOS as required
desusai7 Jul 4, 2024
a8727dd
chore: minor changes
desusai7 Jul 4, 2024
2479461
chore: upgraded versions of SimpleKeychain & JWTDecode.swift to beta …
desusai7 Jul 4, 2024
9acf0da
chore: addressed review comments
desusai7 Jul 5, 2024
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
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ jobs:

pod-lint:
name: Lint podspec using Xcode ${{ matrix.xcode }}
runs-on: macos-13
runs-on: macos-13-xlarge

strategy:
matrix:
xcode:
- '15.0.1'
- '15.2'

steps:
- name: Checkout
Expand Down
16 changes: 10 additions & 6 deletions Auth0.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Pod::Spec.new do |s|
s.version = '2.8.0'
s.summary = "Auth0 SDK for Apple platforms"
s.description = <<-DESC
Auth0 SDK for iOS, macOS, tvOS, and watchOS apps.
Auth0 SDK for iOS, macOS, tvOS, watchOS and visionOS apps.
DESC
s.homepage = 'https://github.com/auth0/Auth0.swift'
s.license = 'MIT'
Expand All @@ -42,22 +42,26 @@ Pod::Spec.new do |s|
s.social_media_url = 'https://twitter.com/auth0'
s.source_files = 'Auth0/*.swift'
s.resource_bundles = { s.name => 'Auth0/PrivacyInfo.xcprivacy' }
s.swift_versions = ['5.7', '5.8']
s.swift_versions = ['5.9']

s.dependency 'SimpleKeychain', '~> 1.1'
s.dependency 'JWTDecode', '~> 3.1'
s.dependency 'SimpleKeychain', '1.2.0-beta.0'
s.dependency 'JWTDecode', '3.2.0-beta.0'

s.ios.deployment_target = '13.0'
s.ios.deployment_target = '14.0'
s.ios.exclude_files = macos_files
s.ios.pod_target_xcconfig = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM' }

s.osx.deployment_target = '11.0'
s.osx.exclude_files = ios_files
s.osx.pod_target_xcconfig = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM' }

s.tvos.deployment_target = '13.0'
s.tvos.deployment_target = '14.0'
s.tvos.exclude_files = excluded_files

s.watchos.deployment_target = '7.0'
s.watchos.exclude_files = excluded_files

s.visionos.deployment_target = '1.0'
s.visionos.exclude_files = macos_files
s.visionos.pod_target_xcconfig = { 'SWIFT_ACTIVE_COMPILATION_CONDITIONS' => 'WEB_AUTH_PLATFORM' }
end
873 changes: 842 additions & 31 deletions Auth0.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 67 additions & 0 deletions Auth0.xcodeproj/xcshareddata/xcschemes/Auth0.visionOS.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1B3B9BF2C24B39E004A32A4"
BuildableName = "Auth0.framework"
BlueprintName = "Auth0.visionOS"
ReferencedContainer = "container:Auth0.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "C1B3B9BF2C24B39E004A32A4"
BuildableName = "Auth0.framework"
BlueprintName = "Auth0.visionOS"
ReferencedContainer = "container:Auth0.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion Auth0/ASProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ extension WebAuthentication {
let session: ASWebAuthenticationSession

#if compiler(>=5.10)
if #available(iOS 17.4, macOS 14.4, *) {
if #available(iOS 17.4, macOS 14.4, visionOS 1.2, *) {
if redirectURL.scheme == "https" {
session = ASWebAuthenticationSession(url: url,
callback: .https(host: redirectURL.host!,
Expand Down
4 changes: 3 additions & 1 deletion Auth0/Auth0WebAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ final class Auth0WebAuth: WebAuth {

#if os(macOS)
private let platform = "macos"
#else
#elseif os(iOS)
private let platform = "ios"
#else
private let platform = "visionos"
#endif
private let responseType = "code"

Expand Down
21 changes: 16 additions & 5 deletions Auth0/MobileWebAuth.swift
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
#if os(iOS)
#if os(iOS) || os(visionOS)
import UIKit
import AuthenticationServices

extension UIApplication {

Check warning on line 6 in Auth0/MobileWebAuth.swift

View workflow job for this annotation

GitHub Actions / Lint code with SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
static func shared() -> UIApplication? {
return UIApplication.perform(NSSelectorFromString("sharedApplication"))?.takeUnretainedValue() as? UIApplication
}

Check warning on line 10 in Auth0/MobileWebAuth.swift

View workflow job for this annotation

GitHub Actions / Lint code with SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
}

extension ASUserAgent: ASWebAuthenticationPresentationContextProviding {


Check warning on line 14 in Auth0/MobileWebAuth.swift

View workflow job for this annotation

GitHub Actions / Lint code with SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
#if os(iOS)
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
return UIApplication.shared()?.windows.last(where: \.isKeyWindow) ?? ASPresentationAnchor()
}

#endif

Check warning on line 20 in Auth0/MobileWebAuth.swift

View workflow job for this annotation

GitHub Actions / Lint code with SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
#if os(visionOS)
func presentationAnchor(for session: ASWebAuthenticationSession) -> ASPresentationAnchor {
if let windowScene = UIApplication.shared()?.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
return windowScene.windows.last(where: \.isKeyWindow) ?? ASPresentationAnchor()
}
return ASPresentationAnchor()
}
#endif

}
#endif
2 changes: 2 additions & 0 deletions Auth0/Telemetry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public struct Telemetry {
return "tvOS"
#elseif os(watchOS)
return "watchOS"
#elseif os(visionOS)
return "visionOS"
#else
return "unknown"
#endif
Expand Down
39 changes: 19 additions & 20 deletions Auth0Tests/ASProviderSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,74 +11,73 @@ private let CustomSchemeRedirectURL = URL(string: "com.auth0.example://samples.a
private let Timeout: NimbleTimeInterval = .seconds(2)

class ASProviderSpec: QuickSpec {

override func spec() {

override class func spec() {
var session: ASWebAuthenticationSession!
var userAgent: ASUserAgent!

beforeEach {
session = ASWebAuthenticationSession(url: AuthorizeURL, callbackURLScheme: nil, completionHandler: { _, _ in })
userAgent = ASUserAgent(session: session, callback: { _ in })
}

afterEach {
session.cancel()
}

describe("WebAuthentication extension") {

it("should create a web authentication session provider") {
let provider = WebAuthentication.asProvider(redirectURL: HTTPSRedirectURL)
expect(provider(AuthorizeURL, {_ in })).to(beAKindOf(ASUserAgent.self))
}

it("should not use an ephemeral session by default") {
let provider = WebAuthentication.asProvider(redirectURL: CustomSchemeRedirectURL)
userAgent = provider(AuthorizeURL, { _ in }) as? ASUserAgent
expect(userAgent.session.prefersEphemeralWebBrowserSession) == false
}

it("should use an ephemeral session") {
let provider = WebAuthentication.asProvider(redirectURL: CustomSchemeRedirectURL, ephemeralSession: true)
userAgent = provider(AuthorizeURL, { _ in }) as? ASUserAgent
expect(userAgent.session.prefersEphemeralWebBrowserSession) == true
}

}

describe("user agent") {

it("should have a custom description") {
expect(userAgent.description) == "ASWebAuthenticationSession"
}

it("should be the web authentication session's presentation context provider") {
expect(session.presentationContextProvider).to(be(userAgent))
}

it("should call the callback with an error") {
await waitUntil(timeout: Timeout) { done in
waitUntil(timeout: Timeout) { done in
let userAgent = ASUserAgent(session: session, callback: { result in
expect(result).to(beFailure())
done()
})
userAgent.finish(with: .failure(.userCancelled))
}
}

it("should call the callback with success") {
await waitUntil(timeout: Timeout) { done in
waitUntil(timeout: Timeout) { done in
let userAgent = ASUserAgent(session: session, callback: { result in
expect(result).to(beSuccessful())
done()
})
userAgent.finish(with: .success(()))
}
}

}

}

}
2 changes: 1 addition & 1 deletion Auth0Tests/Auth0Spec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ private let Token = "TOKEN"

class Auth0Spec: QuickSpec {

override func spec() {
override class func spec() {

describe("global functions") {

Expand Down
Loading
Loading