diff --git a/Autoupdate/AppInstaller.m b/Autoupdate/AppInstaller.m index f0c3232e..4f98a88a 100644 --- a/Autoupdate/AppInstaller.m +++ b/Autoupdate/AppInstaller.m @@ -35,7 +35,7 @@ #define FIRST_UPDATER_MESSAGE_TIMEOUT 7ull #define RETRIEVE_PROCESS_IDENTIFIER_TIMEOUT 5ull -/*! +/** * Show display progress UI after a delay from starting the final part of the installation. * This should be long enough so that we don't show progress for very fast installations, but * short enough so that we don't leave the user wondering why nothing is happening. diff --git a/Autoupdate/SUGuidedPackageInstaller.h b/Autoupdate/SUGuidedPackageInstaller.h index 8bdef5e5..5ba4c4be 100644 --- a/Autoupdate/SUGuidedPackageInstaller.h +++ b/Autoupdate/SUGuidedPackageInstaller.h @@ -6,7 +6,7 @@ // Copyright 2010 Dragon Systems Software Limited. All rights reserved. // -/*! +/** # Sparkle Guided Installations A guided installation allows Sparkle to download and install a package (pkg) or multi-package (mpkg) without user interaction. diff --git a/Autoupdate/SUPlainInstaller.h b/Autoupdate/SUPlainInstaller.h index 8820d81c..6cee3006 100644 --- a/Autoupdate/SUPlainInstaller.h +++ b/Autoupdate/SUPlainInstaller.h @@ -14,7 +14,7 @@ @interface SUPlainInstaller : NSObject -/*! +/** @param host The current (old) bundle host @param bundlePath The path to the new bundle that will be installed. @param installationPath The path the new bundlePath will be installed to. diff --git a/Documentation/build-docs.sh b/Documentation/build-docs.sh deleted file mode 100755 index d27280d3..00000000 --- a/Documentation/build-docs.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -if [ "$ACTION" = "" ] ; then - if which -s doxygen ; then - doxygen Documentation/Doxyfile - else - echo "warning: Doxygen not found in PATH" - echo "open Terminal and type this command 'brew install doxygen' then click 'enter/return' key. finally build this target again" - fi -elif [ "$ACTION" = "clean" ] ; then - rm -rf "$SRCROOT/Documentation/html" -fi diff --git a/Makefile b/Makefile index 6c35fa7d..e468b469 100644 --- a/Makefile +++ b/Makefile @@ -22,26 +22,14 @@ release: build: xcodebuild clean build - -test: - xcodebuild -scheme Distribution -configuration Debug test - ./objc_dep/objc_dep.py -t . + +# Need to first gem install jazzy to run this rule +docs: + jazzy --objc --umbrella-header Sparkle/Sparkle.h --framework-root . --output Documentation/html uitest: xcodebuild -scheme UITests -configuration Debug test -ci: - for i in {7..9} ; do \ - if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \ - ( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build ) || exit 1 ; \ - fi ; \ - done - for i in {10..12} ; do \ - if xcrun --sdk "macosx10.$$i" --show-sdk-path 2> /dev/null ; then \ - ( rm -rf build && xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Coverage -derivedDataPath build test ) || exit 1 ; \ - fi ; \ - done - check-localizations: ./Sparkle/CheckLocalizations.swift -root . -htmlPath "$(TMPDIR)/LocalizationsReport.htm" open "$(TMPDIR)/LocalizationsReport.htm" diff --git a/Sparkle.xcodeproj/project.pbxproj b/Sparkle.xcodeproj/project.pbxproj index 9a191431..6c29351d 100644 --- a/Sparkle.xcodeproj/project.pbxproj +++ b/Sparkle.xcodeproj/project.pbxproj @@ -442,13 +442,6 @@ remoteGlobalIDString = 61B5F90109C4CEE200B25A18; remoteInfo = "Sparkle Test App"; }; - 1454BA1719637EE900344E57 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 1420DF491962329200203BB0; - remoteInfo = Documentation; - }; 14732BCA1960F73500593899 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = 0867D690FE84028FC02AAC07 /* Project object */; @@ -811,7 +804,6 @@ 0263187214FEBB31005EBF43 /* uk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = uk; path = uk.lproj/Sparkle.strings; sourceTree = ""; }; 0867D69BFE84028FC02AAC07 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 0867D6A5FE840307C02AAC07 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; - 1420DF4D196247B500203BB0 /* build-docs.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = "build-docs.sh"; sourceTree = ""; }; 1420DF4E196247B500203BB0 /* Doxyfile */ = {isa = PBXFileReference; lastKnownFileType = text; path = Doxyfile; sourceTree = ""; }; 1420DF4F196247F900203BB0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 142E0E0819A83AAC00E4312B /* SUBinaryDeltaTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUBinaryDeltaTest.m; sourceTree = ""; }; @@ -1608,7 +1600,6 @@ children = ( 1420DF4E196247B500203BB0 /* Doxyfile */, 721D8A891D4D273E0032E472 /* Internal */, - 1420DF4D196247B500203BB0 /* build-docs.sh */, ); path = Documentation; sourceTree = ""; @@ -2401,20 +2392,6 @@ /* End PBXHeadersBuildPhase section */ /* Begin PBXLegacyTarget section */ - 1420DF491962329200203BB0 /* Documentation */ = { - isa = PBXLegacyTarget; - buildArgumentsString = "\"$(SRCROOT)/Documentation/build-docs.sh\" $(ACTION)"; - buildConfigurationList = 1420DF4A1962329200203BB0 /* Build configuration list for PBXLegacyTarget "Documentation" */; - buildPhases = ( - ); - buildToolPath = bash; - buildWorkingDirectory = ""; - dependencies = ( - ); - name = Documentation; - passBuildSettingsInEnvironment = 1; - productName = Documentation; - }; 14732BC51960F69300593899 /* Distribution */ = { isa = PBXLegacyTarget; buildArgumentsString = "$(SRCROOT)/Configurations/make-release-package.sh $(ACTION)"; @@ -2435,7 +2412,6 @@ 7205C46B1E13070300E370AE /* PBXTargetDependency */, FA344BA724C869A300B2A401 /* PBXTargetDependency */, FA344BA524C8699E00B2A401 /* PBXTargetDependency */, - 1454BA1819637EE900344E57 /* PBXTargetDependency */, 895C5DC724D78F700058A82D /* PBXTargetDependency */, ); name = Distribution; @@ -2940,7 +2916,6 @@ 72D9549D1CBB415B006F28BD /* sparkle-cli */, 721C24441CB753E6005440CB /* Installer Progress */, 14732BC51960F69300593899 /* Distribution */, - 1420DF491962329200203BB0 /* Documentation */, 1495005F195FB89400BC5B5B /* All */, 895C5DC024D78E210058A82D /* XCFrameworks */, 726B2B5C1C645FC900388755 /* UI Tests */, @@ -3552,11 +3527,6 @@ target = 61B5F90109C4CEE200B25A18 /* Sparkle Test App */; targetProxy = 1454BA1519637EDB00344E57 /* PBXContainerItemProxy */; }; - 1454BA1819637EE900344E57 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 1420DF491962329200203BB0 /* Documentation */; - targetProxy = 1454BA1719637EE900344E57 /* PBXContainerItemProxy */; - }; 14732BCB1960F73500593899 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = 8DC2EF4F0486A6940098B216 /* Sparkle */; @@ -3882,18 +3852,6 @@ /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ - 1420DF4B1962329200203BB0 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - }; - name = Debug; - }; - 1420DF4C1962329200203BB0 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - }; - name = Release; - }; 14732BC71960F69300593899 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { @@ -3959,12 +3917,6 @@ }; name = Coverage; }; - 149B78611B7D398100D7D62C /* Coverage */ = { - isa = XCBuildConfiguration; - buildSettings = { - }; - name = Coverage; - }; 149B78621B7D398100D7D62C /* Coverage */ = { isa = XCBuildConfiguration; buildSettings = { @@ -4365,16 +4317,6 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - 1420DF4A1962329200203BB0 /* Build configuration list for PBXLegacyTarget "Documentation" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1420DF4B1962329200203BB0 /* Debug */, - 149B78611B7D398100D7D62C /* Coverage */, - 1420DF4C1962329200203BB0 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; 14732BC61960F69300593899 /* Build configuration list for PBXLegacyTarget "Distribution" */ = { isa = XCConfigurationList; buildConfigurations = ( diff --git a/Sparkle/InstallerProgress/InstallerProgressAppController.m b/Sparkle/InstallerProgress/InstallerProgressAppController.m index f4360436..71ab1816 100644 --- a/Sparkle/InstallerProgress/InstallerProgressAppController.m +++ b/Sparkle/InstallerProgress/InstallerProgressAppController.m @@ -22,7 +22,7 @@ #import "SPUSecureCoding.h" #import "SPUInstallationInfo.h" -/*! +/** * Terminate the application after a delay from launching the new update to avoid OS activation issues * This delay should be be high enough to increase the likelihood that our updated app will be launched up front, * but should be low enough so that the user doesn't ponder why the updater hasn't finished terminating yet diff --git a/Sparkle/SPUAppcastItemStateResolver.h b/Sparkle/SPUAppcastItemStateResolver.h index d80f7b96..3d81d0b7 100644 --- a/Sparkle/SPUAppcastItemStateResolver.h +++ b/Sparkle/SPUAppcastItemStateResolver.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN @class SUStandardVersionComparator, SPUAppcastItemState; @protocol SUVersionComparison; -/*! +/** Private exposed class used to resolve Appcast Item properties that rely on external factors such as a host. This resolver is used for constructing appcast items. */ diff --git a/Sparkle/SPUDownloadData.h b/Sparkle/SPUDownloadData.h index 67da4d03..d0ca9935 100644 --- a/Sparkle/SPUDownloadData.h +++ b/Sparkle/SPUDownloadData.h @@ -27,31 +27,31 @@ NS_ASSUME_NONNULL_BEGIN -/*! +/** * A class for containing downloaded data along with some information about it. */ SU_EXPORT @interface SPUDownloadData : NSObject - (instancetype)initWithData:(NSData *)data URL:(NSURL *)URL textEncodingName:(NSString * _Nullable)textEncodingName MIMEType:(NSString * _Nullable)MIMEType; -/*! +/** * The raw data that was downloaded. */ @property (nonatomic, readonly) NSData *data; -/*! +/** * The URL that was fetched from. * * This may be different from the URL in the request if there were redirects involved. */ @property (nonatomic, readonly, copy) NSURL *URL; -/*! +/** * The IANA charset encoding name if available. Eg: "utf-8" */ @property (nonatomic, readonly, nullable, copy) NSString *textEncodingName; -/*! +/** * The MIME type if available. Eg: "text/plain" */ @property (nonatomic, readonly, nullable, copy) NSString *MIMEType; diff --git a/Sparkle/SPUStandardUpdaterController.h b/Sparkle/SPUStandardUpdaterController.h index 4e8c0e19..2cf1ce30 100644 --- a/Sparkle/SPUStandardUpdaterController.h +++ b/Sparkle/SPUStandardUpdaterController.h @@ -23,95 +23,94 @@ NS_ASSUME_NONNULL_BEGIN @class NSMenuItem; @protocol SPUUserDriver, SPUUpdaterDelegate, SPUStandardUserDriverDelegate; -/*! - A controller class that instantiates a SPUUpdater and allows binding UI to it. +/** + A controller class that instantiates a `SPUUpdater` and allows binding UI to it. - This class can be instantiated in a nib or created programatically using initWithUpdaterDelegate:userDriverDelegate: or initWithStartingUpdater:updaterDelegate:userDriverDelegate:. + This class can be instantiated in a nib or created programatically using `-initWithUpdaterDelegate:userDriverDelegate:` or `-initWithStartingUpdater:updaterDelegate:userDriverDelegate:`. The controller's updater targets the application's main bundle and uses Sparkle's standard user interface. Typically, this class is used by sticking it as a custom NSObject subclass in an Interface Builder nib (probably in MainMenu) but it works well programatically too. - The controller creates an SPUUpdater instance and allows hooking up the check for updates action and handling menu item validation. It also allows hooking - up the updater's and user driver's delegates. + The controller creates an `SPUUpdater` instance and allows hooking up the check for updates action and handling menu item validation. + It also allows hooking up the updater's and user driver's delegates. - If you need more control over what bundle you want to update or you want to provide a custom user interface (via SPUUserDriver), please use SPUUpdater directly instead. + If you need more control over what bundle you want to update, or you want to provide a custom user interface (via `SPUUserDriver`), please use `SPUUpdater` directly instead. */ SU_EXPORT @interface SPUStandardUpdaterController : NSObject -/*! +/** Interface builder outlet for the updater's delegate. This property should only be set using Interface Builder by creating a connection using the outlet. */ @property (nonatomic, weak, nullable) IBOutlet id updaterDelegate; -/*! +/** Interface builder outlet for the user driver's delegate. This property should only be set using Interface Builder by creating a connection using the outlet. */ @property (nonatomic, weak, nullable) IBOutlet id userDriverDelegate; -/*! +/** Accessible property for the updater. Some properties on the updater can be binded via KVO When instantiated from a nib, don't perform update checks before the application has finished launching in a MainMenu nib (i.e applicationDidFinishLaunching:) or before the corresponding window/view controller has been loaded (i.e, windowDidLoad or viewDidLoad). The updater is not guaranteed to be started yet before these points. */ @property (nonatomic, readonly) SPUUpdater *updater; -/*! +/** Accessible property for the updater's user driver. */ @property (nonatomic, readonly) SPUStandardUserDriver *userDriver; -/*! - Create a new SPUStandardUpdaterController from a nib. +/** + Create a new `SPUStandardUpdaterController` from a nib. - You cannot call this initializer directly. You must instantiate a SPUStandardUpdaterController inside of a nib (typically the MainMenu nib) to use it. + You cannot call this initializer directly. You must instantiate a `SPUStandardUpdaterController` inside of a nib (typically the MainMenu nib) to use it. - To create a SPUStandardUpdaterController programatically, use initWithUpdaterDelegate:userDriverDelegate: or initWithStartingUpdater:updaterDelegate:userDriverDelegate: instead. + To create a `SPUStandardUpdaterController` programatically, use `-initWithUpdaterDelegate:userDriverDelegate:` or `-initWithStartingUpdater:updaterDelegate:userDriverDelegate:` instead. */ - (instancetype)init NS_UNAVAILABLE; -/*! - Create a new SPUStandardUpdaterController programmatically. +/** + Create a new `SPUStandardUpdaterController` programmatically. - The updater is started automatically. See -[SPUStandardUpdaterController startUpdater] for more information. + The updater is started automatically. See `-startUpdater` for more information. */ - (instancetype)initWithUpdaterDelegate:(nullable id)updaterDelegate userDriverDelegate:(nullable id)userDriverDelegate; -/*! - Create a new SPUStandardUpdaterController programmatically allowing you to specify whether or not to start the updater immediately. +/** + Create a new `SPUStandardUpdaterController` programmatically allowing you to specify whether or not to start the updater immediately. - You can specify whether or not you want to start the updater immediately. If you do not start the updater, you - must invoke -[SPUStandardUpdaterController startUpdater] at a later time to start it. + You can specify whether or not you want to start the updater immediately. + If you do not start the updater, you must invoke `-startUpdater` at a later time to start it. */ - (instancetype)initWithStartingUpdater:(BOOL)startUpdater updaterDelegate:(nullable id)updaterDelegate userDriverDelegate:(nullable id)userDriverDelegate; -/*! +/** Starts the updater if it has not already been started. You should only call this method yourself if you opted out of starting the updater on initialization. Hence, do not call this yourself if you are instantiating this controller from a nib. - This invokes -[SPUUpdater startUpdater:]. If the application is misconfigured with Sparkle, an error is logged and an alert is shown to the user (after a few seconds) to contact the developer. - If you want more control over this behavior, you can create your own SPUUpdater instead. + This invokes `-[SPUUpdater startUpdater:]`. If the application is misconfigured with Sparkle, an error is logged and an alert is shown to the user (after a few seconds) to contact the developer. + If you want more control over this behavior, you can create your own `SPUUpdater` instead of using `SPUStandardUpdaterController`. */ - (void)startUpdater; -/*! +/** Explicitly checks for updates and displays a progress dialog while doing so. This method is meant for a main menu item. Connect any NSMenuItem to this action in Interface Builder or programmatically, - and Sparkle will check for updates and report back its findings verbosely - when it is invoked. + and Sparkle will check for updates and report back its findings verbosely when it is invoked. When the target/action of the menu item is set to this controller and this method, this controller also handles enabling/disabling the menu item by checking - -[SPUUpdater canCheckForUpdates] + `-[SPUUpdater canCheckForUpdates]` - This action checks updates by invoking -[SPUUpdater checkForUpdates] + This action checks updates by invoking `-[SPUUpdater checkForUpdates]` */ - (IBAction)checkForUpdates:(nullable id)sender; diff --git a/Sparkle/SPUStandardUserDriver.h b/Sparkle/SPUStandardUserDriver.h index f4081ecd..9e797957 100644 --- a/Sparkle/SPUStandardUserDriver.h +++ b/Sparkle/SPUStandardUserDriver.h @@ -21,12 +21,12 @@ NS_ASSUME_NONNULL_BEGIN @protocol SPUStandardUserDriverDelegate; -/*! +/** Sparkle's standard built-in user driver for updater interactions */ SU_EXPORT @interface SPUStandardUserDriver : NSObject -/*! +/** Initializes a Sparkle's standard user driver for user update interactions @param hostBundle The target bundle of the host that is being updated. @@ -34,7 +34,7 @@ SU_EXPORT @interface SPUStandardUserDriver : NSObject */ - (instancetype)initWithHostBundle:(NSBundle *)hostBundle delegate:(nullable id)delegate; -/*! +/** Use initWithHostBundle:delegate: instead. */ - (instancetype)init NS_UNAVAILABLE; diff --git a/Sparkle/SPUStandardUserDriverDelegate.h b/Sparkle/SPUStandardUserDriverDelegate.h index 406c969a..3bf1e315 100644 --- a/Sparkle/SPUStandardUserDriverDelegate.h +++ b/Sparkle/SPUStandardUserDriverDelegate.h @@ -18,7 +18,7 @@ @protocol SUVersionDisplay; -/*! +/** A protocol for Sparkle's standard user driver's delegate This includes methods related to UI interactions @@ -27,22 +27,21 @@ SU_EXPORT @protocol SPUStandardUserDriverDelegate @optional -/*! +/** Called before showing a modal alert window, to give the opportunity to hide attached windows that may get in the way. */ - (void)standardUserDriverWillShowModalAlert; -/*! +/** Called after showing a modal alert window, to give the opportunity to hide attached windows that may get in the way. */ - (void)standardUserDriverDidShowModalAlert; -/*! +/** Returns an object that formats version numbers for display to the user. - If you don't implement this method or return \c nil, - the standard version formatter will be used. + If you don't implement this method or return @c nil, the standard version formatter will be used. */ - (_Nullable id )standardUserDriverRequestsVersionDisplayer; diff --git a/Sparkle/SPUUpdatePermissionRequest.h b/Sparkle/SPUUpdatePermissionRequest.h index 2b3be9ad..f3e46c33 100644 --- a/Sparkle/SPUUpdatePermissionRequest.h +++ b/Sparkle/SPUUpdatePermissionRequest.h @@ -18,19 +18,19 @@ NS_ASSUME_NONNULL_BEGIN -/*! +/** This class represents information needed to make a permission request for checking updates. */ SU_EXPORT @interface SPUUpdatePermissionRequest : NSObject -/*! +/** Initializes a new update permission request instance. @param systemProfile The system profile information. */ - (instancetype)initWithSystemProfile:(NSArray *> *)systemProfile; -/*! +/** A read-only property for the user's system profile. */ @property (nonatomic, readonly) NSArray *> *systemProfile; diff --git a/Sparkle/SPUUpdater.h b/Sparkle/SPUUpdater.h index fc32e342..6f36a4a5 100644 --- a/Sparkle/SPUUpdater.h +++ b/Sparkle/SPUUpdater.h @@ -23,53 +23,52 @@ NS_ASSUME_NONNULL_BEGIN @protocol SPUUpdaterDelegate; -/*! - The main API in Sparkle for controlling the update mechanism. +/** + The main API in Sparkle for controlling the update mechanism. - This class is used to configure the update parameters as well as manually - and automatically schedule and control checks for updates. + This class is used to configure the update parameters as well as manually + and automatically schedule and control checks for updates. + + If you want to use a standard updater or instantiate an updater in a nib, see `SPUStandardUpdaterController` for convenience. */ SU_EXPORT @interface SPUUpdater : NSObject -/*! - Initializes a new SPUUpdater instance +/** + Initializes a new `SPUUpdater` instance - This does not start the updater. To start it, see -[SPUUpdater startUpdater:] + This creates an updater, but to start it and schedule update checks `-startUpdater:` needs to be invoked first. - Note that this is a normal initializer and doesn't implement the singleton pattern (i.e, instances aren't cached, so no surprises) - This also means that updater instances can be deallocated, and that they will be torn down properly. + Related: See `SPUStandardUpdaterController` which wraps a `SPUUpdater` instance and is suitable for instantiating inside of nib files. - Related: See SPUStandardUpdaterController which wraps a SPUUpdater instance and is suitable for instantiating in nib files - - @param hostBundle The bundle that should be targetted for updating. This must not be nil. + @param hostBundle The bundle that should be targetted for updating. @param applicationBundle The application bundle that should be waited for termination and relaunched (unless overridden). Usually this can be the same as hostBundle. This may differ when updating a plug-in or other non-application bundle. - @param userDriver The user driver that Sparkle uses for user update interaction - @param delegate The delegate for SPUUpdater. This may be nil. + @param userDriver The user driver that Sparkle uses for user update interaction. + @param delegate The delegate for `SPUUpdater`. */ -- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id )userDriver delegate:(id _Nullable)delegate; +- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id )userDriver delegate:(nullable id)delegate; -/*! - Use -initWithHostBundle:applicationBundle:userDriver:delegate: or SPUStandardUpdaterController standard adapter instead. +/** + Use `-initWithHostBundle:applicationBundle:userDriver:delegate:` or `SPUStandardUpdaterController` standard adapter instead. - If you want to drop an updater into a nib, use SPUStandardUpdaterController. + If you want to drop an updater into a nib, use `SPUStandardUpdaterController`. */ - (instancetype)init NS_UNAVAILABLE; -/*! +/** Starts the updater. - This method checks if Sparkle is configured properly. A valid feed URL should be set before this method is invoked. - Other properties of this SPUUpdater instance can be set before this method is invoked as well, such as automatic update checks. + This method first checks if Sparkle is configured properly. A valid feed URL should be set before this method is invoked. If the configuration is valid, an update cycle is started in the next main runloop cycle. During this cycle, a permission prompt may be brought up (if needed) for checking if the user wants automatic update checking. Otherwise if automatic update checks are enabled, a scheduled update alert may be brought up if enough time has elapsed since the last check. + See `automaticallyChecksForUpdates` for more information. - After starting the updater and before the next runloop cycle, one of -checkForUpdates, -checkForUpdatesInBackground, or -checkForUpdateInformation can be invoked. - This may be useful if you want to check for updates immediately or without showing a permission prompt. + After starting the updater and before the next runloop cycle, one of `-checkForUpdates`, `-checkForUpdatesInBackground`, or `-checkForUpdateInformation` can be invoked. + This may be useful if you want to check for updates immediately or without showing a potential permission prompt. If the updater cannot be started (i.e, due to a configuration issue in the application), you may want to fall back appropriately. - For example, the standard updater controller (SPUStandardUpdaterController) alerts the user that the app is misconfigured and to contact the developer. + For example, the standard updater controller (`SPUStandardUpdaterController`) alerts the user that the app is misconfigured and to contact the developer. This must be called on the main thread. @@ -78,7 +77,7 @@ SU_EXPORT @interface SPUUpdater : NSObject */ - (BOOL)startUpdater:(NSError * __autoreleasing *)error; -/*! +/** Checks for updates, and displays progress while doing so if needed. This is meant for users initiating a new update check or checking the current update progress. @@ -89,11 +88,11 @@ SU_EXPORT @interface SPUUpdater : NSObject This will find updates that the user has previously opted into skipping. - See canCheckForUpdates property which can determine if this method may be invoked. + See `canCheckForUpdates` property which can determine when this method may be invoked. */ - (void)checkForUpdates; -/*! +/** Checks for updates, but does not display any UI unless an update is found. This is meant for programmatically initating a check for updates. @@ -105,31 +104,31 @@ SU_EXPORT @interface SPUUpdater : NSObject */ - (void)checkForUpdatesInBackground; -/*! +/** Begins a "probing" check for updates which will not actually offer to update to that version. However, the delegate methods - SPUUpdaterDelegate::updater:didFindValidUpdate: and - SPUUpdaterDelegate::updaterDidNotFindUpdate: will be called, + `-[SPUUpdaterDelegate updater:didFindValidUpdate:]` and + `-[SPUUpdaterDelegate updaterDidNotFindUpdate:]` will be called, so you can use that information in your UI. Updates that have been skipped by the user will not be found. */ - (void)checkForUpdateInformation; -/*! +/** A property indicating whether or not updates can be checked by the user. An update check can be made by the user when an update session isn't in progress, or when an update or its progress is being shown to the user. - This property is suitable to use for menu item validation for seeing if -checkForUpdates can be invoked. + This property is suitable to use for menu item validation for seeing if `-checkForUpdates` can be invoked. - Note this property does not reflect whether or not an update session is in progress. Please see sessionInProgress property instead. + Note this property does not reflect whether or not an update session is in progress. Please see `sessionInProgress` property instead. */ @property (nonatomic, readonly) BOOL canCheckForUpdates; -/*! +/** A property indicating whether or not an update session is in progress. An update session is in progress when the appcast is being downloaded, an update is being downloaded, @@ -140,42 +139,54 @@ SU_EXPORT @interface SPUUpdater : NSObject or even though the update has been downloaded but the installation has been deferred. In both of these cases, a new update session may be activated with the update resumed at a later point (automatically or manually). - See also canCheckForUpdates property which is more suited for menu item validation. + See also `canCheckForUpdates` property which is more suited for menu item validation. */ @property (nonatomic, readonly) BOOL sessionInProgress; -/*! +/** A property indicating whether or not to check for updates automatically. + By default, Sparkle asks users on second launch for permission if they want automatic update checks enabled + and sets this property based on their response. If SUEnableAutomaticChecks is set in the Info.plist, + this permission request is not performed however. + Setting this property will persist in the host bundle's user defaults. + The update schedule cycle will be reset in a short delay after the property's new value is set. This is to allow reverting this property without kicking off a schedule change immediately */ @property (nonatomic) BOOL automaticallyChecksForUpdates; -/*! - A property indicating the current automatic update check interval. +/** + A property indicating the current automatic update check interval in seconds. Setting this property will persist in the host bundle's user defaults. + For this reason, only set this property if you need dynamic behavior (eg user preferences). + Otherwise prefer to set SUScheduledCheckInterval directly in your Info.plist. + The update schedule cycle will be reset in a short delay after the property's new value is set. This is to allow reverting this property without kicking off a schedule change immediately */ @property (nonatomic) NSTimeInterval updateCheckInterval; -/*! +/** A property indicating whether or not updates can be automatically downloaded in the background. + By default, updates are not automatically downloaded. + Note that the developer can disallow automatic downloading of updates from being enabled. - In this case, -automaticallyDownloadsUpdates will return NO regardless of how this property is set. + In this case, this property will return NO regardless of how this property is set. Setting this property will persist in the host bundle's user defaults. + For this reason, only set this property if you need dynamic behavior (eg user preferences). + Otherwise prefer to set SUAutomaticallyUpdate directly in your Info.plist. */ @property (nonatomic) BOOL automaticallyDownloadsUpdates; -/*! +/** The URL of the appcast used to download update information. - If the updater's delegate implements -[SPUUpdaterDelegate feedURLStringForUpdater:], this will return that feed URL. + If the updater's delegate implements `-[SPUUpdaterDelegate feedURLStringForUpdater:]`, this will return that feed URL. Otherwise if the feed URL has been set before, the feed URL returned will be retrieved from the host bundle's user defaults. Otherwise the feed URL in the host bundle's Info.plist will be returned. If no feed URL can be retrieved, returns nil. @@ -184,75 +195,73 @@ SU_EXPORT @interface SPUUpdater : NSObject */ @property (nonatomic, readonly, nullable) NSURL *feedURL; -/*! +/** Set the URL of the appcast used to download update information. Using this method is discouraged. Setting this property will persist in the host bundle's user defaults. - To avoid this, you should consider instead implementing - -[SPUUpdaterDelegate feedURLStringForUpdater:] + To avoid this, you should consider implementing + `-[SPUUpdaterDelegate feedURLStringForUpdater:]` instead of using this method. Passing nil will remove any feed URL that has been set in the host bundle's user defaults. + If you do not need to alternate between multiple feeds, set the SUFeedURL in your Info.plist instead of invoking this method. - For beta updates, you may consider migrating to -[SPUUpdaterDelegate allowedChannelsForUpdater:] in the future. + For beta updates, you may consider migrating to `-[SPUUpdaterDelegate allowedChannelsForUpdater:]` in the future. This method must be called on the main thread; calls from background threads will have no effect. */ -- (void)setFeedURL:(NSURL * _Nullable)feedURL; +- (void)setFeedURL:(nullable NSURL *)feedURL; -/*! +/** The host bundle that is being updated. */ @property (nonatomic, readonly) NSBundle *hostBundle; -/*! - The bundle this class (SPUUpdater) is loaded into +/** + The bundle this class (`SPUUpdater`) is loaded into */ @property (nonatomic, readonly) NSBundle *sparkleBundle; -/*! - * The user agent used when checking for updates. - * - * The default implementation can be overrided. +/** + The user agent used when checking for updates. + + By default the user agent string returned is in the format: + $(BundleDisplayName)/$(BundleDisplayVersion)/$(SparkleDisplayVersion) + + BundleDisplayVersion is derived from the application Info.plist's CFBundleShortVersionString. + + This default implementation can be overrided. */ @property (nonatomic, copy) NSString *userAgentString; -/*! - The HTTP headers used when checking for updates. +/** + The HTTP headers used when checking for updates, downloading release notes, and downloading updates. - The keys of this dictionary are HTTP header fields (NSString) and values are corresponding values (NSString) + The keys of this dictionary are HTTP header fields and values are corresponding values. */ -#if __has_feature(objc_generics) @property (nonatomic, copy, nullable) NSDictionary *httpHeaders; -#else -@property (nonatomic, copy, nullable) NSDictionary *httpHeaders; -#endif -/*! +/** A property indicating whether or not the user's system profile information is sent when checking for updates. Setting this property will persist in the host bundle's user defaults. */ @property (nonatomic) BOOL sendsSystemProfile; -/*! - Returns the date of last update check. - - \returns \c nil if no check has been performed. +/** + The date of the last update check or nil if no check has been performed yet. */ @property (nonatomic, readonly, copy, nullable) NSDate *lastUpdateCheckDate; -/*! - Appropriately schedules or cancels the update checking timer according to - the preferences for time interval and automatic checks. +/** + Appropriately schedules or cancels the update checking timer according to the preferences for time interval and automatic checks. - This call does not change the date of the next check, - but only the internal timer. + This call does not change the date of the next check, but only the internal timer. */ - (void)resetUpdateCycle; -/*! - The system profile information that is sent when checking for updates +/** + The system profile information that is sent when checking for updates. */ @property (nonatomic, readonly, copy) NSArray *> *systemProfileArray; diff --git a/Sparkle/SPUUpdaterDelegate.h b/Sparkle/SPUUpdaterDelegate.h index b49e8c58..9de51c92 100644 --- a/Sparkle/SPUUpdaterDelegate.h +++ b/Sparkle/SPUUpdaterDelegate.h @@ -63,104 +63,94 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck) SPUUpdateCheckBackgroundScheduled = 1 }; -/*! - Provides methods to control the behavior of an SPUUpdater object. +/** + Provides methods to control the behavior of an `SPUUpdater` object. */ @protocol SPUUpdaterDelegate @optional -/*! +/** Called when a background update will be scheduled after a delay. Automatic update checks need to be enabled for this to trigger. - \param delay The delay until the next scheduled update will occur. + @param delay The delay in seconds until the next scheduled update will occur. - \param updater The updater instance. + @param updater The updater instance. */ - (void)updater:(SPUUpdater *)updater willScheduleUpdateCheckAfterDelay:(NSTimeInterval)delay; -/*! +/** Called when no updates will be scheduled in the future. This may later change if automatic update checks become enabled. - \param updater The updater instance. + @param updater The updater instance. */ - (void)updaterWillIdleSchedulingUpdates:(SPUUpdater *)updater; -/*! +/** Returns whether to allow Sparkle to pop up. For example, this may be used to prevent Sparkle from interrupting a setup assistant. Alternatively, you may want to consider starting the updater after eg: the setup assistant finishes - \param updater The updater instance. + @param updater The updater instance. */ - (BOOL)updaterMayCheckForUpdates:(SPUUpdater *)updater; -/*! +/** Returns additional parameters to append to the appcast URL's query string. This is potentially based on whether or not Sparkle will also be sending along the system profile. - \param updater The updater instance. - \param sendingProfile Whether the system profile will also be sent. + @param updater The updater instance. + @param sendingProfile Whether the system profile will also be sent. - \return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user. + @return An array of dictionaries with keys: "key", "value", "displayKey", "displayValue", the latter two being specifically for display to the user. */ -#if __has_feature(objc_generics) - (NSArray *> *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile; -#else -- (NSArray *)feedParametersForUpdater:(SPUUpdater *)updater sendingSystemProfile:(BOOL)sendingProfile; -#endif -/*! +/** Returns a list of system profile keys to be appended to the appcast URL's query string. If this is unimplemented then all keys will be included. - \param updater The updater instance. + @param updater The updater instance. - \return An array of system profile keys to include in the appcast URL's query string. Elements must be one of the SUSystemProfiler*Key constants + @return An array of system profile keys to include in the appcast URL's query string. Elements must be one of the SUSystemProfiler*Key constants */ -#if __has_feature(objc_generics) - (NSArray *)allowedSystemProfileKeysForUpdater:(SPUUpdater *)updater; -#else -- (NSArray *)allowedSystemProfileKeysForUpdater:(SPUUpdater *)updater; -#endif -/*! +/** Returns a custom appcast URL. - Override this to dynamically specify the entire URL. - Alternatively you may want to consider adding a feed parameter using -feedParametersForUpdater:sendingSystemProfile: - and having the server which appcast to serve. + Override this to dynamically specify the feed URL. - \param updater The updater instance. + @param updater The updater instance. */ - (nullable NSString *)feedURLStringForUpdater:(SPUUpdater *)updater; -/*! +/** Returns whether Sparkle should prompt the user about automatic update checks. Use this to override the default behavior. - \param updater The updater instance. + @param updater The updater instance. */ - (BOOL)updaterShouldPromptForPermissionToCheckForUpdates:(SPUUpdater *)updater; -/*! +/** Called after Sparkle has downloaded the appcast from the remote server. Implement this if you want to do some special handling with the appcast once it finishes loading. - \param updater The updater instance. - \param appcast The appcast that was downloaded from the remote server. + @param updater The updater instance. + @param appcast The appcast that was downloaded from the remote server. */ - (void)updater:(SPUUpdater *)updater didFinishLoadingAppcast:(SUAppcast *)appcast; -/*! +/** Returns the set of Sparkle channels the updater is allowed to find new updates from. An appcast item can specify a channel the update is posted to. Without specifying a channel, the appcast item is posted to the default channel. @@ -179,12 +169,12 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck) Note to use this feature, all app versions that your users may update from in your feed must use a version of Sparkle that supports this feature. This feature was added in Sparkle 2. - \return The set of channel names the updater is allowed to find new updates in. An empty set is the default behavior, + @return The set of channel names the updater is allowed to find new updates in. An empty set is the default behavior, which means the updater will only look for updates in the default channel. */ - (NSSet *)allowedChannelsForUpdater:(SPUUpdater *)updater; -/*! +/** Returns the item in the appcast corresponding to the update that should be installed. Please consider using or migrating to other supported features before adopting this method. @@ -207,26 +197,26 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck) This method may be called multiple times for different selections and filters. This method should be efficient. - \param appcast The appcast that was downloaded from the remote server. - \param updater The updater instance. - \return The best valid appcast item. Return SUAppcastItem.emptyAppcastItem if no appcast item is valid. Return nil if you don't want to be delegated this task and + @param appcast The appcast that was downloaded from the remote server. + @param updater The updater instance. + @return The best valid appcast item. Return SUAppcastItem.emptyAppcastItem if no appcast item is valid. Return nil if you don't want to be delegated this task and want to let Sparkle handle picking the best valid update. */ - (nullable SUAppcastItem *)bestValidUpdateInAppcast:(SUAppcast *)appcast forUpdater:(SPUUpdater *)updater; -/*! +/** Called when a valid update is found by the update driver. - \param updater The updater instance. - \param item The appcast item corresponding to the update that is proposed to be installed. + @param updater The updater instance. + @param item The appcast item corresponding to the update that is proposed to be installed. */ - (void)updater:(SPUUpdater *)updater didFindValidUpdate:(SUAppcastItem *)item; -/*! +/** Called when a valid update is not found. - \param updater The updater instance. - \param error An error containing information on why a new valid update was not found + @param updater The updater instance. + @param error An error containing information on why a new valid update was not found There are various reasons a new update is unavailable and can't be installed. The userInfo dictionary on the error is also populated with three keys: SPULatestAppcastItemFoundKey: if available, this may provide the latest SUAppcastItem that was found. This will be nil if it's unavailable. @@ -236,90 +226,90 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck) */ - (void)updaterDidNotFindUpdate:(SPUUpdater *)updater error:(NSError *)error; -/*! +/** Called when a valid update is not found. - \param updater The updater instance. + @param updater The updater instance. */ - (void)updaterDidNotFindUpdate:(SPUUpdater *)updater; -/*! +/** Called when an update is skipped by the user. - \param updater The updater instance. - \param item The appcast item corresponding to the update that the user skipped. + @param updater The updater instance. + @param item The appcast item corresponding to the update that the user skipped. */ - (void)updater:(SPUUpdater *)updater userDidSkipThisVersion:(SUAppcastItem *)item; -/*! +/** Returns whether the release notes (if available) should be downloaded after an update is found and shown. This is specifically for the releaseNotesLink element in the appcast. - \param updater The updater instance. + @param updater The updater instance. - \return \c YES to download and show the release notes if available, otherwise NO. The default behavior is YES. + @return @c YES to download and show the release notes if available, otherwise @c NO. The default behavior is YES. */ - (BOOL)updaterShouldDownloadReleaseNotes:(SPUUpdater *)updater; -/*! +/** Called immediately before downloading the specified update. - \param updater The updater instance. - \param item The appcast item corresponding to the update that is proposed to be downloaded. - \param request The mutable URL request that will be used to download the update. + @param updater The updater instance. + @param item The appcast item corresponding to the update that is proposed to be downloaded. + @param request The mutable URL request that will be used to download the update. */ - (void)updater:(SPUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request; -/*! +/** Called immediately after succesfull download of the specified update. - \param updater The SUUpdater instance. - \param item The appcast item corresponding to the update that has been downloaded. + @param updater The SUUpdater instance. + @param item The appcast item corresponding to the update that has been downloaded. */ - (void)updater:(SPUUpdater *)updater didDownloadUpdate:(SUAppcastItem *)item; -/*! +/** Called after the specified update failed to download. - \param updater The updater instance. - \param item The appcast item corresponding to the update that failed to download. - \param error The error generated by the failed download. + @param updater The updater instance. + @param item The appcast item corresponding to the update that failed to download. + @param error The error generated by the failed download. */ - (void)updater:(SPUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error; -/*! +/** Called when the user clicks the cancel button while and update is being downloaded. - \param updater The updater instance. + @param updater The updater instance. */ - (void)userDidCancelDownload:(SPUUpdater *)updater; -/*! +/** Called immediately before extracting the specified downloaded update. - \param updater The SUUpdater instance. - \param item The appcast item corresponding to the update that is proposed to be extracted. + @param updater The SUUpdater instance. + @param item The appcast item corresponding to the update that is proposed to be extracted. */ - (void)updater:(SPUUpdater *)updater willExtractUpdate:(SUAppcastItem *)item; -/*! +/** Called immediately after extracting the specified downloaded update. - \param updater The SUUpdater instance. - \param item The appcast item corresponding to the update that has been extracted. + @param updater The SUUpdater instance. + @param item The appcast item corresponding to the update that has been extracted. */ - (void)updater:(SPUUpdater *)updater didExtractUpdate:(SUAppcastItem *)item; -/*! +/** Called immediately before installing the specified update. - \param updater The updater instance. - \param item The appcast item corresponding to the update that is proposed to be installed. + @param updater The updater instance. + @param item The appcast item corresponding to the update that is proposed to be installed. */ - (void)updater:(SPUUpdater *)updater willInstallUpdate:(SUAppcastItem *)item; -/*! +/** Returns whether the relaunch should be delayed in order to perform other tasks. This is not called if the user didn't relaunch on the previous update, @@ -327,49 +317,48 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck) This may also not be called if the application is not going to relaunch after it terminates. - \param updater The updater instance. - \param item The appcast item corresponding to the update that is proposed to be installed. - \param installHandler The install handler that must be completed before continuing with the relaunch. + @param updater The updater instance. + @param item The appcast item corresponding to the update that is proposed to be installed. + @param installHandler The install handler that must be completed before continuing with the relaunch. - \return \c YES to delay the relaunch until \p installHandler is invoked. + @return @c YES to delay the relaunch until @p installHandler is invoked. */ - (BOOL)updater:(SPUUpdater *)updater shouldPostponeRelaunchForUpdate:(SUAppcastItem *)item untilInvokingBlock:(void (^)(void))installHandler; -/*! +/** Returns whether the application should be relaunched at all. Some apps \b cannot be relaunched under certain circumstances. This method can be used to explicitly prevent a relaunch. - \param updater The updater instance. - \return YES if the updater should be relaunched, otherwise NO if it shouldn't. + @param updater The updater instance. + @return YES if the updater should be relaunched, otherwise NO if it shouldn't. */ - (BOOL)updaterShouldRelaunchApplication:(SPUUpdater *)updater; -/*! +/** Called immediately before relaunching. - \param updater The updater instance. + @param updater The updater instance. */ - (void)updaterWillRelaunchApplication:(SPUUpdater *)updater; -/*! +/** Returns an object that compares version numbers to determine their arithmetic relation to each other. This method allows you to provide a custom version comparator. - If you don't implement this method or return \c nil, - the standard version comparator will be used. Note that the - standard version comparator may be used during installation for preventing - a downgrade, even if you provide a custom comparator here. + If you don't implement this method or return @c nil, + the standard version comparator will be used. - \sa SUStandardVersionComparator + Note that the standard version comparator may be used during installation for preventing a downgrade, + even if you provide a custom comparator here. - \param updater The updater instance. - \return The custom version comparator or nil if you don't want to be delegated this task. + @param updater The updater instance. + @return The custom version comparator or nil if you don't want to be delegated this task. */ - (nullable id)versionComparatorForUpdater:(SPUUpdater *)updater; -/*! +/** Returns whether or not the updater should allow interaction from the installer Use this to override the default behavior which is to allow interaction with the installer. @@ -383,28 +372,28 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck) Note this has no effect if the update has already been downloaded in the background silently and ready to be resumed. - \param updater The updater instance. - \param updateCheck The type of update check being performed. + @param updater The updater instance. + @param updateCheck The type of update check being performed. */ - (BOOL)updater:(SPUUpdater *)updater shouldAllowInstallerInteractionForUpdateCheck:(SPUUpdateCheck)updateCheck; -/*! +/** Returns the decryption password (if any) which is used to extract the update archive DMG. Return nil if no password should be used. - \param updater The updater instance. - \return The password used for decrypting the archive, or nil if no password should be used. + @param updater The updater instance. + @return The password used for decrypting the archive, or nil if no password should be used. */ - (nullable NSString *)decryptionPasswordForUpdater:(SPUUpdater *)updater; -/*! +/** Called when an update is scheduled to be silently installed on quit after downloading the update automatically. - \param updater The updater instance. - \param item The appcast item corresponding to the update that is proposed to be installed. - \param immediateInstallHandler The install handler to immediately install the update. No UI interaction will be shown and the application will be relaunched after installation. - \return Return YES if the delegate will handle installing the update or NO if the updater should be given responsibility. + @param updater The updater instance. + @param item The appcast item corresponding to the update that is proposed to be installed. + @param immediateInstallHandler The install handler to immediately install the update. No UI interaction will be shown and the application will be relaunched after installation. + @return YES if the delegate will handle installing the update or NO if the updater should be given responsibility. If the updater is given responsibility, it can later remind the user an update is available if they have not terminated the application for a long time. Also if the updater is given responsibility and the update item is marked critical, the new update will be presented to the user immediately after. @@ -412,11 +401,11 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck) */ - (BOOL)updater:(SPUUpdater *)updater willInstallUpdateOnQuit:(SUAppcastItem *)item immediateInstallationBlock:(void (^)(void))immediateInstallHandler; -/*! +/** Called after an update is aborted due to an error. - \param updater The updater instance. - \param error The error that caused the abort + @param updater The updater instance. + @param error The error that caused the abort */ - (void)updater:(SPUUpdater *)updater didAbortWithError:(NSError *)error; diff --git a/Sparkle/SPUUpdaterSettings.h b/Sparkle/SPUUpdaterSettings.h index 0108cba7..d27276dd 100644 --- a/Sparkle/SPUUpdaterSettings.h +++ b/Sparkle/SPUUpdaterSettings.h @@ -18,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN -/*! +/** This class can be used for reading certain updater settings. It retrieves the settings by first looking into the host's user defaults. @@ -28,22 +28,22 @@ SU_EXPORT @interface SPUUpdaterSettings : NSObject - (instancetype)initWithHostBundle:(NSBundle *)hostBundle; -/*! +/** * Indicates whether or not automatic update checks are enabled. */ @property (readonly, nonatomic) BOOL automaticallyChecksForUpdates; -/*! +/** * The regular update check interval. */ @property (readonly, nonatomic) NSTimeInterval updateCheckInterval; -/*! +/** * Indicates whether or not automatically downloading updates is allowed to be turned on by the user. */ @property (readonly, nonatomic) BOOL allowsAutomaticUpdates; -/*! +/** * Indicates whether or not automatically downloading updates is enabled by the user or developer. * * Note this does not indicate whether or not automatic downloading of updates is allowable. @@ -51,7 +51,7 @@ SU_EXPORT @interface SPUUpdaterSettings : NSObject */ @property (readonly, nonatomic) BOOL automaticallyDownloadsUpdates; -/*! +/** * Indicates whether or not anonymous system profile information is sent when checking for updates. */ @property (readonly, nonatomic) BOOL sendsSystemProfile; diff --git a/Sparkle/SPUUserDriver.h b/Sparkle/SPUUserDriver.h index 450496e7..05fe9cbc 100644 --- a/Sparkle/SPUUserDriver.h +++ b/Sparkle/SPUUserDriver.h @@ -22,7 +22,7 @@ NS_ASSUME_NONNULL_BEGIN @class SPUUpdatePermissionRequest, SUUpdatePermissionResponse, SUAppcastItem, SPUDownloadData; -/*! +/** The API in Sparkle for controlling the user interaction. This protocol is used for implementing a user interface for the Sparkle updater. Sparkle's internal drivers tell @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN */ SU_EXPORT @protocol SPUUserDriver -/*! +/** * Show an updater permission request to the user * * Ask the user for their permission regarding update checks. @@ -43,7 +43,7 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showUpdatePermissionRequest:(SPUUpdatePermissionRequest *)request reply:(void (^)(SUUpdatePermissionResponse *))reply; -/*! +/** * Show the user initating an update check * * Respond to the user initiating an update check. Sparkle uses this to show the user a window with an indeterminate progress bar. @@ -52,42 +52,45 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showUserInitiatedUpdateCheckWithCancellation:(void (^)(void))cancellation; -/*! +/** * Show the user a new update is found. * * Let the user know a new update is found and ask them what they want to do. - * Before this point, -showUserInitiatedUpdateCheckWithCancellation: may be called. + * Before this point, `-showUserInitiatedUpdateCheckWithCancellation:` may be called. * * @param appcastItem The Appcast Item containing information that reflects the new update. * * @param state The current state of the user update. * The state.stage values are: - * SPUUpdateStateNotDownloaded - Update has not been downloaded yet. - * SPUUpdateStateDownloaded - Update has already been downloaded but not started installing yet. - * SPUUpdateStateInstalling - Update has been downloaded and already started installing. + * `SPUUpdateStateNotDownloaded` - Update has not been downloaded yet. + * `SPUUpdateStateDownloaded` - Update has already been downloaded but not started installing yet. + * `SPUUpdateStateInstalling` - Update has been downloaded and already started installing. * * state.userInitiated indicates if the update was initiated by the user or if it was automatically scheduled in the background. * * Additionally, these properties on the appcastItem are of importance: - * appcastItem.informationOnlyUpdate indicates if the update is only informational and should not be downloaded. You can direct the user to the infoURL property of the appcastItem in their web browser. Sometimes information only updates are used as a fallback in case a bad update is shipped, so you'll want to support this case. - * appcastItem.majorUpgrade indicates if the update is a major or paid upgrade. - * appcastItem.criticalUpdate indicates if the update is a critical update. + * + * @c appcastItem.informationOnlyUpdate indicates if the update is only informational and should not be downloaded. You can direct the user to the infoURL property of the appcastItem in their web browser. Sometimes information only updates are used as a fallback in case a bad update is shipped, so you'll want to support this case. + * + * @c appcastItem.majorUpgrade indicates if the update is a major or paid upgrade. + * + * @c appcastItem.criticalUpdate indicates if the update is a critical update. * * @param reply - * A reply of SPUUserUpdateChoiceInstall begins or resumes downloading or installing the update. - * If the state.stage is SPUUserUpdateStateInstalling, this may send a quit event to the application and relaunch it immediately (in this state, this behaves as a fast "install and Relaunch"). Do not use this reply if appcastItem.informationOnlyUpdate is YES. + * A reply of `SPUUserUpdateChoiceInstall` begins or resumes downloading or installing the update. + * If the state.stage is `SPUUserUpdateStateInstalling`, this may send a quit event to the application and relaunch it immediately (in this state, this behaves as a fast "install and Relaunch"). Do not use this reply if @c appcastItem.informationOnlyUpdate is YES. * - * A reply of SPUUserUpdateChoiceDismiss dismisses the update for the time being. The user may be reminded of the update at a later point. - * If the state.stage is SPUUserUpdateStateDownloaded, the downloaded update is kept after dismissing until the next time an update is shown to the user. - * If the state.stage is SPUUserUpdateStateInstalling, the installing update is also preserved after dismissing. In this state however, the update will also still be installed after the application is terminated. + * A reply of `SPUUserUpdateChoiceDismiss` dismisses the update for the time being. The user may be reminded of the update at a later point. + * If the state.stage is `SPUUserUpdateStateDownloaded`, the downloaded update is kept after dismissing until the next time an update is shown to the user. + * If the state.stage is `SPUUserUpdateStateInstalling`, the installing update is also preserved after dismissing. In this state however, the update will also still be installed after the application is terminated. * - * A reply of SPUUserUpdateChoiceSkip skips this particular version and won't notify the user again, unless they initiate an update check themselves. - * If appcastItem.majorUpgrade is YES, the major update and any future minor updates to that major release are skipped. - * If the state.stage is SPUUpdateStateInstalling, the installation is also canceled when the update is skipped. + * A reply of `SPUUserUpdateChoiceSkip` skips this particular version and won't notify the user again, unless they initiate an update check themselves. + * If @c appcastItem.majorUpgrade is YES, the major update and any future minor updates to that major release are skipped. + * If the state.stage is `SPUUpdateStateInstalling`, the installation is also canceled when the update is skipped. */ - (void)showUpdateFoundWithAppcastItem:(SUAppcastItem *)appcastItem state:(SPUUserUpdateState *)state reply:(void (^)(SPUUserUpdateChoice))reply; -/*! +/** * Show the user the release notes for the new update * * Display the release notes to the user. This will be called after showing the new update. @@ -98,7 +101,7 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showUpdateReleaseNotesWithDownloadData:(SPUDownloadData *)downloadData; -/*! +/** * Show the user that the new update's release notes could not be downloaded * * This will be called after showing the new update. @@ -109,26 +112,28 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showUpdateReleaseNotesFailedToDownloadWithError:(NSError *)error; -/*! +/** * Show the user a new update was not found * * Let the user know a new update was not found after they tried initiating an update check. - * Before this point, -showUserInitiatedUpdateCheckWithCancellation: may be called. + * Before this point, `-showUserInitiatedUpdateCheckWithCancellation:` may be called. * * @param error The error associated with why a new update was not found. * There are various reasons a new update is unavailable and can't be installed. * This error object is populated with recovery and suggestion strings suitable to be shown in an alert. * * The userInfo dictionary is also populated with two keys: - * SPULatestAppcastItemFoundKey: if available, this may provide the latest SUAppcastItem that was found. - * SPUNoUpdateFoundReasonKey: if available, this will provide the SUNoUpdateFoundReason. For example the reason could be because + * + * `SPULatestAppcastItemFoundKey`: if available, this may provide the latest SUAppcastItem that was found. + * + * `SPUNoUpdateFoundReasonKey`: if available, this will provide the `SUNoUpdateFoundReason`. For example the reason could be because * the latest version in the feed requires a newer OS version or could be because the user is already on the latest version. * * @param acknowledgement Acknowledge to the updater that no update found error was shown. */ - (void)showUpdateNotFoundWithError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement; -/*! +/** * Show the user an update error occurred * * Let the user know that the updater failed with an error. This will not be invoked without the user having been @@ -136,21 +141,21 @@ SU_EXPORT @protocol SPUUserDriver * * Before this point, any of the non-error user driver methods may have been invoked. * - * @param error The error associated with what update error occurred.. + * @param error The error associated with what update error occurred. * @param acknowledgement Acknowledge to the updater that the error was shown. */ - (void)showUpdaterError:(NSError *)error acknowledgement:(void (^)(void))acknowledgement; -/*! +/** * Show the user that downloading the new update initiated * * Let the user know that downloading the new update started. * - * @param cancellation Invoke this cancellation block to cancel the download at any point before -showDownloadDidStartExtractingUpdate is invoked. + * @param cancellation Invoke this cancellation block to cancel the download at any point before `-showDownloadDidStartExtractingUpdate` is invoked. */ - (void)showDownloadInitiatedWithCancellation:(void (^)(void))cancellation; -/*! +/** * Show the user the content length of the new update that will be downloaded * * @param expectedContentLength The expected content length of the new update being downloaded. @@ -159,7 +164,7 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showDownloadDidReceiveExpectedContentLength:(uint64_t)expectedContentLength; -/*! +/** * Show the user that the update download received more data * * This may be an appropriate time to advance a visible progress indicator of the download @@ -167,7 +172,7 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showDownloadDidReceiveDataOfLength:(uint64_t)length; -/*! +/** * Show the user that the update finished downloading and started extracting * * Sparkle uses this to show an indeterminate progress bar. @@ -177,44 +182,44 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showDownloadDidStartExtractingUpdate; -/*! +/** * Show the user that the update is extracting with progress * * Let the user know how far along the update extraction is. * - * Before this point, -showDownloadDidStartExtractingUpdate is called. + * Before this point, `-showDownloadDidStartExtractingUpdate` is called. * * @param progress The progress of the extraction from a 0.0 to 1.0 scale */ - (void)showExtractionReceivedProgress:(double)progress; -/*! +/** * Show the user that the update is installing * * Let the user know that the update is currently installing. Sparkle uses this to show an indeterminate progress bar. * - * Before this point, -showExtractionReceivedProgress: may be called. + * Before this point, `-showExtractionReceivedProgress:` may be called. */ - (void)showInstallingUpdate; -/*! +/** * Show the user that the update is ready to install & relaunch * * Let the user know that the update is ready to install and relaunch, and ask them whether they want to proceed. * Note if the target application has already terminated, this method may not be invoked. * * @param reply - * A reply of SPUUserUpdateChoiceInstall installs the update the new update immediately. The application is relaunched only if it is still running by the time this reply is invoked. If the application terminates on its own, Sparkle will attempt to automatically install the update. + * A reply of `SPUUserUpdateChoiceInstall` installs the update the new update immediately. The application is relaunched only if it is still running by the time this reply is invoked. If the application terminates on its own, Sparkle will attempt to automatically install the update. * - * A reply of SPUUserUpdateChoiceDismiss dismisses the update installation for the time being. Note the update may still be installed automatically after the application terminates. + * A reply of `SPUUserUpdateChoiceDismiss` dismisses the update installation for the time being. Note the update may still be installed automatically after the application terminates. * - * A reply of SPUUserUpdateChoiceSkip cancels the current update that has begun installing and dismisses the update. In this circumstance, the update is canceled but this update version is not skipped in the future. + * A reply of `SPUUserUpdateChoiceSkip` cancels the current update that has begun installing and dismisses the update. In this circumstance, the update is canceled but this update version is not skipped in the future. * - * Before this point, -showInstallingUpdate will be called. + * Before this point, `-showInstallingUpdate` will be called. */ - (void)showReadyToInstallAndRelaunch:(void (^)(SPUUserUpdateChoice))reply; -/*! +/** * Show or dismiss progress while a termination signal is being sent to the application from Sparkle's installer * * Terminating and relaunching the application (if requested to be relaunched) may happen quickly, @@ -227,7 +232,7 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showSendingTerminationSignal; -/*! +/** * Show the user that the update installation finished * * Let the user know that the update finished installing. @@ -236,14 +241,14 @@ SU_EXPORT @protocol SPUUserDriver * the updater's lifetime is tied to the application it is updating. This implementation must not try to reference * the old bundle prior to the installation, which will no longer be around. * - * Before this point, -showSendingTerminationSignal or -showReadyToInstallAndRelaunch: may be called. + * Before this point, `-showSendingTerminationSignal` or `-showReadyToInstallAndRelaunch:` may be called. * * @param relaunched Indicates if the update was relaunched. * @param acknowledgement Acknowledge to the updater that the finished installation was shown. */ - (void)showUpdateInstalledAndRelaunched:(BOOL)relaunched acknowledgement:(void (^)(void))acknowledgement; -/*! +/** * Show the user the current presented update or its progress in utmost focus * * The user wishes to check for updates while the user is being shown update progress. @@ -251,7 +256,7 @@ SU_EXPORT @protocol SPUUserDriver */ - (void)showUpdateInFocus; -/*! +/** * Dismiss the current update installation * * Stop and tear down everything. diff --git a/Sparkle/SUAppcastItem+Private.h b/Sparkle/SUAppcastItem+Private.h index c7db2590..8d1c9f31 100644 --- a/Sparkle/SUAppcastItem+Private.h +++ b/Sparkle/SUAppcastItem+Private.h @@ -25,7 +25,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUAppcastItem (Private) -/*! +/** Initializes with data from a dictionary provided by the RSS class and state resolver This initializer method is intended to be marked "private" and discouraged from public usage. diff --git a/Sparkle/SUStandardVersionComparator.h b/Sparkle/SUStandardVersionComparator.h index ea81fd4f..3df3d462 100644 --- a/Sparkle/SUStandardVersionComparator.h +++ b/Sparkle/SUStandardVersionComparator.h @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN -/*! +/** Sparkle's default version comparator. This comparator is adapted from MacPAD, by Kevin Ballard. @@ -41,19 +41,19 @@ NS_ASSUME_NONNULL_BEGIN */ SU_EXPORT @interface SUStandardVersionComparator : NSObject -/*! +/** Initializes a new instance of the standard version comparator. */ - (instancetype)init; -/*! +/** Returns a singleton instance of the comparator. It is usually preferred to alloc/init new a comparator instead. */ + (SUStandardVersionComparator *)defaultComparator; -/*! +/** Compares version strings through textual analysis. See the implementation for more details. diff --git a/Sparkle/SUUpdatePermissionResponse.h b/Sparkle/SUUpdatePermissionResponse.h index 764eeb7a..141016fd 100644 --- a/Sparkle/SUUpdatePermissionResponse.h +++ b/Sparkle/SUUpdatePermissionResponse.h @@ -16,12 +16,12 @@ #endif #import -/*! +/** This class represents a response for permission to check updates. */ SU_EXPORT @interface SUUpdatePermissionResponse : NSObject -/*! +/** Initializes a new update permission response instance. @param automaticUpdateChecks Flag for whether to allow automatic update checks. @@ -34,12 +34,12 @@ SU_EXPORT @interface SUUpdatePermissionResponse : NSObject */ - (instancetype)init NS_UNAVAILABLE; -/*! +/** A read-only property indicating whether automatic update checks are allowed or not. */ @property (nonatomic, readonly) BOOL automaticUpdateChecks; -/*! +/** A read-only property indicating if system profile should be sent or not. */ @property (nonatomic, readonly) BOOL sendSystemProfile; diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index 9116e862..bf43dc30 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -26,13 +26,12 @@ @protocol SUUpdaterDelegate; -/*! - The main API in Sparkle for controlling the update mechanism. +/** + The legacy API in Sparkle for controlling the update mechanism. - This class is used to configure the update paramters as well as manually - and automatically schedule and control checks for updates. + This class is now deprecated and acts as a thin wrapper around `SPUUpdater` and `SPUStandardUserDriver`. - Note: This class is now deprecated and acts as a thin wrapper around SPUUpdater and SPUStandardUserDriver + If you are migrating to Sparkle 2, use `SPUStandardUpdaterController` instead, or `SPUUpdater` if you need more control. */ __deprecated_msg("Deprecated in Sparkle 2. Use SPUStandardUpdaterController instead, or SPUUpdater if you need more control.") SU_EXPORT @interface SUUpdater : NSObject diff --git a/Sparkle/SUVersionComparisonProtocol.h b/Sparkle/SUVersionComparisonProtocol.h index 1db106f2..d1587245 100644 --- a/Sparkle/SUVersionComparisonProtocol.h +++ b/Sparkle/SUVersionComparisonProtocol.h @@ -30,12 +30,12 @@ NS_ASSUME_NONNULL_BEGIN -/*! +/** Provides version comparison facilities for Sparkle. */ @protocol SUVersionComparison -/*! +/** An abstract method to compare two version strings. Should return NSOrderedAscending if b > a, NSOrderedDescending if b < a, diff --git a/Sparkle/SUVersionDisplayProtocol.h b/Sparkle/SUVersionDisplayProtocol.h index 5ddb92b1..2407c8d5 100644 --- a/Sparkle/SUVersionDisplayProtocol.h +++ b/Sparkle/SUVersionDisplayProtocol.h @@ -16,12 +16,12 @@ #endif #import -/*! +/** Applies special display formatting to version numbers. */ SU_EXPORT @protocol SUVersionDisplay -/*! +/** Formats two version strings. Both versions are provided so that important distinguishing information diff --git a/generate_appcast/main.swift b/generate_appcast/main.swift index 8e605b43..ee9c5150 100644 --- a/generate_appcast/main.swift +++ b/generate_appcast/main.swift @@ -140,7 +140,6 @@ struct GenerateAppcast: ParsableCommand { For more advanced options that can be used for publishing updates, see https://sparkle-project.org/documentation/publishing/ for further documentation. Extracted archives are cached in \((cacheDirectory.path as NSString).abbreviatingWithTildeInPath) to avoid re-computation in subsequent runs. - If archives that were processed are modified later, the caches may need to be cleared otherwise \(programName) assumes the archives do not change. Note that \(programName) does not support package-based (.pkg) updates. """) diff --git a/objc_dep/README.md b/objc_dep/README.md deleted file mode 100644 index 6ed3c2f4..00000000 --- a/objc_dep/README.md +++ /dev/null @@ -1,108 +0,0 @@ -- 2013-04-17 merged changes from mikkelee who [added](https://github.com/nst/objc_dep/pull/6) to use a single bidirectional arrow for two-way dependencies -- 2013-02-21 merged changes from jomnius who [added](https://github.com/nst/objc_dep/pull/4) a parameter to exclude directories names by regex -- 2012-05-11 merged changes from jonreid who [added](https://github.com/nst/objc_dep/pull/3) a parameter to exclude class names by regex -- 2012-01-11 merged changes from jomnius who [added](https://github.com/nst/objc_dep/pull/1) support for C projects and better handling of categories -- read [Object graph dependency analysis](http://samuelgoodwin.tumblr.com/post/18345393597/object-graph-dependency-analysis) by Samuel Goodwin -- see also jominus blog post [Dependency Graph Tool for iOS Projects](http://jomnius.blogspot.com/2012/01/dependency-graph-tool-for-ios-projects.html) -- yet another use case on vigorouscoding.com [Better get it right the first time](http://www.vigorouscoding.com/2011/12/better-get-it-right-the-first-time/) - -# License - - BSD 3-Clause License - - Copyright (c) 2012-2013, Nicolas Seriot All rights reserved. - - Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. - Neither the name of the Nicolas Seriot nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -# Refactoring by graphing class dependencies - -### Code design and loose coupling - -As developers, we all love clean code, but the fact is that most of the time we're dealing with bad code. It may be recent or legacy code, written by ourselves or by other developers. We can recognize bad code because [code](http://en.wikipedia.org/wiki/Code_smell) [smells](http://www.codinghorror.com/blog/2006/05/code-smells.html). In other words, some heuristics raise questions about code quality. Among thoses we can name dead code, which I already wrote about [here](http://seriot.ch/blog.php?article=20080728) and [here](http://seriot.ch/blog.php?article=20100301), and tight coupling. - -Tight coupling describes a system where many components depend on many other components. A tightly coupled code base stinks, the coupling points out that some classes assume too many responsibilities or that a responsability is spread over several classes, rather than having its own class. The opposite, loose coupling, shows a better design which promotes single-responsibility and separation of concerns. Loose coupling makes the code easier to test and maintain. - -In Objective-C, reducing coupling generally involves [delegates](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocProtocols.html) and [notifications](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Notifications/Introduction/introNotifications.html%23//apple_ref/doc/uid/10000043i). - -### Graphing class dependencies - -So how do we achieve loose coupling in our own code? Well, at first, we need to get a better idea on the current coupling. Let us define class dependency: _class A depends on B if class A imports class B header_. With such a definition, we can draw a graph of dependencies between classes by considering the Objective-C `#import` directives in each class. We assume here that the files are named according to the classes they contain. - -I wrote [objc_dep.py](https://github.com/nst/objc_dep), a Python script which extracts imports from Objective-C source code. The output can then be displayed in [GraphViz](http://www.graphviz.org/) or [OmniGraffle](http://www.omnigroup.com/products/omnigraffle/). You can then see an oriented graph of dependencies between classes. Note that we could also compute metrics on coupling, but it's not the point here. - -### Sample usage - -How do we get from the dependencies graph to a better design? There's no determinist algorithm and it depends on your project. Let us apply the script on [FSWalker](http://code.google.com/p/fswalker/), a small iPhone file browser I wrote a long time ago. - -#### 1. Generate the graph - - $ python objc_dep.py /path/to/FSWalker > fswalker.dot - -#### 2. Open it in OmniGraffle - -At this point, we see classes as nodes and dependencies as directed edges. - - - -#### 3. Remove categories - -We can safely remove Objective-C [categories](http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/ObjectiveC/Articles/ocCategories.html) from the graph, since referencing categories from many places is not an issue from a design point of view. - - - -#### 4. Group related classes - -Next, we can move the vertices around, try to group classes with a common responsibility into clusters. - - - -#### 5. Study strange dependencies - -The graph now gives a pretty good overview of the overall code structure. The controller objects have been colored in pink, the model objects in yellow and the network part in blue. The graph allows to sport strange dependencies and question the code design. We can see at first glance that FSWalkerAppDelegate has too many dependencies. Specifically we consider: - -a) unreferenced classes or clusters - -This is probably dead code, which can be removed. - -Ok, there are no unreferenced classes here, although you will probably find some in bigger projects. - -b) two-ways references - -Maybe one class should not reference another directly, but reference a protocol implemented by the other class instead. - -We have two examples of two-ways references here, between HTTPServer and HTTPConnection, and also between RootViewController and FSWalkerAppDelegate. The former is part of [CocoaHTTPServer](http://code.google.com/p/cocoahttpserver/) and is not a design issue in our project. However, the latter is an issue. By looking at the code, we will notice that RootViewController doesn't actually use FSWalkerAppDelegate. The import can thus be safely removed. - -c) weird references - -Some of the import directives may simply be unnecessary, or reveal design issues. - -There is no good reason why FSWalkerAppDelegate would reference FSItem, nor InfoPanelController. Code inspection will reveal that DetailViewController and InfoPanelController should not be referenced by FSWalkerAppDelegate but RootViewController instead. So, here is the final graph. The architecture of FSWalker may still be improved, but you get the idea... - - - -### Real world usage - -Here is the kind of chart you can expect with a 100 classes project. - - - -#### Using options - -`% python objc_dep.py /path/to/repo -x "(^Internal|secret)" -i subdir1 subdir2 > graph.dot` - -Will exclude files with names that begin with "Internal", or contain the word "secret". Additionally all files in folders named subdir1 and subdir2 are ignored. - -### Possible improvements - -The Cocoa framework enforces the [MVC paradigm](http://developer.apple.com/technologies/mac/cocoa.html), which states (to be short) that model objects and graphical objects should be clearly separated by controller objects. The script could probably be improved by drawing classes which depend on Foundation and classes which depend on AppKit/UIKit with different colors. - -### Conclusion - -I have found [objc_dep.py](https://github.com/nst/objc_dep) to be definitely useful on small projects as well as bigger ones. It helped me in getting a clear view of code base structure. Spotting strange dependencies allowed me to ask good questions which led to design simplifications. Such a tool could even be integrated into Apple development tools. - -Interestingly, the last chart is quite close to the mental representation I have of the code architecture. It reminds me a discussion I had 15 years ago with a friend who was a champion chess player who could play several "blind" chess games simultaneously. He explained then that he saw a blurry chessboard in his head and could move around the pieces as with a small 3D camera. Focusing on a specific piece would then raise awareness of opportunities and risks - dependencies - for this piece. As a side effect, writing this script made me realize that software engineering is pretty similar to chess in this way. diff --git a/objc_dep/objc_dep.py b/objc_dep/objc_dep.py deleted file mode 100755 index b95fe806..00000000 --- a/objc_dep/objc_dep.py +++ /dev/null @@ -1,265 +0,0 @@ -#!/usr/bin/python - -# Nicolas Seriot -# 2011-01-06 -> 2011-12-16 -# https://github.com/nst/objc_dep/ - -""" -Input: path of an Objective-C project - -Output: import dependencies Graphviz format, unless --test is passed in which case outputs a successful exit status of 0 if no two-way dependencies are found - -Typical usage: $ python objc_dep.py /path/to/project [-x regex] [-i subfolder [subfolder ...]] > graph.dot - -The .dot file can be opened with Graphviz or OmniGraffle. - -- red arrows: .pch imports -- blue arrows: two ways imports -""" - -import sys -import os -from sets import Set -import re -from os.path import basename -import argparse - -local_regex_import = re.compile("^\s*#(?:import|include)\s+\"(?P\S*)(?P\.(?:h|hpp|hh))?\"") -system_regex_import = re.compile("^\s*#(?:import|include)\s+[\"<](?P\S*)(?P\.(?:h|hpp|hh))?[\">]") -objc_extensions = ['.h', '.hh', '.hpp', '.m', '.mm', '.c', '.cc', '.cpp'] - -def gen_filenames_imported_in_file(path, regex_exclude, system, extensions): - for line in open(path): - results = re.search(system_regex_import, line) if system else re.search(local_regex_import, line) - if results: - filename = results.group('filename') - extension = results.group('extension') if results.group('extension') else "" - if regex_exclude is not None and regex_exclude.search(filename + extension): - continue - yield (filename + extension) if extension else filename - -def dependencies_in_project(path, ext, exclude, ignore, system, extensions): - d = {} - - regex_exclude = None - if exclude: - regex_exclude = re.compile(exclude) - - for root, dirs, files in os.walk(path): - - if ignore: - for subfolder in ignore: - if subfolder in dirs: - dirs.remove(subfolder) - - objc_files = (f for f in files if f.endswith(ext)) - - for f in objc_files: - - filename = f if extensions else os.path.splitext(f)[0] - if regex_exclude is not None and regex_exclude.search(filename): - continue - - if filename not in d: - d[filename] = Set() - - path = os.path.join(root, f) - - for imported_filename in gen_filenames_imported_in_file(path, regex_exclude, system, extensions): - if imported_filename != filename and '+' not in imported_filename and '+' not in filename: - imported_filename = imported_filename if extensions else os.path.splitext(imported_filename)[0] - d[filename].add(imported_filename) - - return d - -def dependencies_in_project_with_file_extensions(path, exts, exclude, ignore, system, extensions, root_class): - - d = {} - - for ext in exts: - d2 = dependencies_in_project(path, ext, exclude, ignore, system, extensions) - for (k, v) in d2.iteritems(): - if not k in d: - d[k] = Set() - d[k] = d[k].union(v) - - if root_class: - def parse_requirements(tree, root, known_deps=[]): - next_deps = list(tree[root]) - new_deps = [] - - for dep in next_deps: - if dep not in known_deps and dep in tree: - new_deps += parse_requirements(tree, dep, known_deps + next_deps) - - return (new_deps + next_deps) - - requirements = set(parse_requirements(d, root_class)) - - return { k: d[k] for k in requirements if k in d} - - return d - -def two_ways_dependencies(d): - - two_ways = Set() - - # d is {'a1':[b1, b2], 'a2':[b1, b3, b4], ...} - - for a, l in d.iteritems(): - for b in l: - if b in d and a in d[b]: - if (a, b) in two_ways or (b, a) in two_ways: - continue - if a != b: - two_ways.add((a, b)) - - return two_ways - -def untraversed_files(d): - - dead_ends = Set() - - for file_a, file_a_dependencies in d.iteritems(): - for file_b in file_a_dependencies: - if not file_b in dead_ends and not file_b in d: - dead_ends.add(file_b) - - return dead_ends - -def category_files(d): - d2 = {} - l = [] - - for k, v in d.iteritems(): - if not v and '+' in k: - l.append(k) - else: - d2[k] = v - - return l, d2 - -def referenced_classes_from_dict(d): - d2 = {} - - for k, deps in d.iteritems(): - for x in deps: - d2.setdefault(x, Set()) - d2[x].add(k) - - return d2 - -def print_frequencies_chart(d): - - lengths = map(lambda x:len(x), d.itervalues()) - if not lengths: return - max_length = max(lengths) - - for i in range(0, max_length+1): - s = "%2d | %s\n" % (i, '*'*lengths.count(i)) - sys.stderr.write(s) - - sys.stderr.write("\n") - - l = [Set() for i in range(max_length+1)] - for k, v in d.iteritems(): - l[len(v)].add(k) - - for i in range(0, max_length+1): - s = "%2d | %s\n" % (i, ", ".join(sorted(list(l[i])))) - sys.stderr.write(s) - -def dependencies_in_dot_format(path, exclude, ignore, system, extensions, root_class): - - d = dependencies_in_project_with_file_extensions(path, objc_extensions, exclude, ignore, system, extensions, root_class) - - two_ways_set = two_ways_dependencies(d) - untraversed_set = untraversed_files(d) - - category_list, d = category_files(d) - - pch_set = dependencies_in_project(path, '.pch', exclude, ignore, system, extensions) - - # - - sys.stderr.write("# number of imports\n\n") - print_frequencies_chart(d) - - sys.stderr.write("\n# times the class is imported\n\n") - d2 = referenced_classes_from_dict(d) - print_frequencies_chart(d2) - - # - - l = [] - l.append("digraph G {") - l.append("\tnode [shape=box];") - - for k, deps in d.iteritems(): - if deps: - deps.discard(k) - - if len(deps) == 0: - l.append("\t\"%s\" -> {};" % (k)) - - for k2 in deps: - if not ((k, k2) in two_ways_set or (k2, k) in two_ways_set): - l.append("\t\"%s\" -> \"%s\";" % (k, k2)) - - l.append("\t") - for (k, v) in pch_set.iteritems(): - l.append("\t\"%s\" [color=red];" % k) - for x in v: - l.append("\t\"%s\" -> \"%s\" [color=red];" % (k, x)) - - l.append("\t") - l.append("\tedge [color=blue, dir=both];") - - for (k, k2) in two_ways_set: - l.append("\t\"%s\" -> \"%s\";" % (k, k2)) - - for k in untraversed_set: - l.append("\t\"%s\" [color=gray, style=dashed, fontcolor=gray]" % k) - - if category_list: - l.append("\t") - l.append("\tedge [color=black];") - l.append("\tnode [shape=plaintext];") - l.append("\t\"Categories\" [label=\"%s\"];" % "\\n".join(category_list)) - - if ignore: - l.append("\t") - l.append("\tnode [shape=box, color=blue];") - l.append("\t\"Ignored\" [label=\"%s\"];" % "\\n".join(ignore)) - - l.append("}\n") - return '\n'.join(l) - -def main(): - parser = argparse.ArgumentParser() - parser.add_argument("-x", "--exclude", nargs='?', default='' ,help="regular expression of substrings to exclude from module names") - parser.add_argument("-i", "--ignore", nargs='*', help="list of subfolder names to ignore") - parser.add_argument("-s", "--system", action='store_true', default=False, help="include system dependencies") - parser.add_argument("-e", "--extensions", action='store_true', default=False, help="print file extensions") - parser.add_argument("-r", "--root", default='', help="Class to use as root of dependency graph") - parser.add_argument("-t", "--test", action='store_true', default=False, help="Exit with a success status of 0 if no two-way dependencies exist or failure otherwise, instead of outputting a graph") - parser.add_argument("project_path", help="path to folder hierarchy containing Objective-C files") - args= parser.parse_args() - - if not args.test: - print dependencies_in_dot_format(args.project_path, args.exclude, args.ignore, args.system, args.extensions, args.root) - else: - # Test if two-way dependencies exist. If none do, then exit on success (0), otherwise exit on failure (1) - d = dependencies_in_project_with_file_extensions(args.project_path, objc_extensions, args.exclude, args.ignore, args.system, args.extensions, args.root) - two_ways_set = two_ways_dependencies(d) - - if len(two_ways_set) == 0: - sys.exit(0) - else: - sys.stderr.write("Error: Found two way dependencies:\n") - for (k, k2) in two_ways_set: - sys.stderr.write("%s <-> %s\n" % (k, k2)) - sys.exit(1) - -if __name__=='__main__': - main() diff --git a/objc_dep/source.txt b/objc_dep/source.txt deleted file mode 100644 index 28399ce0..00000000 --- a/objc_dep/source.txt +++ /dev/null @@ -1,3 +0,0 @@ -Source: https://github.com/nst/objc_dep/ -License: See README.md -Commit: c73b097d8de0fbca8b9468cf25aaef398d66c68f