Skip to content

Commit 525b133

Browse files
authored
Add tvOS platform to RTDB (#1259)
1 parent 2da94d9 commit 525b133

File tree

11 files changed

+287
-33
lines changed

11 files changed

+287
-33
lines changed

database/DatabaseExampleSwiftUI/DatabaseExample/DatabaseExample.xcodeproj/project.pbxproj

Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@
2121
C796F29C26CCE3DA0076C5F5 /* ScreenDimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C796F29B26CCE3DA0076C5F5 /* ScreenDimensions.swift */; };
2222
C796F29D26CCE3DA0076C5F5 /* ScreenDimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C796F29B26CCE3DA0076C5F5 /* ScreenDimensions.swift */; };
2323
C796F29E26CCE9DE0076C5F5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B9029EF026A10B1500C92F12 /* GoogleService-Info.plist */; };
24+
C796F2AD26D2281A0076C5F5 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C796F2AC26D2281A0076C5F5 /* Preview Assets.xcassets */; };
25+
C796F2B226D228380076C5F5 /* GoogleService-Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = B9029EF026A10B1500C92F12 /* GoogleService-Info.plist */; };
26+
C796F2B326D2283B0076C5F5 /* Comment.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7C6B5B2268DAC1800546A57 /* Comment.swift */; };
27+
C796F2B426D2283E0076C5F5 /* UserViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F60CF5268EBEDE002F68AB /* UserViewModel.swift */; };
28+
C796F2B526D228410076C5F5 /* PostViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C79D1AC226A4114600B6A169 /* PostViewModel.swift */; };
29+
C796F2B626D228490076C5F5 /* PostsType.swift in Sources */ = {isa = PBXBuildFile; fileRef = C730A31E26B0998A00A29E81 /* PostsType.swift */; };
30+
C796F2B726D228490076C5F5 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F60CFB268EE316002F68AB /* ContentView.swift */; };
31+
C796F2B826D228490076C5F5 /* PostDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B60D269E1CEF00A43C40 /* PostDetailView.swift */; };
32+
C796F2B926D228490076C5F5 /* NewPostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C70B63FE2696B29400851A91 /* NewPostsView.swift */; };
33+
C796F2BA26D228490076C5F5 /* PostCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B610269E1E3B00A43C40 /* PostCell.swift */; };
34+
C796F2BB26D228490076C5F5 /* SignUpView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7F60CF1268E352F002F68AB /* SignUpView.swift */; };
35+
C796F2BC26D228490076C5F5 /* PostListViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C77ABFAA26B8992600BDE919 /* PostListViewModel.swift */; };
36+
C796F2BD26D228490076C5F5 /* LoginView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7C6B575268C8C9A00546A57 /* LoginView.swift */; };
37+
C796F2BE26D228490076C5F5 /* PostsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C79D1AEC26A8D9A300B6A169 /* PostsView.swift */; };
38+
C796F2BF26D228490076C5F5 /* Database+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C77ABFAD26B8A7FF00BDE919 /* Database+Extensions.swift */; };
39+
C796F2C026D228490076C5F5 /* DatabaseExampleApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7C6B574268C8C9A00546A57 /* DatabaseExampleApp.swift */; };
40+
C796F2C126D228490076C5F5 /* ScreenDimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C796F29B26CCE3DA0076C5F5 /* ScreenDimensions.swift */; };
41+
C796F2C326D228F30076C5F5 /* FirebaseAuth in Frameworks */ = {isa = PBXBuildFile; productRef = C796F2C226D228F30076C5F5 /* FirebaseAuth */; };
42+
C796F2C526D228F30076C5F5 /* FirebaseDatabase in Frameworks */ = {isa = PBXBuildFile; productRef = C796F2C426D228F30076C5F5 /* FirebaseDatabase */; };
43+
C796F2C626D390010076C5F5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C7C6B576268C8C9C00546A57 /* Assets.xcassets */; };
2444
C799B60E269E1CEF00A43C40 /* PostDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B60D269E1CEF00A43C40 /* PostDetailView.swift */; };
2545
C799B60F269E1CEF00A43C40 /* PostDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B60D269E1CEF00A43C40 /* PostDetailView.swift */; };
2646
C799B611269E1E3B00A43C40 /* PostCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = C799B610269E1E3B00A43C40 /* PostCell.swift */; };
@@ -55,6 +75,9 @@
5575
C77ABFAA26B8992600BDE919 /* PostListViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostListViewModel.swift; sourceTree = "<group>"; };
5676
C77ABFAD26B8A7FF00BDE919 /* Database+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Database+Extensions.swift"; sourceTree = "<group>"; };
5777
C796F29B26CCE3DA0076C5F5 /* ScreenDimensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScreenDimensions.swift; sourceTree = "<group>"; };
78+
C796F2A326D228180076C5F5 /* DatabaseExample (tvOS).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "DatabaseExample (tvOS).app"; sourceTree = BUILT_PRODUCTS_DIR; };
79+
C796F2AC26D2281A0076C5F5 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
80+
C796F2AE26D2281A0076C5F5 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5881
C799B60D269E1CEF00A43C40 /* PostDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostDetailView.swift; sourceTree = "<group>"; };
5982
C799B610269E1E3B00A43C40 /* PostCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostCell.swift; sourceTree = "<group>"; };
6083
C79D1AC226A4114600B6A169 /* PostViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PostViewModel.swift; sourceTree = "<group>"; };
@@ -74,6 +97,15 @@
7497
/* End PBXFileReference section */
7598

7699
/* Begin PBXFrameworksBuildPhase section */
100+
C796F2A026D228180076C5F5 /* Frameworks */ = {
101+
isa = PBXFrameworksBuildPhase;
102+
buildActionMask = 2147483647;
103+
files = (
104+
C796F2C526D228F30076C5F5 /* FirebaseDatabase in Frameworks */,
105+
C796F2C326D228F30076C5F5 /* FirebaseAuth in Frameworks */,
106+
);
107+
runOnlyForDeploymentPostprocessing = 0;
108+
};
77109
C7C6B578268C8C9C00546A57 /* Frameworks */ = {
78110
isa = PBXFrameworksBuildPhase;
79111
buildActionMask = 2147483647;
@@ -103,13 +135,31 @@
103135
name = Frameworks;
104136
sourceTree = "<group>";
105137
};
138+
C796F2A426D228180076C5F5 /* tvOS */ = {
139+
isa = PBXGroup;
140+
children = (
141+
C796F2AE26D2281A0076C5F5 /* Info.plist */,
142+
C796F2AB26D2281A0076C5F5 /* Preview Content */,
143+
);
144+
path = tvOS;
145+
sourceTree = "<group>";
146+
};
147+
C796F2AB26D2281A0076C5F5 /* Preview Content */ = {
148+
isa = PBXGroup;
149+
children = (
150+
C796F2AC26D2281A0076C5F5 /* Preview Assets.xcassets */,
151+
);
152+
path = "Preview Content";
153+
sourceTree = "<group>";
154+
};
106155
C7C6B56E268C8C9A00546A57 = {
107156
isa = PBXGroup;
108157
children = (
109158
B9029EF026A10B1500C92F12 /* GoogleService-Info.plist */,
110159
C7C6B573268C8C9A00546A57 /* Shared */,
111160
C7C6B57D268C8C9C00546A57 /* iOS */,
112161
C7C6B584268C8C9C00546A57 /* macOS */,
162+
C796F2A426D228180076C5F5 /* tvOS */,
113163
C7C6B57C268C8C9C00546A57 /* Products */,
114164
C796F29626CCDCEF0076C5F5 /* Frameworks */,
115165
);
@@ -131,6 +181,7 @@
131181
children = (
132182
C7C6B57B268C8C9C00546A57 /* DatabaseExample.app */,
133183
C7C6B583268C8C9C00546A57 /* DatabaseExample.app */,
184+
C796F2A326D228180076C5F5 /* DatabaseExample (tvOS).app */,
134185
);
135186
name = Products;
136187
sourceTree = "<group>";
@@ -183,6 +234,27 @@
183234
/* End PBXGroup section */
184235

185236
/* Begin PBXNativeTarget section */
237+
C796F2A226D228180076C5F5 /* DatabaseExample (tvOS) */ = {
238+
isa = PBXNativeTarget;
239+
buildConfigurationList = C796F2B126D2281A0076C5F5 /* Build configuration list for PBXNativeTarget "DatabaseExample (tvOS)" */;
240+
buildPhases = (
241+
C796F29F26D228180076C5F5 /* Sources */,
242+
C796F2A026D228180076C5F5 /* Frameworks */,
243+
C796F2A126D228180076C5F5 /* Resources */,
244+
);
245+
buildRules = (
246+
);
247+
dependencies = (
248+
);
249+
name = "DatabaseExample (tvOS)";
250+
packageProductDependencies = (
251+
C796F2C226D228F30076C5F5 /* FirebaseAuth */,
252+
C796F2C426D228F30076C5F5 /* FirebaseDatabase */,
253+
);
254+
productName = tvOSDatabaseExample;
255+
productReference = C796F2A326D228180076C5F5 /* DatabaseExample (tvOS).app */;
256+
productType = "com.apple.product-type.application";
257+
};
186258
C7C6B57A268C8C9C00546A57 /* DatabaseExample (iOS) */ = {
187259
isa = PBXNativeTarget;
188260
buildConfigurationList = C7C6B58F268C8C9C00546A57 /* Build configuration list for PBXNativeTarget "DatabaseExample (iOS)" */;
@@ -235,6 +307,9 @@
235307
LastSwiftUpdateCheck = 1250;
236308
LastUpgradeCheck = 1250;
237309
TargetAttributes = {
310+
C796F2A226D228180076C5F5 = {
311+
CreatedOnToolsVersion = 12.5;
312+
};
238313
C7C6B57A268C8C9C00546A57 = {
239314
CreatedOnToolsVersion = 12.5;
240315
};
@@ -261,11 +336,22 @@
261336
targets = (
262337
C7C6B57A268C8C9C00546A57 /* DatabaseExample (iOS) */,
263338
C7C6B582268C8C9C00546A57 /* DatabaseExample (macOS) */,
339+
C796F2A226D228180076C5F5 /* DatabaseExample (tvOS) */,
264340
);
265341
};
266342
/* End PBXProject section */
267343

268344
/* Begin PBXResourcesBuildPhase section */
345+
C796F2A126D228180076C5F5 /* Resources */ = {
346+
isa = PBXResourcesBuildPhase;
347+
buildActionMask = 2147483647;
348+
files = (
349+
C796F2AD26D2281A0076C5F5 /* Preview Assets.xcassets in Resources */,
350+
C796F2C626D390010076C5F5 /* Assets.xcassets in Resources */,
351+
C796F2B226D228380076C5F5 /* GoogleService-Info.plist in Resources */,
352+
);
353+
runOnlyForDeploymentPostprocessing = 0;
354+
};
269355
C7C6B579268C8C9C00546A57 /* Resources */ = {
270356
isa = PBXResourcesBuildPhase;
271357
buildActionMask = 2147483647;
@@ -287,6 +373,28 @@
287373
/* End PBXResourcesBuildPhase section */
288374

289375
/* Begin PBXSourcesBuildPhase section */
376+
C796F29F26D228180076C5F5 /* Sources */ = {
377+
isa = PBXSourcesBuildPhase;
378+
buildActionMask = 2147483647;
379+
files = (
380+
C796F2B526D228410076C5F5 /* PostViewModel.swift in Sources */,
381+
C796F2B726D228490076C5F5 /* ContentView.swift in Sources */,
382+
C796F2BE26D228490076C5F5 /* PostsView.swift in Sources */,
383+
C796F2BC26D228490076C5F5 /* PostListViewModel.swift in Sources */,
384+
C796F2B626D228490076C5F5 /* PostsType.swift in Sources */,
385+
C796F2C126D228490076C5F5 /* ScreenDimensions.swift in Sources */,
386+
C796F2B826D228490076C5F5 /* PostDetailView.swift in Sources */,
387+
C796F2B926D228490076C5F5 /* NewPostsView.swift in Sources */,
388+
C796F2BF26D228490076C5F5 /* Database+Extensions.swift in Sources */,
389+
C796F2B326D2283B0076C5F5 /* Comment.swift in Sources */,
390+
C796F2C026D228490076C5F5 /* DatabaseExampleApp.swift in Sources */,
391+
C796F2B426D2283E0076C5F5 /* UserViewModel.swift in Sources */,
392+
C796F2BD26D228490076C5F5 /* LoginView.swift in Sources */,
393+
C796F2BB26D228490076C5F5 /* SignUpView.swift in Sources */,
394+
C796F2BA26D228490076C5F5 /* PostCell.swift in Sources */,
395+
);
396+
runOnlyForDeploymentPostprocessing = 0;
397+
};
290398
C7C6B577268C8C9C00546A57 /* Sources */ = {
291399
isa = PBXSourcesBuildPhase;
292400
buildActionMask = 2147483647;
@@ -334,6 +442,51 @@
334442
/* End PBXSourcesBuildPhase section */
335443

336444
/* Begin XCBuildConfiguration section */
445+
C796F2AF26D2281A0076C5F5 /* Debug */ = {
446+
isa = XCBuildConfiguration;
447+
buildSettings = {
448+
ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
449+
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
450+
CODE_SIGN_STYLE = Automatic;
451+
DEVELOPMENT_ASSET_PATHS = "\"tvOS/Preview Content\"";
452+
ENABLE_PREVIEWS = YES;
453+
INFOPLIST_FILE = tvOS/Info.plist;
454+
LD_RUNPATH_SEARCH_PATHS = (
455+
"$(inherited)",
456+
"@executable_path/Frameworks",
457+
);
458+
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.DatabaseExample;
459+
PRODUCT_NAME = "$(TARGET_NAME)";
460+
SDKROOT = appletvos;
461+
SWIFT_VERSION = 5.0;
462+
TARGETED_DEVICE_FAMILY = 3;
463+
TVOS_DEPLOYMENT_TARGET = 14.5;
464+
};
465+
name = Debug;
466+
};
467+
C796F2B026D2281A0076C5F5 /* Release */ = {
468+
isa = XCBuildConfiguration;
469+
buildSettings = {
470+
ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
471+
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
472+
CODE_SIGN_STYLE = Automatic;
473+
DEVELOPMENT_ASSET_PATHS = "\"tvOS/Preview Content\"";
474+
ENABLE_PREVIEWS = YES;
475+
INFOPLIST_FILE = tvOS/Info.plist;
476+
LD_RUNPATH_SEARCH_PATHS = (
477+
"$(inherited)",
478+
"@executable_path/Frameworks",
479+
);
480+
PRODUCT_BUNDLE_IDENTIFIER = com.google.firebase.quickstart.DatabaseExample;
481+
PRODUCT_NAME = "$(TARGET_NAME)";
482+
SDKROOT = appletvos;
483+
SWIFT_VERSION = 5.0;
484+
TARGETED_DEVICE_FAMILY = 3;
485+
TVOS_DEPLOYMENT_TARGET = 14.5;
486+
VALIDATE_PRODUCT = YES;
487+
};
488+
name = Release;
489+
};
337490
C7C6B58D268C8C9C00546A57 /* Debug */ = {
338491
isa = XCBuildConfiguration;
339492
buildSettings = {
@@ -535,6 +688,15 @@
535688
/* End XCBuildConfiguration section */
536689

537690
/* Begin XCConfigurationList section */
691+
C796F2B126D2281A0076C5F5 /* Build configuration list for PBXNativeTarget "DatabaseExample (tvOS)" */ = {
692+
isa = XCConfigurationList;
693+
buildConfigurations = (
694+
C796F2AF26D2281A0076C5F5 /* Debug */,
695+
C796F2B026D2281A0076C5F5 /* Release */,
696+
);
697+
defaultConfigurationIsVisible = 0;
698+
defaultConfigurationName = Release;
699+
};
538700
C7C6B572268C8C9A00546A57 /* Build configuration list for PBXProject "DatabaseExample" */ = {
539701
isa = XCConfigurationList;
540702
buildConfigurations = (
@@ -586,6 +748,16 @@
586748
package = C7C6B595268C8D7800546A57 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
587749
productName = FirebaseDatabase;
588750
};
751+
C796F2C226D228F30076C5F5 /* FirebaseAuth */ = {
752+
isa = XCSwiftPackageProductDependency;
753+
package = C7C6B595268C8D7800546A57 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
754+
productName = FirebaseAuth;
755+
};
756+
C796F2C426D228F30076C5F5 /* FirebaseDatabase */ = {
757+
isa = XCSwiftPackageProductDependency;
758+
package = C7C6B595268C8D7800546A57 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
759+
productName = FirebaseDatabase;
760+
};
589761
C7C6B596268C8D7800546A57 /* FirebaseDatabaseSwift-Beta */ = {
590762
isa = XCSwiftPackageProductDependency;
591763
package = C7C6B595268C8D7800546A57 /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;

database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Models/ScreenDimensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import SwiftUI
1818

1919
class ScreenDimensions {
20-
#if os(iOS)
20+
#if os(iOS) || os(tvOS)
2121
static var width: CGFloat = UIScreen.main.bounds.size.width
2222
static var height: CGFloat = UIScreen.main.bounds.size.height
2323
#elseif os(macOS)

database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/ContentView.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ struct ContentView: View {
2121
@AppStorage("isSignedIn") var isSignedIn = true
2222

2323
// define variables for creating a new post for macOS
24-
#if os(macOS)
24+
#if os(macOS) || os(tvOS)
2525
@StateObject var postList = PostListViewModel()
2626
@State private var newPostsViewPresented = false
2727
#endif
@@ -43,7 +43,8 @@ struct ContentView: View {
4343
}
4444
}
4545
.accentColor(Color(.systemTeal))
46-
#if os(iOS)
46+
47+
#if os(iOS) || os(tvOS)
4748
tabView
4849
#elseif os(macOS)
4950
tabView

database/DatabaseExampleSwiftUI/DatabaseExample/Shared/Views/LoginView.swift

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct LoginView: View {
4343
emailTextField
4444
.keyboardType(.emailAddress)
4545
.autocapitalization(UITextAutocapitalizationType.none)
46-
#elseif os(macOS)
46+
#elseif os(macOS) || os(tvOS)
4747
emailTextField
4848
#endif
4949
}
@@ -53,7 +53,7 @@ struct LoginView: View {
5353
emailInputField
5454
.background(RoundedRectangle(cornerRadius: 10).fill(Color(.systemGray5)))
5555
.frame(width: ScreenDimensions.width * 0.8)
56-
#elseif os(macOS)
56+
#elseif os(macOS) || os(tvOS)
5757
emailInputField
5858
#endif
5959

@@ -72,7 +72,7 @@ struct LoginView: View {
7272
passwordInputField
7373
.background(RoundedRectangle(cornerRadius: 10).fill(Color(.systemGray5)))
7474
.frame(width: ScreenDimensions.width * 0.8)
75-
#elseif os(macOS)
75+
#elseif os(macOS) || os(tvOS)
7676
passwordInputField
7777
#endif
7878

@@ -81,33 +81,44 @@ struct LoginView: View {
8181
.fixedSize()
8282

8383
// Login button
84-
Button(action: user.login) {
84+
let loginButton = Button(action: user.login) {
8585
Text("Login".uppercased())
8686
.foregroundColor(.white)
8787
.font(.title2)
8888
.bold()
8989
}
90-
.buttonStyle(BorderlessButtonStyle())
9190
.padding(0.025 * ScreenDimensions.height)
9291
.background(Capsule().fill(Color(.systemTeal)))
9392

93+
#if os(iOS) || os(macOS)
94+
loginButton
95+
.buttonStyle(BorderlessButtonStyle())
96+
#elseif os(tvOS)
97+
loginButton
98+
#endif
99+
94100
Spacer()
95101
.frame(idealHeight: 0.05 * ScreenDimensions.height)
96102
.fixedSize()
97103

98104
// Navigation text
99105
HStack {
100106
Text("Don't have an account?")
101-
Button(action: {
107+
let signUpButton = Button(action: {
102108
signUpViewPresented = true
103109
}) {
104110
Text("Sign up".uppercased())
105111
.bold()
106112
}
107-
.buttonStyle(BorderlessButtonStyle())
108113
.sheet(isPresented: $signUpViewPresented) {
109114
SignUpView(user: user, isPresented: $signUpViewPresented)
110115
}
116+
#if os(iOS) || os(macOS)
117+
signUpButton
118+
.buttonStyle(BorderlessButtonStyle())
119+
#elseif os(tvOS)
120+
signUpButton
121+
#endif
111122
}
112123
}
113124
.alert(isPresented: $user.alert, content: {

0 commit comments

Comments
 (0)