Skip to content

Commit 2bfeff3

Browse files
committed
firebase setup
1 parent 081b96b commit 2bfeff3

File tree

8 files changed

+280
-3
lines changed

8 files changed

+280
-3
lines changed

.github/workflows/publish.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ jobs:
3636
with:
3737
ssh-private-key: ${{ secrets.SSH_KEY }}
3838

39+
- name: "Google Services File"
40+
run: |
41+
echo "${{ secrets.GOOGLE_SERVICES }}" | base64 --decode > "Django Files/GoogleService-Info.plist"
42+
3943
- name: "Fastlane ${{ env.command }}"
4044
run: fastlane ${{ env.command }}
4145
env:

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,6 @@ xcuserdata/
1616
.DS_Store
1717
report.xml
1818
report.html
19-
report.junit
19+
report.junit
20+
21+
GoogleService-Info.plist

Django Files.xcodeproj/project.pbxproj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
4CA2E48A2D6D49D6006EF3F0 /* HTTPTypes in Frameworks */ = {isa = PBXBuildFile; productRef = 4CA2E4892D6D49D6006EF3F0 /* HTTPTypes */; };
1414
4CA2E48C2D6D49D6006EF3F0 /* HTTPTypesFoundation in Frameworks */ = {isa = PBXBuildFile; productRef = 4CA2E48B2D6D49D6006EF3F0 /* HTTPTypesFoundation */; };
1515
4CE57E8B2D7C9F440073CFC1 /* SnapshotHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CE57E8A2D7C9F440073CFC1 /* SnapshotHelper.swift */; };
16+
A21CC8852DEB967300EF776C /* FirebaseAnalytics in Frameworks */ = {isa = PBXBuildFile; productRef = A21CC8842DEB967300EF776C /* FirebaseAnalytics */; };
17+
A21CC88B2DEB991100EF776C /* FirebaseCrashlytics in Frameworks */ = {isa = PBXBuildFile; productRef = A21CC88A2DEB991100EF776C /* FirebaseCrashlytics */; };
1618
A2DF11D52DDA13FE0096E7C4 /* HighlightSwift in Frameworks */ = {isa = PBXBuildFile; productRef = A2DF11D42DDA13FE0096E7C4 /* HighlightSwift */; };
1719
/* End PBXBuildFile section */
1820

@@ -131,6 +133,8 @@
131133
files = (
132134
A2DF11D52DDA13FE0096E7C4 /* HighlightSwift in Frameworks */,
133135
4C82CB512D62372200C0893B /* HTTPTypes in Frameworks */,
136+
A21CC88B2DEB991100EF776C /* FirebaseCrashlytics in Frameworks */,
137+
A21CC8852DEB967300EF776C /* FirebaseAnalytics in Frameworks */,
134138
4C82CB532D62372200C0893B /* HTTPTypesFoundation in Frameworks */,
135139
);
136140
runOnlyForDeploymentPostprocessing = 0;
@@ -217,6 +221,8 @@
217221
4C82CB502D62372200C0893B /* HTTPTypes */,
218222
4C82CB522D62372200C0893B /* HTTPTypesFoundation */,
219223
A2DF11D42DDA13FE0096E7C4 /* HighlightSwift */,
224+
A21CC8842DEB967300EF776C /* FirebaseAnalytics */,
225+
A21CC88A2DEB991100EF776C /* FirebaseCrashlytics */,
220226
);
221227
productName = "Django Files";
222228
productReference = 4C5E20EC2D603C3B009EE83A /* Django Files.app */;
@@ -331,6 +337,7 @@
331337
4C82CB4F2D62372200C0893B /* XCRemoteSwiftPackageReference "swift-http-types" */,
332338
4CE57E892D7C9EB70073CFC1 /* XCRemoteSwiftPackageReference "fastlane" */,
333339
A2DF11D32DDA12CA0096E7C4 /* XCRemoteSwiftPackageReference "highlightswift" */,
340+
A21CC8832DEB950C00EF776C /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */,
334341
);
335342
preferredProjectObjectVersion = 77;
336343
productRefGroup = 4C5E20ED2D603C3B009EE83A /* Products */;
@@ -855,6 +862,14 @@
855862
minimumVersion = 2.226.0;
856863
};
857864
};
865+
A21CC8832DEB950C00EF776C /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */ = {
866+
isa = XCRemoteSwiftPackageReference;
867+
repositoryURL = "https://github.com/firebase/firebase-ios-sdk";
868+
requirement = {
869+
kind = upToNextMajorVersion;
870+
minimumVersion = 11.13.0;
871+
};
872+
};
858873
A2DF11D32DDA12CA0096E7C4 /* XCRemoteSwiftPackageReference "highlightswift" */ = {
859874
isa = XCRemoteSwiftPackageReference;
860875
repositoryURL = "https://github.com/appstefan/highlightswift";
@@ -886,6 +901,16 @@
886901
package = 4C82CB4F2D62372200C0893B /* XCRemoteSwiftPackageReference "swift-http-types" */;
887902
productName = HTTPTypesFoundation;
888903
};
904+
A21CC8842DEB967300EF776C /* FirebaseAnalytics */ = {
905+
isa = XCSwiftPackageProductDependency;
906+
package = A21CC8832DEB950C00EF776C /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
907+
productName = FirebaseAnalytics;
908+
};
909+
A21CC88A2DEB991100EF776C /* FirebaseCrashlytics */ = {
910+
isa = XCSwiftPackageProductDependency;
911+
package = A21CC8832DEB950C00EF776C /* XCRemoteSwiftPackageReference "firebase-ios-sdk" */;
912+
productName = FirebaseCrashlytics;
913+
};
889914
A2DF11D42DDA13FE0096E7C4 /* HighlightSwift */ = {
890915
isa = XCSwiftPackageProductDependency;
891916
package = A2DF11D32DDA12CA0096E7C4 /* XCRemoteSwiftPackageReference "highlightswift" */;

Django Files.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved

Lines changed: 118 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Django Files.xcodeproj/xcshareddata/xcschemes/Django Files.xcscheme

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,12 @@
7474
ReferencedContainer = "container:Django Files.xcodeproj">
7575
</BuildableReference>
7676
</BuildableProductRunnable>
77+
<CommandLineArguments>
78+
<CommandLineArgument
79+
argument = "-FIRDebugEnabled"
80+
isEnabled = "YES">
81+
</CommandLineArgument>
82+
</CommandLineArguments>
7783
</LaunchAction>
7884
<ProfileAction
7985
buildConfiguration = "Release"

Django Files/Django_FilesApp.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,31 @@
77

88
import SwiftUI
99
import SwiftData
10+
import FirebaseCore
11+
import FirebaseAnalytics
12+
import FirebaseCrashlytics
13+
14+
class AppDelegate: NSObject, UIApplicationDelegate {
15+
func application(_ application: UIApplication,
16+
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
17+
FirebaseApp.configure()
18+
19+
// Initialize Firebase Analytics based on user preference
20+
let analyticsEnabled = UserDefaults.standard.bool(forKey: "firebaseAnalyticsEnabled")
21+
Analytics.setAnalyticsCollectionEnabled(analyticsEnabled)
22+
23+
// Initialize Crashlytics based on user preference
24+
let crashlyticsEnabled = UserDefaults.standard.bool(forKey: "crashlyticsEnabled")
25+
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(crashlyticsEnabled)
26+
27+
return true
28+
}
29+
}
30+
1031

1132
@main
1233
struct Django_FilesApp: App {
34+
@UIApplicationDelegateAdaptor(AppDelegate.self) var delegate
1335
var sharedModelContainer: ModelContainer = {
1436
let schema = Schema([
1537
DjangoFilesSession.self,
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
//
2+
// AppSettings.swift
3+
// Django Files
4+
//
5+
// Created by Ralph Luaces on 5/31/25.
6+
//
7+
8+
import SwiftUI
9+
import FirebaseAnalytics
10+
import FirebaseCrashlytics
11+
12+
struct AppSettings: View {
13+
@AppStorage("firebaseAnalyticsEnabled") private var firebaseAnalyticsEnabled = true
14+
@AppStorage("crashlyticsEnabled") private var crashlyticsEnabled = true
15+
@State private var showAnalyticsAlert = false
16+
@State private var showCrashlyticsAlert = false
17+
@State private var pendingAnalyticsValue = true
18+
@State private var pendingCrashlyticsValue = true
19+
20+
var body: some View {
21+
Form {
22+
Section(header: Text("Privacy")) {
23+
Toggle(isOn: Binding(
24+
get: { firebaseAnalyticsEnabled },
25+
set: { newValue in
26+
if !newValue {
27+
pendingAnalyticsValue = newValue
28+
showAnalyticsAlert = true
29+
} else {
30+
firebaseAnalyticsEnabled = newValue
31+
Analytics.setAnalyticsCollectionEnabled(newValue)
32+
}
33+
}
34+
)) {
35+
VStack(alignment: .leading) {
36+
Text("Analytics")
37+
Text("Help improve the app by sending anonymous usage data")
38+
.font(.caption)
39+
.foregroundColor(.secondary)
40+
}
41+
}
42+
.alert("Disable Analytics?", isPresented: $showAnalyticsAlert) {
43+
Button("Keep Enabled", role: .cancel) {
44+
firebaseAnalyticsEnabled = true
45+
}
46+
Button("Disable", role: .destructive) {
47+
firebaseAnalyticsEnabled = pendingAnalyticsValue
48+
Analytics.setAnalyticsCollectionEnabled(pendingAnalyticsValue)
49+
}
50+
} message: {
51+
Text("Please consider leaving analytics enabled to help improve Django Files. We do not collect ANY personal information with analytics.")
52+
}
53+
54+
Toggle(isOn: Binding(
55+
get: { crashlyticsEnabled },
56+
set: { newValue in
57+
if !newValue {
58+
pendingCrashlyticsValue = newValue
59+
showCrashlyticsAlert = true
60+
} else {
61+
crashlyticsEnabled = newValue
62+
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(newValue)
63+
}
64+
}
65+
)) {
66+
VStack(alignment: .leading) {
67+
Text("Crash Reporting")
68+
Text("Send crash reports to help identify and fix issues")
69+
.font(.caption)
70+
.foregroundColor(.secondary)
71+
}
72+
}
73+
.alert("Disable Crash Reporting?", isPresented: $showCrashlyticsAlert) {
74+
Button("Keep Enabled", role: .cancel) {
75+
crashlyticsEnabled = true
76+
}
77+
Button("Disable", role: .destructive) {
78+
crashlyticsEnabled = pendingCrashlyticsValue
79+
Crashlytics.crashlytics().setCrashlyticsCollectionEnabled(pendingCrashlyticsValue)
80+
}
81+
} message: {
82+
Text("Please consider leaving crash analytics enabled. We collect no personal information, only information portaining to application errors.")
83+
}
84+
}
85+
}
86+
.navigationTitle("Settings")
87+
}
88+
}
89+
90+
#Preview {
91+
NavigationView {
92+
AppSettings()
93+
}
94+
}
95+

Django Files/Views/TabView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct TabViewWindow: View {
2929
}
3030

3131
enum Tab {
32-
case files, albums, shorts, serverList, userSettings, serverSettings, mobileWeb
32+
case files, albums, shorts, serverList, userSettings, serverSettings, mobileWeb, appSettings
3333
}
3434

3535
var body: some View {
@@ -101,6 +101,12 @@ struct TabViewWindow: View {
101101
Label("Server Settings", systemImage: "person.2.badge.gearshape")
102102
}
103103
.tag(Tab.serverSettings)
104+
105+
AppSettings()
106+
.tabItem {
107+
Label("App Settings", systemImage: "gear")
108+
}
109+
.tag(Tab.appSettings)
104110
}
105111
.onChange(of: sessionManager.selectedSession) { oldValue, newValue in
106112
if let session = newValue {

0 commit comments

Comments
 (0)