Skip to content

Commit

Permalink
docs: add UserManagement example (#161)
Browse files Browse the repository at this point in the history
* docs: add UserManagement example

* Remove ProductSample folder

* Build examples on CI
  • Loading branch information
grdsdev authored Nov 17, 2023
1 parent e8ba6d1 commit 42e94b2
Show file tree
Hide file tree
Showing 21 changed files with 654 additions and 17 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,14 @@ jobs:
run: sudo xcode-select -s /Applications/Xcode_14.3.app
- name: Run tests
run: make test-library

examples:
runs-on: macos-13
name: Build Examples
steps:
- uses: actions/checkout@v3
- name: Select Xcode 14.3
run: sudo xcode-select -s /Applications/Xcode_14.3.app
- name: Build examples
run: make build-examples

203 changes: 203 additions & 0 deletions Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
796298992AEBBA77000AA957 /* MFAFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 796298982AEBBA77000AA957 /* MFAFlow.swift */; };
7962989D2AEBC6F9000AA957 /* SVGView in Frameworks */ = {isa = PBXBuildFile; productRef = 7962989C2AEBC6F9000AA957 /* SVGView */; };
79719ECE2ADF26C400737804 /* Supabase in Frameworks */ = {isa = PBXBuildFile; productRef = 79719ECD2ADF26C400737804 /* Supabase */; };
79FEFFAF2B07873600D36347 /* UserManagementApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFAE2B07873600D36347 /* UserManagementApp.swift */; };
79FEFFB12B07873600D36347 /* AppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFB02B07873600D36347 /* AppView.swift */; };
79FEFFB32B07873700D36347 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 79FEFFB22B07873700D36347 /* Assets.xcassets */; };
79FEFFB72B07873700D36347 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 79FEFFB62B07873700D36347 /* Preview Assets.xcassets */; };
79FEFFBC2B07874000D36347 /* Supabase in Frameworks */ = {isa = PBXBuildFile; productRef = 79FEFFBB2B07874000D36347 /* Supabase */; };
79FEFFBE2B07894700D36347 /* Supabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFBD2B07894700D36347 /* Supabase.swift */; };
79FEFFC02B07895900D36347 /* AuthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFBF2B07895900D36347 /* AuthView.swift */; };
79FEFFC32B078CD800D36347 /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC22B078CD800D36347 /* ProfileView.swift */; };
79FEFFC52B078D7900D36347 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC42B078D7900D36347 /* Models.swift */; };
79FEFFC72B078FB000D36347 /* SwiftUIHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -54,6 +64,18 @@
795640692955AFBD0088A06F /* ErrorText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorText.swift; sourceTree = "<group>"; };
796298982AEBBA77000AA957 /* MFAFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFAFlow.swift; sourceTree = "<group>"; };
7962989A2AEBBD9F000AA957 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
79FEFFAC2B07873600D36347 /* UserManagement.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UserManagement.app; sourceTree = BUILT_PRODUCTS_DIR; };
79FEFFAE2B07873600D36347 /* UserManagementApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserManagementApp.swift; sourceTree = "<group>"; };
79FEFFB02B07873600D36347 /* AppView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppView.swift; sourceTree = "<group>"; };
79FEFFB22B07873700D36347 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
79FEFFB42B07873700D36347 /* UserManagement.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = UserManagement.entitlements; sourceTree = "<group>"; };
79FEFFB62B07873700D36347 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
79FEFFBD2B07894700D36347 /* Supabase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Supabase.swift; sourceTree = "<group>"; };
79FEFFBF2B07895900D36347 /* AuthView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthView.swift; sourceTree = "<group>"; };
79FEFFC12B078B6100D36347 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
79FEFFC22B078CD800D36347 /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
79FEFFC42B078D7900D36347 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };
79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIHelpers.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -76,6 +98,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
79FEFFA92B07873600D36347 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
79FEFFBC2B07874000D36347 /* Supabase in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand Down Expand Up @@ -104,6 +134,7 @@
children = (
793895C82954ABFF0044F2B8 /* Examples */,
790308E72AEE7B4D003C4A98 /* RealtimeSample */,
79FEFFAD2B07873600D36347 /* UserManagement */,
793895C72954ABFF0044F2B8 /* Products */,
7956405A2954AC3E0088A06F /* Frameworks */,
);
Expand All @@ -114,6 +145,7 @@
children = (
793895C62954ABFF0044F2B8 /* Examples.app */,
790308E62AEE7B4D003C4A98 /* RealtimeSample.app */,
79FEFFAC2B07873600D36347 /* UserManagement.app */,
);
name = Products;
sourceTree = "<group>";
Expand Down Expand Up @@ -155,6 +187,32 @@
name = Frameworks;
sourceTree = "<group>";
};
79FEFFAD2B07873600D36347 /* UserManagement */ = {
isa = PBXGroup;
children = (
79FEFFC12B078B6100D36347 /* Info.plist */,
79FEFFAE2B07873600D36347 /* UserManagementApp.swift */,
79FEFFB02B07873600D36347 /* AppView.swift */,
79FEFFB22B07873700D36347 /* Assets.xcassets */,
79FEFFB42B07873700D36347 /* UserManagement.entitlements */,
79FEFFB52B07873700D36347 /* Preview Content */,
79FEFFBD2B07894700D36347 /* Supabase.swift */,
79FEFFBF2B07895900D36347 /* AuthView.swift */,
79FEFFC22B078CD800D36347 /* ProfileView.swift */,
79FEFFC42B078D7900D36347 /* Models.swift */,
79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */,
);
path = UserManagement;
sourceTree = "<group>";
};
79FEFFB52B07873700D36347 /* Preview Content */ = {
isa = PBXGroup;
children = (
79FEFFB62B07873700D36347 /* Preview Assets.xcassets */,
);
path = "Preview Content";
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand Down Expand Up @@ -201,6 +259,26 @@
productReference = 793895C62954ABFF0044F2B8 /* Examples.app */;
productType = "com.apple.product-type.application";
};
79FEFFAB2B07873600D36347 /* UserManagement */ = {
isa = PBXNativeTarget;
buildConfigurationList = 79FEFFB82B07873700D36347 /* Build configuration list for PBXNativeTarget "UserManagement" */;
buildPhases = (
79FEFFA82B07873600D36347 /* Sources */,
79FEFFA92B07873600D36347 /* Frameworks */,
79FEFFAA2B07873600D36347 /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = UserManagement;
packageProductDependencies = (
79FEFFBB2B07874000D36347 /* Supabase */,
);
productName = UserManagement;
productReference = 79FEFFAC2B07873600D36347 /* UserManagement.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -217,6 +295,9 @@
793895C52954ABFF0044F2B8 = {
CreatedOnToolsVersion = 14.1;
};
79FEFFAB2B07873600D36347 = {
CreatedOnToolsVersion = 15.0.1;
};
};
};
buildConfigurationList = 793895C12954ABFF0044F2B8 /* Build configuration list for PBXProject "Examples" */;
Expand All @@ -239,6 +320,7 @@
targets = (
793895C52954ABFF0044F2B8 /* Examples */,
790308E52AEE7B4D003C4A98 /* RealtimeSample */,
79FEFFAB2B07873600D36347 /* UserManagement */,
);
};
/* End PBXProject section */
Expand All @@ -262,6 +344,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
79FEFFAA2B07873600D36347 /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
79FEFFB72B07873700D36347 /* Preview Assets.xcassets in Resources */,
79FEFFB32B07873700D36347 /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -292,6 +383,20 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
79FEFFA82B07873600D36347 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
79FEFFB12B07873600D36347 /* AppView.swift in Sources */,
79FEFFBE2B07894700D36347 /* Supabase.swift in Sources */,
79FEFFC32B078CD800D36347 /* ProfileView.swift in Sources */,
79FEFFC52B078D7900D36347 /* Models.swift in Sources */,
79FEFFC72B078FB000D36347 /* SwiftUIHelpers.swift in Sources */,
79FEFFC02B07895900D36347 /* AuthView.swift in Sources */,
79FEFFAF2B07873600D36347 /* UserManagementApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -537,6 +642,91 @@
};
name = Release;
};
79FEFFB92B07873700D36347 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = UserManagement/UserManagement.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"UserManagement/Preview Content\"";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = UserManagement/Info.plist;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.supabase.UserManagement;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
79FEFFBA2B07873700D36347 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = UserManagement/UserManagement.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "\"UserManagement/Preview Content\"";
DEVELOPMENT_TEAM = ELTTE7K8TT;
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_PREVIEWS = YES;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = UserManagement/Info.plist;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = com.supabase.UserManagement;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = auto;
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -567,6 +757,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
79FEFFB82B07873700D36347 /* Build configuration list for PBXNativeTarget "UserManagement" */ = {
isa = XCConfigurationList;
buildConfigurations = (
79FEFFB92B07873700D36347 /* Debug */,
79FEFFBA2B07873700D36347 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
Expand Down Expand Up @@ -620,6 +819,10 @@
isa = XCSwiftPackageProductDependency;
productName = Supabase;
};
79FEFFBB2B07874000D36347 /* Supabase */ = {
isa = XCSwiftPackageProductDependency;
productName = Supabase;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 793895BE2954ABFF0044F2B8 /* Project object */;
Expand Down
3 changes: 0 additions & 3 deletions Examples/ProductSample/.ci/pre_build.sh

This file was deleted.

1 change: 0 additions & 1 deletion Examples/ProductSample/.gitignore

This file was deleted.

8 changes: 5 additions & 3 deletions Examples/RealtimeSample/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ extension Message {
}
}

#Preview {
ContentView()
}
#if swift(>=5.9)
#Preview {
ContentView()
}
#endif
35 changes: 35 additions & 0 deletions Examples/UserManagement/AppView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
//
// AppView.swift
// UserManagement
//
// Created by Guilherme Souza on 17/11/23.
//

import SwiftUI

struct AppView: View {
@State var isAuthenticated = false

var body: some View {
Group {
if isAuthenticated {
ProfileView()
} else {
AuthView()
}
}
.task {
for await state in await supabase.auth.onAuthStateChange() {
if [.initialSession, .signedIn, .signedOut].contains(state.event) {
isAuthenticated = state.session != nil
}
}
}
}
}

#if swift(>=5.9)
#Preview {
AppView()
}
#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading

0 comments on commit 42e94b2

Please sign in to comment.