diff --git a/.swift-version b/.swift-version new file mode 100644 index 00000000..a75b92f1 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +5.1 diff --git a/Podfile b/Podfile index 0f35a384..0d8e12cb 100644 --- a/Podfile +++ b/Podfile @@ -17,6 +17,7 @@ target 'CairoSVG' do end + target 'Speculid' do # Comment the next line if you're not using Swift and don't want to use dynamic frameworks use_frameworks! @@ -24,11 +25,16 @@ target 'Speculid' do # Pods for Speculid pod 'SwiftVer' - target 'SpeculidTests' do - inherit! :search_paths - # Pods for testing - end + + +end +target 'SpeculidTests' do + # Comment the next line if you're not using Swift and don't want to use dynamic frameworks + use_frameworks! + + # Pods for Speculid + pod 'SwiftVer' end target 'Speculid-Mac-App' do diff --git a/Podfile.lock b/Podfile.lock index 62807a97..a76a3d58 100644 --- a/Podfile.lock +++ b/Podfile.lock @@ -9,7 +9,7 @@ DEPENDENCIES: - SwiftVer SPEC REPOS: - https://github.com/cocoapods/specs.git: + https://github.com/CocoaPods/Specs.git: - SwiftFormat - SwiftLint - SwiftVer @@ -19,6 +19,6 @@ SPEC CHECKSUMS: SwiftLint: 5553187048b900c91aa03552807681bb6b027846 SwiftVer: 85fca0c0087660e0b07fe021efdd4b794046e465 -PODFILE CHECKSUM: 2ecd26879e8bf7a7ac71ae7dbb51d7fe0d3d478d +PODFILE CHECKSUM: 432b032d04411cede9e0269a79b2d07c89f85f01 -COCOAPODS: 1.7.3 +COCOAPODS: 1.8.0 diff --git a/Speculid.xcodeproj/project.pbxproj b/Speculid.xcodeproj/project.pbxproj index 2edaab7a..99616415 100644 --- a/Speculid.xcodeproj/project.pbxproj +++ b/Speculid.xcodeproj/project.pbxproj @@ -4780,6 +4780,7 @@ B3136E7A1F90FD2E0002B7AB /* Sources */, B3136E7B1F90FD2E0002B7AB /* Frameworks */, B3136E7C1F90FD2E0002B7AB /* Resources */, + AB8615DAE34FEF509F2B61FF /* [CP] Embed Pods Frameworks */, ); buildRules = ( ); @@ -4949,27 +4950,33 @@ TargetAttributes = { B3136E5F1F90FCCF0002B7AB = { CreatedOnToolsVersion = 9.0; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; TestTargetID = B37C743D1F8C58F300DF505B; }; B3136E7D1F90FD2E0002B7AB = { CreatedOnToolsVersion = 9.0; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; }; B3136E8C1F90FD3D0002B7AB = { CreatedOnToolsVersion = 9.0; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; }; B3242E96213DBE6C0063037C = { CreatedOnToolsVersion = 10.0; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; }; B326F24E21811B970072D652 = { CreatedOnToolsVersion = 10.0; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; }; B37C743D1F8C58F300DF505B = { CreatedOnToolsVersion = 9.0; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; SystemCapabilities = { com.apple.HardenedRuntime = { @@ -4982,7 +4989,7 @@ }; B37C74521F8C590D00DF505B = { CreatedOnToolsVersion = 9.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; SystemCapabilities = { com.apple.HardenedRuntime = { @@ -4992,7 +4999,7 @@ }; B37C74721F8C5ADA00DF505B = { CreatedOnToolsVersion = 9.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1110; ProvisioningStyle = Automatic; }; B37C74881F8C5B5C00DF505B = { @@ -5199,6 +5206,24 @@ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; showEnvVarsInLog = 0; }; + AB8615DAE34FEF509F2B61FF /* [CP] Embed Pods Frameworks */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-SpeculidTests/Pods-SpeculidTests-frameworks.sh", + "${BUILT_PRODUCTS_DIR}/SwiftVer/SwiftVer.framework", + ); + name = "[CP] Embed Pods Frameworks"; + outputPaths = ( + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/SwiftVer.framework", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SpeculidTests/Pods-SpeculidTests-frameworks.sh\"\n"; + showEnvVarsInLog = 0; + }; B3136E9C1F9100CB0002B7AB /* Autorevision */ = { isa = PBXShellScriptBuildPhase; buildActionMask = 2147483647; @@ -5225,7 +5250,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "\"${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat\" \"${SRCROOT}/frameworks\" --disable trailingCommas --indent 2 --allman false --removelines enabled --header strip --insertlines disabled --empty void --ranges spaced --trimwhitespace always --linebreaks lf --commas always --comments indent --ifdef indent --hexliterals uppercase --semicolons inline"; + shellScript = "\"${PODS_ROOT}/SwiftFormat/CommandLineTool/swiftformat\" \"${SRCROOT}/frameworks\" --disable trailingCommas --indent 2 --allman false --removelines enabled --header strip --insertlines disabled --empty void --ranges spaced --trimwhitespace always --linebreaks lf --commas always --comments indent --ifdef indent --hexliterals uppercase --semicolons inline\n"; }; B318906C1F91A02000D0EFA0 /* swiftlint */ = { isa = PBXShellScriptBuildPhase; @@ -5601,7 +5626,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-AppUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = "Speculid-Mac-App"; }; name = Debug; @@ -5620,7 +5645,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-AppUITests"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = "Speculid-Mac-App"; }; name = Release; @@ -5639,7 +5664,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.brightdigit.SpeculidTests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -5657,7 +5682,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.brightdigit.SpeculidTests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -5675,7 +5700,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.brightdigit.CairoSVGTests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -5693,7 +5718,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.brightdigit.CairoSVGTests; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -5707,7 +5732,7 @@ MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; PRODUCT_NAME = speculid; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -5720,7 +5745,7 @@ INSTALL_PATH = ""; MTL_FAST_MATH = YES; PRODUCT_NAME = speculid; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -5749,7 +5774,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -5777,7 +5802,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -5920,7 +5945,7 @@ PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(PROJECT_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -5941,7 +5966,7 @@ PRODUCT_MODULE_NAME = "$(TARGET_NAME:c99extidentifier)"; PRODUCT_NAME = "$(PROJECT_NAME:c99extidentifier)"; PROVISIONING_PROFILE_SPECIFIER = ""; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -5963,7 +5988,7 @@ PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -5984,7 +6009,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -6007,7 +6032,7 @@ PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)Kit"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -6031,7 +6056,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "com.brightdigit.Speculid-Mac-Framework"; PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)Kit"; SKIP_INSTALL = YES; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme index eaead017..6def7311 100644 --- a/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme +++ b/Speculid.xcodeproj/xcshareddata/xcschemes/Speculid-Mac-App.xcscheme @@ -118,7 +118,7 @@ + isEnabled = "YES"> + isEnabled = "NO"> - - diff --git a/Speculid.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings b/Speculid.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings deleted file mode 100644 index 0c67376e..00000000 --- a/Speculid.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/frameworks/speculid/Controllers/Application.swift b/frameworks/speculid/Controllers/Application.swift index 21103524..d692fc12 100644 --- a/frameworks/speculid/Controllers/Application.swift +++ b/frameworks/speculid/Controllers/Application.swift @@ -28,17 +28,17 @@ open class Application: NSApplication, ApplicationProtocol { return try SpeculidDocument(url: url, decoder: jsonDecoder, configuration: configuration) } - open static var current: ApplicationProtocol! { + public static var current: ApplicationProtocol! { return NSApplication.shared as? ApplicationProtocol } - open static let unknownCommandMessagePrefix = "Unknown Command Arguments" + public static let unknownCommandMessagePrefix = "Unknown Command Arguments" public static func unknownCommandMessage(fromArguments arguments: [String]) -> String { return "\(unknownCommandMessagePrefix): \(arguments.joined(separator: " "))" } - open static let helpText: String! = { + public static let helpText: String! = { guard let url = Application.bundle.url(forResource: "help", withExtension: "txt") else { return nil } @@ -66,13 +66,13 @@ open class Application: NSApplication, ApplicationProtocol { open private(set) var configuration: SpeculidConfigurationProtocol! open private(set) var builder: SpeculidBuilderProtocol! - open let statusItemProvider: StatusItemProviderProtocol - open let remoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol - open let installerObjectInterfaceProvider: InstallerObjectInterfaceProviderProtocol - open let regularExpressionBuilder: RegularExpressionSetBuilderProtocol - open let configurationBuilder: SpeculidConfigurationBuilderProtocol - open let jsonDecoder: JSONDecoder - open let imageSpecificationBuilder: SpeculidImageSpecificationBuilderProtocol + public let statusItemProvider: StatusItemProviderProtocol + public let remoteObjectInterfaceProvider: RemoteObjectInterfaceProviderProtocol + public let installerObjectInterfaceProvider: InstallerObjectInterfaceProviderProtocol + public let regularExpressionBuilder: RegularExpressionSetBuilderProtocol + public let configurationBuilder: SpeculidConfigurationBuilderProtocol + public let jsonDecoder: JSONDecoder + public let imageSpecificationBuilder: SpeculidImageSpecificationBuilderProtocol open var commandLineRunner: CommandLineRunnerProtocol public override init() { diff --git a/frameworks/speculid/Controllers/SpeculidApplicationModeParser.swift b/frameworks/speculid/Controllers/SpeculidApplicationModeParser.swift index 2ed8ec66..9b759925 100644 --- a/frameworks/speculid/Controllers/SpeculidApplicationModeParser.swift +++ b/frameworks/speculid/Controllers/SpeculidApplicationModeParser.swift @@ -6,7 +6,7 @@ public struct SpeculidApplicationModeParser: SpeculidApplicationModeParserProtoc if commandLine.arguments.first == Bundle.main.executablePath { indicies.append(commandLine.arguments.startIndex) } - if let index = commandLine.arguments.index(of: "-NSDocumentRevisionsDebugMode") { + if let index = commandLine.arguments.firstIndex(of: "-NSDocumentRevisionsDebugMode") { indicies.append(index) indicies.append(index.advanced(by: 1)) } @@ -39,10 +39,10 @@ public struct SpeculidApplicationModeParser: SpeculidApplicationModeParserProtoc } } } - -@available(swift, obsoleted: 4.2) -extension Array where Element: Equatable { - func firstIndex(of element: Element) -> Index? { - return index(of: element) - } -} +// +// @available(swift, obsoleted: 4.2) +// extension Array where Element: Equatable { +// func firstIndex(of element: Element) -> Index? { +// return firstIndex(of: element) +// } +// } diff --git a/frameworks/speculid/Controllers/VersionMenuItem.swift b/frameworks/speculid/Controllers/VersionMenuItem.swift index 7bf3e7c8..ab5d71c9 100644 --- a/frameworks/speculid/Controllers/VersionMenuItem.swift +++ b/frameworks/speculid/Controllers/VersionMenuItem.swift @@ -11,7 +11,7 @@ public class VersionMenuItem: NSMenuItem { public static func buildNumbers(fromResource resource: String?, withExtension extension: String?) -> Set? { if let url = Application.bundle.url(forResource: resource, withExtension: `extension`) { if let text = try? String(contentsOf: url) { - return Set(text.components(separatedBy: CharacterSet.newlines).flatMap { Int($0) }) + return Set(text.components(separatedBy: CharacterSet.newlines).compactMap { Int($0) }) } } return nil diff --git a/frameworks/speculid/Extensions/NSColor.swift b/frameworks/speculid/Extensions/NSColor.swift index d7d48386..f32f56fd 100644 --- a/frameworks/speculid/Extensions/NSColor.swift +++ b/frameworks/speculid/Extensions/NSColor.swift @@ -88,7 +88,7 @@ extension NSColor { throw UIColorInputError.unableToScanHexValue } - switch hexString.characters.count { + switch hexString.count { case 3: self.init(hex3: UInt16(hexValue)) case 4: @@ -162,15 +162,15 @@ extension String { let index = self.index(startIndex, offsetBy: 1) let hexString = self[index...] - switch hexString.characters.count { + switch hexString.count { case 4: return "#" - + hexString.substring(from: characters.index(startIndex, offsetBy: 1)) - + hexString.substring(to: characters.index(startIndex, offsetBy: 1)) + + hexString.substring(from: self.index(startIndex, offsetBy: 1)) + + hexString.substring(to: self.index(startIndex, offsetBy: 1)) case 8: return "#" - + hexString.substring(from: characters.index(startIndex, offsetBy: 2)) - + hexString.substring(to: characters.index(startIndex, offsetBy: 2)) + + hexString.substring(from: self.index(startIndex, offsetBy: 2)) + + hexString.substring(to: self.index(startIndex, offsetBy: 2)) default: return nil } diff --git a/frameworks/speculid/Extensions/String.swift b/frameworks/speculid/Extensions/String.swift index bc1e8d1b..648a5af6 100644 --- a/frameworks/speculid/Extensions/String.swift +++ b/frameworks/speculid/Extensions/String.swift @@ -2,12 +2,12 @@ import Foundation extension String { public func firstMatchGroups(regex: NSRegularExpression) -> [String]? { - let range = NSRange(0 ..< characters.count) + let range = NSRange(0 ..< count) guard let result = regex.firstMatch(in: self, options: [], range: range) else { return nil } - return (0 ..< result.numberOfRanges).flatMap { (index) -> String? in + return (0 ..< result.numberOfRanges).compactMap { (index) -> String? in guard let range = Range(result.range(at: index), in: self) else { return nil } diff --git a/tests/speculid/Controllers/SpeculidApplicationModeParserTest.swift b/tests/speculid/Controllers/SpeculidApplicationModeParserTest.swift index bc549f3a..1d79d5c1 100644 --- a/tests/speculid/Controllers/SpeculidApplicationModeParserTest.swift +++ b/tests/speculid/Controllers/SpeculidApplicationModeParserTest.swift @@ -15,29 +15,29 @@ extension Array where Element == String { return (0 ..< count).map { _ in String.randomAlphanumeric(ofLength: 100) } } } - -@available(swift, obsoleted: 4.2) -extension Array { - func randomElement() -> Element? { - guard count > 0 else { - return nil - } - let index = Index(arc4random_uniform(UInt32(count))) - return self[index] - } -} - -@available(swift, obsoleted: 4.2) -extension String { - func randomElement() -> Character? { - guard count > 0 else { - return nil - } - let offset = Int(arc4random_uniform(UInt32(count))) - let index = self.index(startIndex, offsetBy: offset) - return self[index] - } -} +// +// @available(swift, obsoleted: 4.2) +// extension Array { +// func randomElement() -> Element? { +// guard count > 0 else { +// return nil +// } +// let index = Index(arc4random_uniform(UInt32(count))) +// return self[index] +// } +// } +// +// @available(swift, obsoleted: 4.2) +// extension String { +// func randomElement() -> Character? { +// guard count > 0 else { +// return nil +// } +// let offset = Int(arc4random_uniform(UInt32(count))) +// let index = self.index(startIndex, offsetBy: offset) +// return self[index] +// } +// } struct SimpleCommandLineArgumentProvider: CommandLineArgumentProviderProtocol { public let arguments: [String]