Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
318 changes: 314 additions & 4 deletions BitDream.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "2630"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "NO"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6A2000064200000000B1C2D3"
BuildableName = "BitDream.app"
BlueprintName = "BitDreamAppStore"
ReferencedContainer = "container:BitDream.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6A2000064200000000B1C2D3"
BuildableName = "BitDream.app"
BlueprintName = "BitDreamAppStore"
ReferencedContainer = "container:BitDream.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6A2000064200000000B1C2D3"
BuildableName = "BitDream.app"
BlueprintName = "BitDreamAppStore"
ReferencedContainer = "container:BitDream.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
2 changes: 1 addition & 1 deletion BitDream/AppUpdater.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if os(macOS)
#if os(macOS) && canImport(Sparkle)
import Foundation
import Sparkle

Expand Down
18 changes: 16 additions & 2 deletions BitDream/BitDreamApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ struct BitDreamApp: App {
@NSApplicationDelegateAdaptor(AppFileOpenDelegate.self) private var appFileOpenDelegate
@StateObject private var menuBarStatusItemController = MenuBarStatusItemBridge()
@StateObject private var dockBadgeController = DockBadgeController()
#if canImport(Sparkle)
@StateObject private var appUpdater = AppUpdater()
#endif
@StateObject private var serverEditingCoordinator = MacOSServerEditingCoordinator()
#endif

Expand Down Expand Up @@ -119,7 +121,9 @@ private extension BitDreamApp {
ensureStartupConnectionBehaviorApplied(store: store, modelContext: persistenceController.container.mainContext)
syncMenuBarStatusItem()
dockBadgeController.configure(store: store)
#if canImport(Sparkle)
appUpdater.start()
#endif
}
.onChange(of: menuBarTransferWidgetEnabled) { _, isEnabled in
syncMenuBarStatusItem(isEnabled: isEnabled)
Expand Down Expand Up @@ -230,7 +234,11 @@ private extension BitDreamApp {
}
.windowResizability(.contentSize)
.commands {
#if canImport(Sparkle)
AppCommands(appUpdater: appUpdater)
#else
AppCommands()
#endif
CommandGroup(replacing: .newItem) { }
FileCommands(store: store)
SearchCommands(store: store)
Expand Down Expand Up @@ -306,9 +314,15 @@ private extension BitDreamApp {

var settingsScene: some Scene {
Settings {
SettingsView(store: store) // Use the same store instance
Group {
#if canImport(Sparkle)
SettingsView(store: store)
.environmentObject(appUpdater)
#else
SettingsView(store: store)
#endif
}
.frame(minWidth: 500, idealWidth: 550, maxWidth: 650)
.environmentObject(appUpdater)
.environmentObject(themeManager) // Pass the ThemeManager to the Settings view
.immediateTheme(manager: themeManager)
}
Expand Down
68 changes: 68 additions & 0 deletions BitDream/Info-AppStore.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeName</key>
<string>BitTorrent File</string>
<key>LSItemContentTypes</key>
<array>
<string>org.bittorrent.torrent</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>LSHandlerRank</key>
<string>Owner</string>
</dict>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>BitDream Magnet</string>
<key>CFBundleURLSchemes</key>
<array>
<string>magnet</string>
</array>
</dict>
<dict>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
<key>CFBundleURLName</key>
<string>BitDream</string>
<key>CFBundleURLSchemes</key>
<array>
<string>bitdream</string>
</array>
</dict>
</array>
<key>LSSupportsOpeningDocumentsInPlace</key>
<true/>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>org.bittorrent.torrent</string>
<key>UTTypeDescription</key>
<string>BitTorrent file</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.data</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>torrent</string>
</array>
<key>public.mime-type</key>
<string>application/x-bittorrent</string>
</dict>
</dict>
</array>
</dict>
</plist>
13 changes: 10 additions & 3 deletions BitDream/PreviewSupport/PreviewSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ final class PreviewEnvironment {
#if os(iOS)
let appIconManager: AppIconManager
#endif
#if os(macOS)
#if os(macOS) && canImport(Sparkle)
let appUpdater: AppUpdater
#endif
#if os(macOS)
let serverEditingCoordinator: MacOSServerEditingCoordinator
#endif

Expand All @@ -47,8 +49,10 @@ final class PreviewEnvironment {
#if os(iOS)
self.appIconManager = AppIconManager.inert()
#endif
#if os(macOS)
#if os(macOS) && canImport(Sparkle)
self.appUpdater = AppUpdater(updatesEnabled: false)
#endif
#if os(macOS)
self.serverEditingCoordinator = MacOSServerEditingCoordinator()
#endif
}
Expand Down Expand Up @@ -83,10 +87,13 @@ struct PreviewContainer<Content: View>: View {

@ViewBuilder
private var configuredContent: some View {
#if os(macOS)
#if os(macOS) && canImport(Sparkle)
content(previewEnvironment)
.environmentObject(previewEnvironment.appUpdater)
.environmentObject(previewEnvironment.serverEditingCoordinator)
#elseif os(macOS)
content(previewEnvironment)
.environmentObject(previewEnvironment.serverEditingCoordinator)
#elseif os(iOS)
content(previewEnvironment)
.environmentObject(previewEnvironment.appIconManager)
Expand Down
22 changes: 13 additions & 9 deletions BitDream/Views/macOS/Settings/macOSGeneralSettingsTab.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import Foundation
#if os(macOS)
struct macOSGeneralSettingsTab: View {
@Environment(\.appUserDefaults) private var userDefaults
#if canImport(Sparkle)
@EnvironmentObject private var appUpdater: AppUpdater
#endif
@EnvironmentObject private var themeManager: ThemeManager
@ObservedObject var store: TransmissionStore

Expand All @@ -24,7 +26,8 @@ struct macOSGeneralSettingsTab: View {
)
}

private var automaticallyChecksForUpdatesBinding: Binding<Bool> {
#if canImport(Sparkle)
private var automaticallyChecksForUpdates: Binding<Bool> {
Binding<Bool>(
get: { appUpdater.automaticallyChecksForUpdates },
set: { appUpdater.automaticallyChecksForUpdates = $0 }
Expand All @@ -35,6 +38,7 @@ struct macOSGeneralSettingsTab: View {
guard let date = appUpdater.lastUpdateCheckDate else { return "Never" }
return date.formatted(Date.FormatStyle(date: .abbreviated, time: .shortened))
}
#endif

var body: some View {
VStack(alignment: .leading, spacing: 20) {
Expand Down Expand Up @@ -150,15 +154,13 @@ struct macOSGeneralSettingsTab: View {
}
}

#if canImport(Sparkle)
divider

settingsSection("Updates") {
Toggle("Automatically check for updates", isOn: automaticallyChecksForUpdatesBinding)
Toggle("Automatically check for updates", isOn: automaticallyChecksForUpdates)

HStack(alignment: .firstTextBaseline) {
Button("Check for Updates…") {
appUpdater.checkForUpdates()
}
Button("Check for Updates…", action: appUpdater.checkForUpdates)
.disabled(!appUpdater.canCheckForUpdates)

Spacer()
Expand All @@ -168,6 +170,7 @@ struct macOSGeneralSettingsTab: View {
.foregroundStyle(.tertiary)
}
}
#endif

divider

Expand All @@ -192,9 +195,10 @@ struct macOSGeneralSettingsTab: View {
store: store,
themeManager: themeManager,
userDefaults: userDefaults
) {
appUpdater.resetToDefaults()
}
)
#if canImport(Sparkle)
appUpdater.resetToDefaults()
#endif
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions BitDream/Views/macOS/macOSMenuCommands.swift
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,9 @@ struct AppearanceCommands: Commands {

struct AppCommands: Commands {
@Environment(\.openWindow) private var openWindow
#if canImport(Sparkle)
@ObservedObject var appUpdater: AppUpdater
#endif

var body: some Commands {
CommandGroup(replacing: .appInfo) {
Expand All @@ -403,12 +405,12 @@ struct AppCommands: Commands {
Label("About BitDream", systemImage: "info.circle")
})

Button(action: {
appUpdater.checkForUpdates()
}, label: {
#if canImport(Sparkle)
Button(action: appUpdater.checkForUpdates) {
Label("Check for Updates…", systemImage: "square.and.arrow.down")
})
}
.disabled(!appUpdater.canCheckForUpdates)
#endif
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions docs/build-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@
- `Config/BuildSettings.example.local.xcconfig` (tracked): template for local setup.
- `Config/BuildSettings.local.xcconfig` (ignored): required local/CI overrides.

These files configure the direct-download `BitDream` target. The
`BitDreamAppStore` target neither reads Sparkle settings nor requires a local
override file.

## Local Setup
1. Copy `Config/BuildSettings.example.local.xcconfig` to `Config/BuildSettings.local.xcconfig`.
2. Set local values (currently `SPARKLE_APPCAST_URL` and `SPARKLE_PUBLIC_KEY`).

## CI / Release
- CI writes `Config/BuildSettings.local.xcconfig` before archive builds.
- For Sparkle, release workflow uses repo variables `SPARKLE_APPCAST_URL` and `SPARKLE_PUBLIC_KEY`.
- The Mac App Store build uses its dedicated Sparkle-free target and scheme.
Loading
Loading