Skip to content

Commit

Permalink
Mike/platform support (#43)
Browse files Browse the repository at this point in the history
* get tvOS to compile

* get vision os to compile

* get mac catalyst to compile

* limit UI components to iOS, compiling on other platforms
  • Loading branch information
mikepitre authored Apr 11, 2024
1 parent 18d5265 commit e06ad27
Show file tree
Hide file tree
Showing 97 changed files with 155 additions and 106 deletions.
16 changes: 12 additions & 4 deletions ClerkDemo/ClerkDemo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
8F74DCDA2BC74C8700C7C5F6 /* ClerkDemo.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = ClerkDemo.entitlements; sourceTree = "<group>"; };
8F8116662B9BC35B00E2858C /* ClerkDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ClerkDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
8F8116692B9BC35B00E2858C /* ClerkDemoApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ClerkDemoApp.swift; sourceTree = "<group>"; };
8F81166D2B9BC35C00E2858C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -63,6 +64,7 @@
8F8116682B9BC35B00E2858C /* ClerkDemo */ = {
isa = PBXGroup;
children = (
8F74DCDA2BC74C8700C7C5F6 /* ClerkDemo.entitlements */,
8F8407862BA36ACB00218DB3 /* Info.plist */,
8F8116692B9BC35B00E2858C /* ClerkDemoApp.swift */,
8F81167E2B9BC45000E2858C /* HomeView.swift */,
Expand Down Expand Up @@ -304,6 +306,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ClerkDemo/ClerkDemo.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"ClerkDemo/Preview Content\"";
Expand All @@ -325,13 +328,15 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.clerk.ClerkDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,7";
TVOS_DEPLOYMENT_TARGET = 16.0;
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Debug;
};
Expand All @@ -340,6 +345,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = ClerkDemo/ClerkDemo.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"ClerkDemo/Preview Content\"";
Expand All @@ -361,13 +367,15 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.clerk.ClerkDemo;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator xros xrsimulator";
SUPPORTS_MACCATALYST = NO;
SUPPORTED_PLATFORMS = "appletvos appletvsimulator iphoneos iphonesimulator macosx xros xrsimulator";
SUPPORTS_MACCATALYST = YES;
SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD = NO;
SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2,3,7";
TVOS_DEPLOYMENT_TARGET = 16.0;
XROS_DEPLOYMENT_TARGET = 1.0;
};
name = Release;
};
Expand Down
14 changes: 14 additions & 0 deletions ClerkDemo/ClerkDemo/ClerkDemo.entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?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>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>keychain-access-groups</key>
<array>
<string>$(AppIdentifierPrefix)com.clerk.ClerkDemo</string>
</array>
</dict>
</plist>
2 changes: 2 additions & 0 deletions ClerkDemo/ClerkDemo/ClerkDemoApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ struct ClerkDemoApp: App {
var body: some Scene {
WindowGroup {
HomeView()
#if os(iOS)
.clerkProvider()
#endif
.task {
Clerk.shared.configure(publishableKey: publishableKey)
try? await Clerk.shared.load()
Expand Down
7 changes: 2 additions & 5 deletions ClerkDemo/ClerkDemo/DemoSpecific/DemoAppSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct DemoAppSettingsView: View {
}
.navigationTitle("Demo Settings")
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
ToolbarItem(placement: .primaryAction) {
Button(action: {
dismiss()
}, label: {
Expand All @@ -56,10 +56,7 @@ struct DemoAppSettingsView: View {
}
.overlay {
if isLoading {
ZStack {
Color(.systemBackground).opacity(0.5).ignoresSafeArea()
ProgressView()
}
ProgressView()
}
}
}
Expand Down
12 changes: 11 additions & 1 deletion ClerkDemo/ClerkDemo/HomeView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct HomeView: View {
var body: some View {
NavigationStack {
List {
#if os(iOS)
Section("Instructions:") {
Text("Create an account on [Clerk.com](https://www.clerk.com).")
Text("Create an app.")
Expand All @@ -22,21 +23,28 @@ struct HomeView: View {
Text("Tap the user button to get started.")
}
.font(.subheadline)
#else
Text("Clerk UI components are only supported on iOS (iPhone, iPad, Mac Catalyst), but you can still use the Clerk SDK to interact with the Clerk API on other platforms.")
#endif
}
.navigationTitle("Clerk Demo")
.toolbar {
ToolbarItem(placement: .topBarTrailing) {
ToolbarItem(placement: .primaryAction) {
#if os(iOS)
UserButton()
#endif
}
}
}
.overlay {
if clerk.loadingState == .notLoaded {
VStack {
Spacer()
#if os(iOS)
OrgLogoView()
.frame(width: 100, height: 100)
.padding()
#endif
Spacer()
Spacer()
}
Expand All @@ -45,7 +53,9 @@ struct HomeView: View {
.transition(.opacity.animation(.default))
}
}
#if os(iOS)
.demoSettings()
#endif
}
}

Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import PackageDescription

let package = Package(
name: "Clerk",
platforms: [.iOS(.v16), .macCatalyst(.v13), .macOS(.v13), .watchOS(.v9), .tvOS(.v16), .visionOS(.v1)],
platforms: [.iOS(.v16), .macCatalyst(.v16), .macOS(.v13), .watchOS(.v9), .tvOS(.v16), .visionOS(.v1)],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
Expand Down
2 changes: 2 additions & 0 deletions Sources/API/Models/ExternalAccount.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ extension ExternalAccount {

extension ExternalAccount {

#if !os(tvOS)
/// Invokes a re-authorization flow for an existing external account.
@MainActor
public func reauthorize() async throws {
Expand All @@ -107,6 +108,7 @@ extension ExternalAccount {
let authSession = ExternalAuthWebSession(url: url, authAction: .reauthorize)
try await authSession.start()
}
#endif

}

Expand Down
2 changes: 1 addition & 1 deletion Sources/API/Models/PhoneNumber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension PhoneNumber {
let phoneNumberKit = Container.shared.phoneNumberKit()
guard let phoneNumber = try? phoneNumberKit.parse(phoneNumber) else { return phoneNumber }

#if canImport(UIKit)
#if os(iOS)

if
let region = phoneNumber.regionID,
Expand Down
2 changes: 2 additions & 0 deletions Sources/API/Models/SignIn.swift
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ public struct SignIn: Codable, Sendable {
return response
}

#if !os(tvOS)
/// Signs in users via OAuth. This is commonly known as Single Sign On (SSO), where an external account is used for verifying the user's identity.
@MainActor
public func authenticateWithRedirect() async throws {
Expand All @@ -361,6 +362,7 @@ public struct SignIn: Codable, Sendable {
let authSession = ExternalAuthWebSession(url: url, authAction: .signIn)
try await authSession.start()
}
#endif
}

extension SignIn {
Expand Down
2 changes: 2 additions & 0 deletions Sources/API/Models/SignUp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ public struct SignUp: Codable, Sendable {
public let code: String
}

#if !os(tvOS)
/// Signs in users via OAuth. This is commonly known as Single Sign On (SSO), where an external account is used for verifying the user's identity.
@MainActor
public func authenticateWithRedirect() async throws {
Expand All @@ -304,6 +305,7 @@ public struct SignUp: Codable, Sendable {
let authSession = ExternalAuthWebSession(url: url, authAction: .signUp)
try await authSession.start()
}
#endif

/// Returns the current sign up.
@MainActor
Expand Down
4 changes: 4 additions & 0 deletions Sources/API/Utils/ExternalAuthWebSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by Mike Pitre on 10/19/23.
//

#if !os(tvOS)

import AuthenticationServices

@MainActor
Expand Down Expand Up @@ -105,3 +107,5 @@ extension ExternalAuthWebSession: ASWebAuthenticationPresentationContextProvidin

}

#endif

4 changes: 4 additions & 0 deletions Sources/API/Utils/LocalAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Created by Mike Pitre on 3/25/24.
//

#if !os(tvOS)

import Foundation
import SwiftUI
import LocalAuthentication
Expand Down Expand Up @@ -139,3 +141,5 @@ extension LABiometryType {
}

}

#endif
2 changes: 1 addition & 1 deletion Sources/UI/ClerkTheme.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 10/12/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down
4 changes: 3 additions & 1 deletion Sources/UI/ClerkUIState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
// Created by Mike Pitre on 10/25/23.
//

#if canImport(UIKit)
#if os(iOS)

import Foundation

public final class ClerkUIState: ObservableObject {

public init() {}

/// Is the auth view being displayed.
@Published public var authIsPresented = false

Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/AccordionView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 11/3/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/AsyncButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 10/4/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/AuthProviderButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 9/22/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI
import NukeUI
Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/AuthProviderIcon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 3/6/24.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI
import NukeUI
Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/AuthSocialProvidersView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 11/2/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI
import Algorithms
Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/CapsuleTag.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 11/8/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/CheckBoxView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 12/19/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/CodeFormView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 11/6/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/CustomTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 9/22/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down
2 changes: 1 addition & 1 deletion Sources/UI/Common/DismissButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 12/13/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down
9 changes: 2 additions & 7 deletions Sources/UI/Common/ErrorPresentation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Created by Mike Pitre on 12/11/23.
//

#if canImport(UIKit)
#if os(iOS)

import SwiftUI

Expand Down Expand Up @@ -72,12 +72,7 @@ extension View {
}

#Preview {
Color(.systemBackground)
.sheet(item: .constant(ErrorWrapper(error: ClerkClientError(message: "Password is incorrect. Try again, or use another method.")))) { errorWrapper in
ErrorView(errorWrapper: errorWrapper)
.presentationDetents([.height(250)])
.presentationDragIndicator(.visible)
}
ErrorView(errorWrapper: ErrorWrapper(error: ClerkClientError(message: "Password is incorrect. Try again, or use another method.")))
}

#endif
Loading

0 comments on commit e06ad27

Please sign in to comment.