Skip to content

Commit

Permalink
Added features toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
rasmuslos committed Jan 23, 2024
1 parent 01ed816 commit 3debf18
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 38 deletions.
2 changes: 0 additions & 2 deletions AmpFin.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,6 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
OTHER_SWIFT_FLAGS = "";
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -1612,7 +1611,6 @@
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = "";
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@
<key>Siri Extension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<key>Widget Extension.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
<integer>4</integer>
</dict>
<key>iOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<key>tvOS.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>2</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
Expand Down
14 changes: 0 additions & 14 deletions AmpFinKit/Package.resolved

This file was deleted.

5 changes: 2 additions & 3 deletions AmpFinKit/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@ let package = Package(
.package(url: "https://github.com/daltoniam/Starscream.git", from: "4.0.0")
],
targets: [
// Remove the underscore to disable app groups for sideloading
.target(name: "AFBase", dependencies: [.byName(name: "Starscream")], swiftSettings: [.define("_DISABLE_APP_GROUP")]),
.target(name: "AFBase", dependencies: [.byName(name: "Starscream")]),
.target(name: "AFExtension", dependencies: [.byName(name: "AFBase"), .byName(name: "AFOffline", condition: .when(platforms: [.iOS]))]),
.target(name: "AFOffline", dependencies: [.byName(name: "AFBase")], swiftSettings: [.define("_DISABLE_APP_GROUP")]),
.target(name: "AFOffline", dependencies: [.byName(name: "AFBase")]),
.target(
name: "AFPlayback",
dependencies: [
Expand Down
11 changes: 11 additions & 0 deletions AmpFinKit/Sources/AFBase/AmpFinKit.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// File.swift
//
//
// Created by Rasmus Krämer on 23.01.24.
//

import Foundation

// this sucks ass, why for the love of god
public var AFKIT_ENABLE_ALL_FEATURES = true
11 changes: 5 additions & 6 deletions AmpFinKit/Sources/AFBase/HTTP/JellyfinClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@ public class JellyfinClient {
#endif

let logger = Logger(subsystem: "io.rfk.ampfin", category: "HTTP")
#if DISABLE_APP_GROUP
#warning("UserDefaults will not be stored in group container")
static let defaults = UserDefaults.standard
#else
static let defaults = UserDefaults(suiteName: "group.io.rfk.ampfin")!
#endif
static let defaults = AFKIT_ENABLE_ALL_FEATURES ? UserDefaults(suiteName: "group.io.rfk.ampfin")! : UserDefaults.standard

init(serverUrl: URL!, token: String?, userId: String?) {
if !AFKIT_ENABLE_ALL_FEATURES {
logger.warning("User data will not be stored in an app group")
}

self.serverUrl = serverUrl
self.token = token
self.userId = userId
Expand Down
7 changes: 1 addition & 6 deletions AmpFinKit/Sources/AFOffline/PersistenceManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,7 @@ public struct PersistenceManager {
OfflinePlay.self,
OfflineFavorite.self,
])
#if DISABLE_APP_GROUP
#warning("SwiftData database will not be stored in group container")
let modelConfiguration = ModelConfiguration("AmpFin", schema: schema, isStoredInMemoryOnly: false, allowsSave: true, groupContainer: .identifier("group.io.rfk.ampfin"))
#else
let modelConfiguration = ModelConfiguration("AmpFin", schema: schema, isStoredInMemoryOnly: false, allowsSave: true)
#endif
let modelConfiguration = ModelConfiguration("AmpFin", schema: schema, isStoredInMemoryOnly: false, allowsSave: true, groupContainer: AFKIT_ENABLE_ALL_FEATURES ? .identifier("group.io.rfk.ampfin") : .none)

do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
Expand Down
1 change: 1 addition & 0 deletions Config/Base.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
// https://help.apple.com/xcode/#/dev745c5c974

MARKETING_VERSION = 1.2.2
SWIFT_ACTIVE_COMPILATION_CONDITIONS = ENABLE_ALL_FEATURES
3 changes: 3 additions & 0 deletions Config/Debug.xcconfig.template
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@

#include "Base.xcconfig"


SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG ENABLE_ALL_FEATURES

DEVELOPMENT_TEAM = ABC123456
BUNDLE_ID_PREFIX = me.change
2 changes: 2 additions & 0 deletions iOS/Core/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ struct ContentView: View {
.onAppear {
SpotlightHelper.donate()
INMediaUserContext.donate()
#if ENABLE_ALL_FEATURES
INPreferences.requestSiriAuthorization { _ in }
#endif

OfflineManager.shared.updateOfflineItems()
OfflineManager.shared.syncPlaysToJellyfinServer()
Expand Down
4 changes: 4 additions & 0 deletions iOS/Core/iOSApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ struct iOSApp: App {
@UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

init() {
#if !ENABLE_ALL_FEATURES
AFKIT_ENABLE_ALL_FEATURES = false
#endif

try? Tips.configure([
.displayFrequency(.daily)
])
Expand Down
1 change: 0 additions & 1 deletion iOS/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@
}
},
"developedBy" : {
"extractionState" : "stale",
"localizations" : {
"de" : {
"stringUnit" : {
Expand Down
2 changes: 1 addition & 1 deletion iOS/Presentation/Views/Account/AccountSheet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ struct AccountSheet: View {
.foregroundStyle(.secondary)
}

#if DEBUG
#if !ENABLE_ALL_FEATURES
// quite ironic that this code is bad
Section {
HStack {
Expand Down
2 changes: 1 addition & 1 deletion iOS/Presentation/Views/Account/LoginView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct LoginView: View {

Spacer()

#if DEBUG
#if !ENABLE_ALL_FEATURES
Text("developedBy")
.font(.caption)
.foregroundStyle(.secondary)
Expand Down

0 comments on commit 3debf18

Please sign in to comment.