From 2b72690b8c73671ea85dea6cbc0095c9bc814c91 Mon Sep 17 00:00:00 2001 From: James Harvey <44349936+jmshrv@users.noreply.github.com> Date: Fri, 26 Apr 2024 21:38:28 +0100 Subject: [PATCH] Initial Sparkle support --- MacIguana.xcodeproj/project.pbxproj | 35 ++++++++++++--- .../xcshareddata/swiftpm/Package.resolved | 11 ++++- .../Extensions/UInt8+JimulatorConvert.swift | 15 ------- MacIguana/Info.plist | 7 ++- MacIguana/MacIguanaApp.swift | 44 +++++++++++++++++++ MacIguana/Views/TerminalTextView.swift | 2 +- appcast.xml | 14 ++++++ 7 files changed, 105 insertions(+), 23 deletions(-) create mode 100644 appcast.xml diff --git a/MacIguana.xcodeproj/project.pbxproj b/MacIguana.xcodeproj/project.pbxproj index 151389a..0bceca8 100644 --- a/MacIguana.xcodeproj/project.pbxproj +++ b/MacIguana.xcodeproj/project.pbxproj @@ -16,9 +16,11 @@ 1A401C292AE81995003EB398 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A401C282AE81995003EB398 /* Assets.xcassets */; }; 1A401C2C2AE81995003EB398 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A401C2B2AE81995003EB398 /* Preview Assets.xcassets */; }; 1A480F7E2BA9FEAB0016A17D /* AssemblyLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A480F7D2BA9FEAB0016A17D /* AssemblyLoader.swift */; }; - 1A4ACDC72BD9957A005DFCC3 /* UInt8+JimulatorConvert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A4ACDC62BD9957A005DFCC3 /* UInt8+JimulatorConvert.swift */; }; + 1A4ACDCA2BD99788005DFCC3 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 1A4ACDC92BD99788005DFCC3 /* Sparkle */; }; 1A5391DF2BBB18FA003CBD84 /* MemoryList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5391DE2BBB18FA003CBD84 /* MemoryList.swift */; }; 1A5ACF6D2BBDA03300D66C3B /* KmdparseWord+isInstruction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A5ACF6C2BBDA03300D66C3B /* KmdparseWord+isInstruction.swift */; }; + 1A679F8E2BDC09E00017FCC2 /* UInt8+JimulatorConvert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A679F8D2BDC09E00017FCC2 /* UInt8+JimulatorConvert.swift */; }; + 1A679F902BDC47FA0017FCC2 /* appcast.xml in Resources */ = {isa = PBXBuildFile; fileRef = 1A679F8F2BDC47FA0017FCC2 /* appcast.xml */; }; 1A6D60F42BB8A5530077C04D /* LibiguanaError+LocalizedError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A6D60F32BB8A5530077C04D /* LibiguanaError+LocalizedError.swift */; }; 1A742BA72B979F5900BFB27A /* BoardStatePane.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A742BA62B979F5900BFB27A /* BoardStatePane.swift */; }; 1A742BA92B97A06D00BFB27A /* Status+CustomStringConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A742BA82B97A06D00BFB27A /* Status+CustomStringConvertible.swift */; }; @@ -49,10 +51,11 @@ 1A401C2B2AE81995003EB398 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; 1A401C2D2AE81995003EB398 /* MacIguana.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = MacIguana.entitlements; sourceTree = ""; }; 1A480F7D2BA9FEAB0016A17D /* AssemblyLoader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AssemblyLoader.swift; sourceTree = ""; }; - 1A4ACDC62BD9957A005DFCC3 /* UInt8+JimulatorConvert.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = "UInt8+JimulatorConvert.swift"; path = "../../../../../.Trash/UInt8+JimulatorConvert.swift"; sourceTree = ""; }; 1A5391DE2BBB18FA003CBD84 /* MemoryList.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryList.swift; sourceTree = ""; }; 1A5ACF6C2BBDA03300D66C3B /* KmdparseWord+isInstruction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "KmdparseWord+isInstruction.swift"; sourceTree = ""; }; 1A64AE402BC42FB0008E53DB /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; + 1A679F8D2BDC09E00017FCC2 /* UInt8+JimulatorConvert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "UInt8+JimulatorConvert.swift"; sourceTree = ""; }; + 1A679F8F2BDC47FA0017FCC2 /* appcast.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = appcast.xml; sourceTree = ""; }; 1A6D60F32BB8A5530077C04D /* LibiguanaError+LocalizedError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "LibiguanaError+LocalizedError.swift"; sourceTree = ""; }; 1A742BA62B979F5900BFB27A /* BoardStatePane.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BoardStatePane.swift; sourceTree = ""; }; 1A742BA82B97A06D00BFB27A /* Status+CustomStringConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Status+CustomStringConvertible.swift"; sourceTree = ""; }; @@ -73,6 +76,7 @@ buildActionMask = 2147483647; files = ( 1AFCEA8D2B86292A000FE4C1 /* Libiguana in Frameworks */, + 1A4ACDCA2BD99788005DFCC3 /* Sparkle in Frameworks */, 1AFCEA902B862966000FE4C1 /* Libiguana in Frameworks */, 1AFCEA842B86219C000FE4C1 /* Libiguana in Frameworks */, 1A84188D2B9F1C59006CC42C /* Libiguana in Frameworks */, @@ -88,6 +92,7 @@ 1A401C182AE81994003EB398 = { isa = PBXGroup; children = ( + 1A679F8F2BDC47FA0017FCC2 /* appcast.xml */, 1A64AE402BC42FB0008E53DB /* README.md */, 1A401C232AE81994003EB398 /* MacIguana */, 1A401C222AE81994003EB398 /* Products */, @@ -150,7 +155,7 @@ 1A948C362B880EF3001515F0 /* Registers+list.swift */, 1AB33E452B9698F3007468AA /* Registers+zero.swift */, 1A742BA82B97A06D00BFB27A /* Status+CustomStringConvertible.swift */, - 1A4ACDC62BD9957A005DFCC3 /* UInt8+JimulatorConvert.swift */, + 1A679F8D2BDC09E00017FCC2 /* UInt8+JimulatorConvert.swift */, ); path = Extensions; sourceTree = ""; @@ -189,6 +194,7 @@ 1A12D2CA2B87C06600639258 /* Libiguana */, 1A8418892B9F1BF8006CC42C /* Libiguana */, 1A84188C2B9F1C59006CC42C /* Libiguana */, + 1A4ACDC92BD99788005DFCC3 /* Sparkle */, ); productName = MacIguana; productReference = 1A401C212AE81994003EB398 /* MacIguana.app */; @@ -202,7 +208,7 @@ attributes = { BuildIndependentTargetsInParallel = 1; LastSwiftUpdateCheck = 1500; - LastUpgradeCheck = 1500; + LastUpgradeCheck = 1530; TargetAttributes = { 1A401C202AE81994003EB398 = { CreatedOnToolsVersion = 15.0.1; @@ -220,6 +226,7 @@ mainGroup = 1A401C182AE81994003EB398; packageReferences = ( 1A84188B2B9F1C59006CC42C /* XCRemoteSwiftPackageReference "libiguana-swift" */, + 1A4ACDC82BD99788005DFCC3 /* XCRemoteSwiftPackageReference "Sparkle" */, ); productRefGroup = 1A401C222AE81994003EB398 /* Products */; projectDirPath = ""; @@ -237,6 +244,7 @@ files = ( 1A401C2C2AE81995003EB398 /* Preview Assets.xcassets in Resources */, 1A401C292AE81995003EB398 /* Assets.xcassets in Resources */, + 1A679F902BDC47FA0017FCC2 /* appcast.xml in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -253,7 +261,7 @@ 1AFCEA8A2B86264C000FE4C1 /* SwiftIguanaEnvironment.swift in Sources */, 1A401C272AE81994003EB398 /* ContentView.swift in Sources */, 1A742BA72B979F5900BFB27A /* BoardStatePane.swift in Sources */, - 1A4ACDC72BD9957A005DFCC3 /* UInt8+JimulatorConvert.swift in Sources */, + 1A679F8E2BDC09E00017FCC2 /* UInt8+JimulatorConvert.swift in Sources */, 1A480F7E2BA9FEAB0016A17D /* AssemblyLoader.swift in Sources */, 1A401C252AE81994003EB398 /* MacIguanaApp.swift in Sources */, 1A5391DF2BBB18FA003CBD84 /* MemoryList.swift in Sources */, @@ -307,6 +315,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -370,6 +379,7 @@ CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COPY_PHASE_STRIP = NO; + DEAD_CODE_STRIPPING = YES; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -400,6 +410,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"MacIguana/Preview Content\""; DEVELOPMENT_TEAM = PFNS8PTRM7; ENABLE_HARDENED_RUNTIME = YES; @@ -429,6 +440,7 @@ CODE_SIGN_STYLE = Automatic; COMBINE_HIDPI_IMAGES = YES; CURRENT_PROJECT_VERSION = 1; + DEAD_CODE_STRIPPING = YES; DEVELOPMENT_ASSET_PATHS = "\"MacIguana/Preview Content\""; DEVELOPMENT_TEAM = PFNS8PTRM7; ENABLE_HARDENED_RUNTIME = YES; @@ -473,6 +485,14 @@ /* End XCConfigurationList section */ /* Begin XCRemoteSwiftPackageReference section */ + 1A4ACDC82BD99788005DFCC3 /* XCRemoteSwiftPackageReference "Sparkle" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/sparkle-project/Sparkle"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.6.0; + }; + }; 1A84188B2B9F1C59006CC42C /* XCRemoteSwiftPackageReference "libiguana-swift" */ = { isa = XCRemoteSwiftPackageReference; repositoryURL = "https://github.com/iguana-debugger/libiguana-swift"; @@ -488,6 +508,11 @@ isa = XCSwiftPackageProductDependency; productName = Libiguana; }; + 1A4ACDC92BD99788005DFCC3 /* Sparkle */ = { + isa = XCSwiftPackageProductDependency; + package = 1A4ACDC82BD99788005DFCC3 /* XCRemoteSwiftPackageReference "Sparkle" */; + productName = Sparkle; + }; 1A8418892B9F1BF8006CC42C /* Libiguana */ = { isa = XCSwiftPackageProductDependency; productName = Libiguana; diff --git a/MacIguana.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/MacIguana.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index aae4d12..cfe2159 100644 --- a/MacIguana.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/MacIguana.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -1,5 +1,5 @@ { - "originHash" : "9d1e0708ec0134e497f0fd9d95907d62b5eb34fba6e26fa9e80eece008b9a685", + "originHash" : "4d61b311e8d5ef7674d97f2bc43b4bbdb200c601483bbfd976ba28c4b4b50f6a", "pins" : [ { "identity" : "libiguana-swift", @@ -9,6 +9,15 @@ "branch" : "main", "revision" : "20cd1a090a52fa3082e176c9000f8f5d357b9b36" } + }, + { + "identity" : "sparkle", + "kind" : "remoteSourceControl", + "location" : "https://github.com/sparkle-project/Sparkle", + "state" : { + "revision" : "0a4caaf7a81eea2cece651ef4b17331fa0634dff", + "version" : "2.6.0" + } } ], "version" : 3 diff --git a/MacIguana/Extensions/UInt8+JimulatorConvert.swift b/MacIguana/Extensions/UInt8+JimulatorConvert.swift index 0f1eeb8..8d51356 100644 --- a/MacIguana/Extensions/UInt8+JimulatorConvert.swift +++ b/MacIguana/Extensions/UInt8+JimulatorConvert.swift @@ -6,7 +6,6 @@ // import Foundation -import SwiftTerm /// Functions for converting to/from Jimulator for SwiftTerm extension UInt8 { @@ -21,18 +20,4 @@ extension UInt8 { return self } } - - /// Converts a Jimulator keycode to a terminal keycode - func terminal(_ xpos: Int) -> [UInt8] { - switch self { - case 8: // Backspace - if xpos == 0 { - return [27, 77] + EscapeSequences.moveEndNormal + [8, 127, 8] // ESC M, end, followed by backspace - } else { - return [8, 127, 8] - } - default: - return [self] - } - } } diff --git a/MacIguana/Info.plist b/MacIguana/Info.plist index 0c67376..2cf0420 100644 --- a/MacIguana/Info.plist +++ b/MacIguana/Info.plist @@ -1,5 +1,10 @@ - + + SUFeedURL + https://raw.githubusercontent.com/iguana-debugger/MacIguana/main/appcast.xml + SUPublicEDKey + i++WpK0lLKWG8hhIqjYXHVg5a1+cxJxRQSE1dNF/9AY= + diff --git a/MacIguana/MacIguanaApp.swift b/MacIguana/MacIguanaApp.swift index 4778ff9..3b291ba 100644 --- a/MacIguana/MacIguanaApp.swift +++ b/MacIguana/MacIguanaApp.swift @@ -7,9 +7,48 @@ import SwiftUI import Libiguana +import Sparkle + +// This view model class publishes when new updates can be checked by the user +final class CheckForUpdatesViewModel: ObservableObject { + @Published var canCheckForUpdates = false + + init(updater: SPUUpdater) { + updater.publisher(for: \.canCheckForUpdates) + .assign(to: &$canCheckForUpdates) + } +} + +// This is the view for the Check for Updates menu item +// Note this intermediate view is necessary for the disabled state on the menu item to work properly before Monterey. +// See https://stackoverflow.com/questions/68553092/menu-not-updating-swiftui-bug for more info +struct CheckForUpdatesView: View { + @ObservedObject private var checkForUpdatesViewModel: CheckForUpdatesViewModel + private let updater: SPUUpdater + + init(updater: SPUUpdater) { + self.updater = updater + + // Create our view model for our CheckForUpdatesView + self.checkForUpdatesViewModel = CheckForUpdatesViewModel(updater: updater) + } + + var body: some View { + Button("Check for Updates…", action: updater.checkForUpdates) + .disabled(!checkForUpdatesViewModel.canCheckForUpdates) + } +} @main struct MacIguanaApp: App { + private let updaterController: SPUStandardUpdaterController + + init() { + // If you want to start the updater manually, pass false to startingUpdater and call .startUpdater() later + // This is where you can also pass an updater delegate if you need one + updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil) + } + var body: some Scene { DocumentGroup(viewing: KomodoDocument.self) { document in if let url = document.fileURL { @@ -19,5 +58,10 @@ struct MacIguanaApp: App { } } .defaultSize(width: 1200, height: 800) + .commands { + CommandGroup(after: .appInfo) { + CheckForUpdatesView(updater: updaterController.updater) + } + } } } diff --git a/MacIguana/Views/TerminalTextView.swift b/MacIguana/Views/TerminalTextView.swift index 8de761f..9fc1202 100644 --- a/MacIguana/Views/TerminalTextView.swift +++ b/MacIguana/Views/TerminalTextView.swift @@ -33,7 +33,7 @@ struct TerminalTextView: NSViewRepresentable { } func textView(_ textView: NSTextView, shouldChangeTextIn affectedCharRange: NSRange, replacementString: String?) -> Bool { - let documentLength = textView.textStorage?.length ?? 0 +// let documentLength = textView.textStorage?.length ?? 0 // If the location isn't at the end of the document, don't allow the input. This also stops stuff like // selecting text to overwrite the document. diff --git a/appcast.xml b/appcast.xml new file mode 100644 index 0000000..e417532 --- /dev/null +++ b/appcast.xml @@ -0,0 +1,14 @@ + + + + MacIguana + + 1.0 + Fri, 26 Apr 2024 17:58:01 +0100 + 1 + 1.0 + 14.0 + + + + \ No newline at end of file