Skip to content

Commit

Permalink
FranzCocoa: add Mac App Store target
Browse files Browse the repository at this point in the history
  • Loading branch information
Bogdanp committed Oct 21, 2023
1 parent 9c2a9cd commit a162248
Show file tree
Hide file tree
Showing 7 changed files with 423 additions and 3 deletions.
329 changes: 329 additions & 0 deletions FranzCocoa.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

77 changes: 77 additions & 0 deletions FranzCocoa.xcodeproj/xcshareddata/xcschemes/Franz MAS.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1500"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43CDBAA12AE411A0003063D7"
BuildableName = "Franz MAS.app"
BlueprintName = "Franz MAS"
ReferencedContainer = "container:FranzCocoa.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</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 = "43CDBAA12AE411A0003063D7"
BuildableName = "Franz MAS.app"
BlueprintName = "Franz MAS"
ReferencedContainer = "container:FranzCocoa.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "43CDBAA12AE411A0003063D7"
BuildableName = "Franz MAS.app"
BlueprintName = "Franz MAS"
ReferencedContainer = "container:FranzCocoa.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
4 changes: 4 additions & 0 deletions FranzCocoa/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
FutureUtil.set(defaultErrorHandler: Error.alert(withError:))
assert(Error.wait(Backend.shared.ping()) == "pong")

#if !MAC_APP_STORE_BUILD
AutoUpdater.shared.start(
withInterval: Defaults.shared.checkForUpdates ? Defaults.shared.updateInterval.seconds * 1000 : nil,
checkingImmediately: Defaults.shared.checkForUpdates
Expand All @@ -19,6 +20,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
andRelease: release
)
}
#endif

WindowManager.shared.showWelcomeWindow()
}
Expand All @@ -44,6 +46,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
WindowManager.shared.openManual()
}

#if !MAC_APP_STORE_BUILD
@IBAction func didPushCheckForUpdatesButton(_ sender: Any) {
var canceled = false
WindowManager.shared.showUpdatesProgressWindow {
Expand All @@ -66,4 +69,5 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
)
}
#endif
}
6 changes: 3 additions & 3 deletions FranzCocoa/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="21507" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="22155" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="21507"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="22155"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand All @@ -29,7 +29,7 @@
<menuItem title="Check for Updates..." id="o5x-Uf-7h4">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="didPushCheckForUpdatesButton:" target="Voe-Tx-rLC" id="Mk7-GP-QAo"/>
<action selector="didPushCheckForUpdatesButton:" target="-1" id="gbt-vc-Wbz"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
Expand Down
4 changes: 4 additions & 0 deletions FranzCocoa/PreferencesWindowController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class PreferencesWindowController: NSWindowController {
connectionsItem.label = "Connections"
connectionsItem.viewController = NSHostingController(rootView: ConnectionsView())

#if !MAC_APP_STORE_BUILD
let licenseItem = NSTabViewItem()
licenseItem.image = .init(systemSymbolName: "checkmark.seal", accessibilityDescription: "License Tab")
licenseItem.label = "License"
Expand All @@ -44,13 +45,16 @@ class PreferencesWindowController: NSWindowController {
updatesItem.image = .init(systemSymbolName: "arrow.clockwise", accessibilityDescription: "Updates Tab")
updatesItem.label = "Updates"
updatesItem.viewController = NSHostingController(rootView: UpdatesView())
#endif

tabController.delegate = self
tabController.tabStyle = .toolbar
tabController.addTabViewItem(generalItem)
tabController.addTabViewItem(connectionsItem)
#if !MAC_APP_STORE_BUILD
tabController.addTabViewItem(licenseItem)
tabController.addTabViewItem(updatesItem)
#endif

window?.contentViewController = tabController
window?.setContentSize(.init(width: 500, height: 150))
Expand Down
4 changes: 4 additions & 0 deletions FranzCocoa/WelcomeWindowContentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class WelcomeWindowContentViewController: NSViewController {
let build = Bundle.main.object(forInfoDictionaryKey: "CFBundleVersion") ?? "Unknown"
versionLabel.stringValue = "Version \(version) (Build \(build))"

#if MAC_APP_STORE_BUILD
trialButton.isHidden = true
#else
trialButton.isHidden = true
if Error.wait(Backend.shared.getLicense()) == nil {
trialButton.isHidden = false
Expand All @@ -26,6 +29,7 @@ class WelcomeWindowContentViewController: NSViewController {
}
}
}
#endif
}

func newConnection() {
Expand Down
2 changes: 2 additions & 0 deletions FranzCocoa/WindowManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ class WindowManager {
preferringExisting preferExisting: Bool = true
) -> WorkspaceWindowController? {
assert(Thread.isMainThread)
#if !MAC_APP_STORE_BUILD
guard checkLicense() else {
return nil
}
#endif
guard let id = conn.id else {
preconditionFailure()
}
Expand Down

0 comments on commit a162248

Please sign in to comment.