Skip to content

Commit 42e94b2

Browse files
authored
docs: add UserManagement example (#161)
* docs: add UserManagement example * Remove ProductSample folder * Build examples on CI
1 parent e8ba6d1 commit 42e94b2

File tree

21 files changed

+654
-17
lines changed

21 files changed

+654
-17
lines changed

.github/workflows/ci.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,14 @@ jobs:
2323
run: sudo xcode-select -s /Applications/Xcode_14.3.app
2424
- name: Run tests
2525
run: make test-library
26+
27+
examples:
28+
runs-on: macos-13
29+
name: Build Examples
30+
steps:
31+
- uses: actions/checkout@v3
32+
- name: Select Xcode 14.3
33+
run: sudo xcode-select -s /Applications/Xcode_14.3.app
34+
- name: Build examples
35+
run: make build-examples
36+

Examples/Examples.xcodeproj/project.pbxproj

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@
2929
796298992AEBBA77000AA957 /* MFAFlow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 796298982AEBBA77000AA957 /* MFAFlow.swift */; };
3030
7962989D2AEBC6F9000AA957 /* SVGView in Frameworks */ = {isa = PBXBuildFile; productRef = 7962989C2AEBC6F9000AA957 /* SVGView */; };
3131
79719ECE2ADF26C400737804 /* Supabase in Frameworks */ = {isa = PBXBuildFile; productRef = 79719ECD2ADF26C400737804 /* Supabase */; };
32+
79FEFFAF2B07873600D36347 /* UserManagementApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFAE2B07873600D36347 /* UserManagementApp.swift */; };
33+
79FEFFB12B07873600D36347 /* AppView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFB02B07873600D36347 /* AppView.swift */; };
34+
79FEFFB32B07873700D36347 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 79FEFFB22B07873700D36347 /* Assets.xcassets */; };
35+
79FEFFB72B07873700D36347 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 79FEFFB62B07873700D36347 /* Preview Assets.xcassets */; };
36+
79FEFFBC2B07874000D36347 /* Supabase in Frameworks */ = {isa = PBXBuildFile; productRef = 79FEFFBB2B07874000D36347 /* Supabase */; };
37+
79FEFFBE2B07894700D36347 /* Supabase.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFBD2B07894700D36347 /* Supabase.swift */; };
38+
79FEFFC02B07895900D36347 /* AuthView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFBF2B07895900D36347 /* AuthView.swift */; };
39+
79FEFFC32B078CD800D36347 /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC22B078CD800D36347 /* ProfileView.swift */; };
40+
79FEFFC52B078D7900D36347 /* Models.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC42B078D7900D36347 /* Models.swift */; };
41+
79FEFFC72B078FB000D36347 /* SwiftUIHelpers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */; };
3242
/* End PBXBuildFile section */
3343

3444
/* Begin PBXFileReference section */
@@ -54,6 +64,18 @@
5464
795640692955AFBD0088A06F /* ErrorText.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ErrorText.swift; sourceTree = "<group>"; };
5565
796298982AEBBA77000AA957 /* MFAFlow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFAFlow.swift; sourceTree = "<group>"; };
5666
7962989A2AEBBD9F000AA957 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
67+
79FEFFAC2B07873600D36347 /* UserManagement.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UserManagement.app; sourceTree = BUILT_PRODUCTS_DIR; };
68+
79FEFFAE2B07873600D36347 /* UserManagementApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UserManagementApp.swift; sourceTree = "<group>"; };
69+
79FEFFB02B07873600D36347 /* AppView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppView.swift; sourceTree = "<group>"; };
70+
79FEFFB22B07873700D36347 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
71+
79FEFFB42B07873700D36347 /* UserManagement.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = UserManagement.entitlements; sourceTree = "<group>"; };
72+
79FEFFB62B07873700D36347 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
73+
79FEFFBD2B07894700D36347 /* Supabase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Supabase.swift; sourceTree = "<group>"; };
74+
79FEFFBF2B07895900D36347 /* AuthView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AuthView.swift; sourceTree = "<group>"; };
75+
79FEFFC12B078B6100D36347 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
76+
79FEFFC22B078CD800D36347 /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
77+
79FEFFC42B078D7900D36347 /* Models.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Models.swift; sourceTree = "<group>"; };
78+
79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftUIHelpers.swift; sourceTree = "<group>"; };
5779
/* End PBXFileReference section */
5880

5981
/* Begin PBXFrameworksBuildPhase section */
@@ -76,6 +98,14 @@
7698
);
7799
runOnlyForDeploymentPostprocessing = 0;
78100
};
101+
79FEFFA92B07873600D36347 /* Frameworks */ = {
102+
isa = PBXFrameworksBuildPhase;
103+
buildActionMask = 2147483647;
104+
files = (
105+
79FEFFBC2B07874000D36347 /* Supabase in Frameworks */,
106+
);
107+
runOnlyForDeploymentPostprocessing = 0;
108+
};
79109
/* End PBXFrameworksBuildPhase section */
80110

81111
/* Begin PBXGroup section */
@@ -104,6 +134,7 @@
104134
children = (
105135
793895C82954ABFF0044F2B8 /* Examples */,
106136
790308E72AEE7B4D003C4A98 /* RealtimeSample */,
137+
79FEFFAD2B07873600D36347 /* UserManagement */,
107138
793895C72954ABFF0044F2B8 /* Products */,
108139
7956405A2954AC3E0088A06F /* Frameworks */,
109140
);
@@ -114,6 +145,7 @@
114145
children = (
115146
793895C62954ABFF0044F2B8 /* Examples.app */,
116147
790308E62AEE7B4D003C4A98 /* RealtimeSample.app */,
148+
79FEFFAC2B07873600D36347 /* UserManagement.app */,
117149
);
118150
name = Products;
119151
sourceTree = "<group>";
@@ -155,6 +187,32 @@
155187
name = Frameworks;
156188
sourceTree = "<group>";
157189
};
190+
79FEFFAD2B07873600D36347 /* UserManagement */ = {
191+
isa = PBXGroup;
192+
children = (
193+
79FEFFC12B078B6100D36347 /* Info.plist */,
194+
79FEFFAE2B07873600D36347 /* UserManagementApp.swift */,
195+
79FEFFB02B07873600D36347 /* AppView.swift */,
196+
79FEFFB22B07873700D36347 /* Assets.xcassets */,
197+
79FEFFB42B07873700D36347 /* UserManagement.entitlements */,
198+
79FEFFB52B07873700D36347 /* Preview Content */,
199+
79FEFFBD2B07894700D36347 /* Supabase.swift */,
200+
79FEFFBF2B07895900D36347 /* AuthView.swift */,
201+
79FEFFC22B078CD800D36347 /* ProfileView.swift */,
202+
79FEFFC42B078D7900D36347 /* Models.swift */,
203+
79FEFFC62B078FB000D36347 /* SwiftUIHelpers.swift */,
204+
);
205+
path = UserManagement;
206+
sourceTree = "<group>";
207+
};
208+
79FEFFB52B07873700D36347 /* Preview Content */ = {
209+
isa = PBXGroup;
210+
children = (
211+
79FEFFB62B07873700D36347 /* Preview Assets.xcassets */,
212+
);
213+
path = "Preview Content";
214+
sourceTree = "<group>";
215+
};
158216
/* End PBXGroup section */
159217

160218
/* Begin PBXNativeTarget section */
@@ -201,6 +259,26 @@
201259
productReference = 793895C62954ABFF0044F2B8 /* Examples.app */;
202260
productType = "com.apple.product-type.application";
203261
};
262+
79FEFFAB2B07873600D36347 /* UserManagement */ = {
263+
isa = PBXNativeTarget;
264+
buildConfigurationList = 79FEFFB82B07873700D36347 /* Build configuration list for PBXNativeTarget "UserManagement" */;
265+
buildPhases = (
266+
79FEFFA82B07873600D36347 /* Sources */,
267+
79FEFFA92B07873600D36347 /* Frameworks */,
268+
79FEFFAA2B07873600D36347 /* Resources */,
269+
);
270+
buildRules = (
271+
);
272+
dependencies = (
273+
);
274+
name = UserManagement;
275+
packageProductDependencies = (
276+
79FEFFBB2B07874000D36347 /* Supabase */,
277+
);
278+
productName = UserManagement;
279+
productReference = 79FEFFAC2B07873600D36347 /* UserManagement.app */;
280+
productType = "com.apple.product-type.application";
281+
};
204282
/* End PBXNativeTarget section */
205283

206284
/* Begin PBXProject section */
@@ -217,6 +295,9 @@
217295
793895C52954ABFF0044F2B8 = {
218296
CreatedOnToolsVersion = 14.1;
219297
};
298+
79FEFFAB2B07873600D36347 = {
299+
CreatedOnToolsVersion = 15.0.1;
300+
};
220301
};
221302
};
222303
buildConfigurationList = 793895C12954ABFF0044F2B8 /* Build configuration list for PBXProject "Examples" */;
@@ -239,6 +320,7 @@
239320
targets = (
240321
793895C52954ABFF0044F2B8 /* Examples */,
241322
790308E52AEE7B4D003C4A98 /* RealtimeSample */,
323+
79FEFFAB2B07873600D36347 /* UserManagement */,
242324
);
243325
};
244326
/* End PBXProject section */
@@ -262,6 +344,15 @@
262344
);
263345
runOnlyForDeploymentPostprocessing = 0;
264346
};
347+
79FEFFAA2B07873600D36347 /* Resources */ = {
348+
isa = PBXResourcesBuildPhase;
349+
buildActionMask = 2147483647;
350+
files = (
351+
79FEFFB72B07873700D36347 /* Preview Assets.xcassets in Resources */,
352+
79FEFFB32B07873700D36347 /* Assets.xcassets in Resources */,
353+
);
354+
runOnlyForDeploymentPostprocessing = 0;
355+
};
265356
/* End PBXResourcesBuildPhase section */
266357

267358
/* Begin PBXSourcesBuildPhase section */
@@ -292,6 +383,20 @@
292383
);
293384
runOnlyForDeploymentPostprocessing = 0;
294385
};
386+
79FEFFA82B07873600D36347 /* Sources */ = {
387+
isa = PBXSourcesBuildPhase;
388+
buildActionMask = 2147483647;
389+
files = (
390+
79FEFFB12B07873600D36347 /* AppView.swift in Sources */,
391+
79FEFFBE2B07894700D36347 /* Supabase.swift in Sources */,
392+
79FEFFC32B078CD800D36347 /* ProfileView.swift in Sources */,
393+
79FEFFC52B078D7900D36347 /* Models.swift in Sources */,
394+
79FEFFC72B078FB000D36347 /* SwiftUIHelpers.swift in Sources */,
395+
79FEFFC02B07895900D36347 /* AuthView.swift in Sources */,
396+
79FEFFAF2B07873600D36347 /* UserManagementApp.swift in Sources */,
397+
);
398+
runOnlyForDeploymentPostprocessing = 0;
399+
};
295400
/* End PBXSourcesBuildPhase section */
296401

297402
/* Begin XCBuildConfiguration section */
@@ -537,6 +642,91 @@
537642
};
538643
name = Release;
539644
};
645+
79FEFFB92B07873700D36347 /* Debug */ = {
646+
isa = XCBuildConfiguration;
647+
buildSettings = {
648+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
649+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
650+
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
651+
CODE_SIGN_ENTITLEMENTS = UserManagement/UserManagement.entitlements;
652+
CODE_SIGN_STYLE = Automatic;
653+
CURRENT_PROJECT_VERSION = 1;
654+
DEVELOPMENT_ASSET_PATHS = "\"UserManagement/Preview Content\"";
655+
DEVELOPMENT_TEAM = ELTTE7K8TT;
656+
ENABLE_HARDENED_RUNTIME = YES;
657+
ENABLE_PREVIEWS = YES;
658+
GENERATE_INFOPLIST_FILE = YES;
659+
INFOPLIST_FILE = UserManagement/Info.plist;
660+
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
661+
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
662+
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
663+
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
664+
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
665+
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
666+
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
667+
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
668+
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
669+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
670+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
671+
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
672+
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
673+
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
674+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
675+
MACOSX_DEPLOYMENT_TARGET = 14.0;
676+
MARKETING_VERSION = 1.0;
677+
PRODUCT_BUNDLE_IDENTIFIER = com.supabase.UserManagement;
678+
PRODUCT_NAME = "$(TARGET_NAME)";
679+
SDKROOT = auto;
680+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
681+
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "DEBUG $(inherited)";
682+
SWIFT_EMIT_LOC_STRINGS = YES;
683+
SWIFT_VERSION = 5.0;
684+
TARGETED_DEVICE_FAMILY = "1,2";
685+
};
686+
name = Debug;
687+
};
688+
79FEFFBA2B07873700D36347 /* Release */ = {
689+
isa = XCBuildConfiguration;
690+
buildSettings = {
691+
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
692+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS = YES;
693+
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
694+
CODE_SIGN_ENTITLEMENTS = UserManagement/UserManagement.entitlements;
695+
CODE_SIGN_STYLE = Automatic;
696+
CURRENT_PROJECT_VERSION = 1;
697+
DEVELOPMENT_ASSET_PATHS = "\"UserManagement/Preview Content\"";
698+
DEVELOPMENT_TEAM = ELTTE7K8TT;
699+
ENABLE_HARDENED_RUNTIME = YES;
700+
ENABLE_PREVIEWS = YES;
701+
GENERATE_INFOPLIST_FILE = YES;
702+
INFOPLIST_FILE = UserManagement/Info.plist;
703+
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
704+
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
705+
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphoneos*]" = YES;
706+
"INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents[sdk=iphonesimulator*]" = YES;
707+
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
708+
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphoneos*]" = YES;
709+
"INFOPLIST_KEY_UILaunchScreen_Generation[sdk=iphonesimulator*]" = YES;
710+
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphoneos*]" = UIStatusBarStyleDefault;
711+
"INFOPLIST_KEY_UIStatusBarStyle[sdk=iphonesimulator*]" = UIStatusBarStyleDefault;
712+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
713+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
714+
IPHONEOS_DEPLOYMENT_TARGET = 17.0;
715+
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
716+
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
717+
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
718+
MACOSX_DEPLOYMENT_TARGET = 14.0;
719+
MARKETING_VERSION = 1.0;
720+
PRODUCT_BUNDLE_IDENTIFIER = com.supabase.UserManagement;
721+
PRODUCT_NAME = "$(TARGET_NAME)";
722+
SDKROOT = auto;
723+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
724+
SWIFT_EMIT_LOC_STRINGS = YES;
725+
SWIFT_VERSION = 5.0;
726+
TARGETED_DEVICE_FAMILY = "1,2";
727+
};
728+
name = Release;
729+
};
540730
/* End XCBuildConfiguration section */
541731

542732
/* Begin XCConfigurationList section */
@@ -567,6 +757,15 @@
567757
defaultConfigurationIsVisible = 0;
568758
defaultConfigurationName = Release;
569759
};
760+
79FEFFB82B07873700D36347 /* Build configuration list for PBXNativeTarget "UserManagement" */ = {
761+
isa = XCConfigurationList;
762+
buildConfigurations = (
763+
79FEFFB92B07873700D36347 /* Debug */,
764+
79FEFFBA2B07873700D36347 /* Release */,
765+
);
766+
defaultConfigurationIsVisible = 0;
767+
defaultConfigurationName = Release;
768+
};
570769
/* End XCConfigurationList section */
571770

572771
/* Begin XCRemoteSwiftPackageReference section */
@@ -620,6 +819,10 @@
620819
isa = XCSwiftPackageProductDependency;
621820
productName = Supabase;
622821
};
822+
79FEFFBB2B07874000D36347 /* Supabase */ = {
823+
isa = XCSwiftPackageProductDependency;
824+
productName = Supabase;
825+
};
623826
/* End XCSwiftPackageProductDependency section */
624827
};
625828
rootObject = 793895BE2954ABFF0044F2B8 /* Project object */;

Examples/ProductSample/.ci/pre_build.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

Examples/ProductSample/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

Examples/RealtimeSample/ContentView.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ extension Message {
118118
}
119119
}
120120

121-
#Preview {
122-
ContentView()
123-
}
121+
#if swift(>=5.9)
122+
#Preview {
123+
ContentView()
124+
}
125+
#endif

Examples/UserManagement/AppView.swift

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//
2+
// AppView.swift
3+
// UserManagement
4+
//
5+
// Created by Guilherme Souza on 17/11/23.
6+
//
7+
8+
import SwiftUI
9+
10+
struct AppView: View {
11+
@State var isAuthenticated = false
12+
13+
var body: some View {
14+
Group {
15+
if isAuthenticated {
16+
ProfileView()
17+
} else {
18+
AuthView()
19+
}
20+
}
21+
.task {
22+
for await state in await supabase.auth.onAuthStateChange() {
23+
if [.initialSession, .signedIn, .signedOut].contains(state.event) {
24+
isAuthenticated = state.session != nil
25+
}
26+
}
27+
}
28+
}
29+
}
30+
31+
#if swift(>=5.9)
32+
#Preview {
33+
AppView()
34+
}
35+
#endif
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"colors" : [
3+
{
4+
"idiom" : "universal"
5+
}
6+
],
7+
"info" : {
8+
"author" : "xcode",
9+
"version" : 1
10+
}
11+
}

0 commit comments

Comments
 (0)