From da6a5f8f93a4bda55961a93788200c9019bb76d0 Mon Sep 17 00:00:00 2001 From: Adam Sharp Date: Sat, 25 May 2019 12:37:28 -0400 Subject: [PATCH 1/5] Update dependencies for Swift 5 --- .gitignore | 1 - .swift-version | 2 +- Cartfile | 4 ++-- Cartfile.private | 2 +- Package.swift | 8 ++++---- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index fbb880c..06fd4ff 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ xcuserdata/ # swiftpm /.build -/Package.pins /Package.resolved # Carthage diff --git a/.swift-version b/.swift-version index 5186d07..6b244dc 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0 +5.0.1 diff --git a/Cartfile b/Cartfile index b952884..f7e307f 100644 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,2 @@ -github "Quick/Quick" ~> 1.1.0 -github "sharplet/Regex" ~> 1.0 +github "Quick/Quick" ~> 2.0 +github "sharplet/Regex" ~> 2.0 diff --git a/Cartfile.private b/Cartfile.private index 8613a20..6a43d61 100644 --- a/Cartfile.private +++ b/Cartfile.private @@ -1 +1 @@ -github "Quick/Nimble" ~> 7.0 +github "Quick/Nimble" ~> 8.0 diff --git a/Package.swift b/Package.swift index f273008..e8d8f25 100644 --- a/Package.swift +++ b/Package.swift @@ -5,9 +5,9 @@ import PackageDescription let package = Package( name: "Scenarios", dependencies: [ - .package(url: "https://github.com/sharplet/Regex.git", from: "1.0.0"), - .package(url: "https://github.com/Quick/Quick.git", from: "1.0.0"), - .package(url: "https://github.com/Quick/Nimble.git", from: "7.0.0"), + .package(url: "https://github.com/sharplet/Regex.git", from: "2.0.0"), + .package(url: "https://github.com/Quick/Quick.git", from: "2.0.0"), + .package(url: "https://github.com/Quick/Nimble.git", from: "8.0.0"), ], targets: [ .target( @@ -27,5 +27,5 @@ let package = Package( path: "Tests" ), ], - swiftLanguageVersions: [3, 4] + swiftLanguageVersions: [4, 5] ) From 320ab3a3b17d20b3d7dbb63cd72d25ffc8338892 Mon Sep 17 00:00:00 2001 From: Adam Sharp Date: Sat, 25 May 2019 15:44:23 -0400 Subject: [PATCH 2/5] Work around Quick's FileString type We want to use StaticString pervasively, because it's required in order to call XCTFail. If we adopted FileString, we'd also have to add Nimble as a dependency in order to use it's fail() assertion. --- Scenarios.xcodeproj/project.pbxproj | 1 + Scenarios/Components/Roles.swift | 14 ------------- Scenarios/Components/Types.swift | 8 -------- Scenarios/Feature.swift | 8 +++----- Scenarios/Scenario.swift | 17 +++++++++------- Scenarios/Step.swift | 8 ++------ Scenarios/StepArguments.swift | 7 ++----- Scenarios/StepDefinition.swift | 10 +++------- Tests/ScenariosTests/ScenarioSpec.swift | 20 ++++--------------- .../ScenariosTests/StepArgumentsFeature.swift | 12 +++-------- 10 files changed, 28 insertions(+), 77 deletions(-) diff --git a/Scenarios.xcodeproj/project.pbxproj b/Scenarios.xcodeproj/project.pbxproj index 045ae63..eb0c87c 100644 --- a/Scenarios.xcodeproj/project.pbxproj +++ b/Scenarios.xcodeproj/project.pbxproj @@ -259,6 +259,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = CE0508831BDDE75100B21C8C; diff --git a/Scenarios/Components/Roles.swift b/Scenarios/Components/Roles.swift index 571da11..b53f349 100644 --- a/Scenarios/Components/Roles.swift +++ b/Scenarios/Components/Roles.swift @@ -17,7 +17,6 @@ /// /// Asserting results for scenarios can be extended by asserting multiple results. public protocol Extendable { - /// Specifies an extension to the most recent declaration of the scenario. /// /// - parameters: @@ -26,14 +25,11 @@ public protocol Extendable { /// - returns: A scenario which captures all specifications in the previous scenario /// as well as the new specification. func And(_ description: String, file: StaticString, line: UInt) -> Self - } - /// Scenarios which have yet to have any specification as to how they should be /// prepared / how the conditions for the scenario should be __arranged__. public protocol Preparable { - /// Specifies the preparation / arrangement step for the scenario. /// /// - parameters: @@ -43,14 +39,11 @@ public protocol Preparable { /// /// - seealso: Extendable func Given(_ description: String, file: StaticString, line: UInt) -> Prepared - } - /// Scenarios for which the steps to carry out the tests which they capture have not /// yet been specified. public protocol Actionable { - /// Specifies the action step for the scenario. /// /// - parameters: @@ -60,14 +53,11 @@ public protocol Actionable { /// /// - seealso: Extendable func When(_ description: String, file: StaticString, line: UInt) -> Actioned - } - /// Scenarios which have had some action / manipulation performed, and are ready to have /// results be asserted. public protocol Assertable { - /// Specifies the assertion step for the scenario. /// /// - parameters: @@ -76,15 +66,12 @@ public protocol Assertable { /// /// - seealso: Extendable func Then(_ description: String, file: StaticString, line: UInt) -> Asserted - } - /// Instances of conforming types build scenarios by collecting multiple /// components (types which are `Preparable`, `Actionable`, `Assertable`) as they are /// built-up, and commit the result to the test harness. internal protocol ScenarioBuilder { - /// Adds a specification to the scenario to-be-built. /// /// - note: Agnostic to the current stage of the built-up scenario. @@ -93,5 +80,4 @@ internal protocol ScenarioBuilder { /// - description: A specification detailing the steps to be appended to the /// current state of the scenario. mutating func add(stepWithDescription description: String, file: StaticString, line: UInt) - } diff --git a/Scenarios/Components/Types.swift b/Scenarios/Components/Types.swift index 5f44241..ae4c18b 100644 --- a/Scenarios/Components/Types.swift +++ b/Scenarios/Components/Types.swift @@ -21,7 +21,6 @@ /// - be manipulated / acted upon (for example, by tapping on a button, or scrolling down /// a list), in preparation for future state assertion. public final class Prepared: Assertable, Actionable, Extendable { - private var builder: ScenarioBuilder internal init(_ builder: ScenarioBuilder) { @@ -43,10 +42,8 @@ public final class Prepared: Assertable, Actionable, Extendable { builder.add(stepWithDescription: description, file: file, line: line) return Asserted(builder) } - } - /// A scenario that has had some intermediate action(s) performed (it has had preconditions /// prepared, and its test steps, the actions, performed), and is ready to have its /// state be asserted. @@ -67,7 +64,6 @@ public final class Prepared: Assertable, Actionable, Extendable { /// At this stage, the scenario has had its test case `Actioned`, and is ready to /// have its (new) state be asserted. public final class Actioned: Assertable, Extendable { - private var builder: ScenarioBuilder internal init(_ builder: ScenarioBuilder) { @@ -84,10 +80,8 @@ public final class Actioned: Assertable, Extendable { builder.add(stepWithDescription: description, file: file, line: line) return Asserted(builder) } - } - /// A scenario that has had its state, post-test-case-execution, asserted. /// /// - note: A scenario is generally `Asserted` as a result of a `Then` step, followed @@ -115,7 +109,6 @@ public final class Actioned: Assertable, Extendable { /// At this stage, the scenario has `Asserted` its expectations of the results of /// the test case execution and is ready to be built. public final class Asserted: Extendable { - private var builder: ScenarioBuilder internal init(_ builder: ScenarioBuilder) { @@ -127,5 +120,4 @@ public final class Asserted: Extendable { builder.add(stepWithDescription: description, file: file, line: line) return self } - } diff --git a/Scenarios/Feature.swift b/Scenarios/Feature.swift index 3e3bc92..7974c6f 100644 --- a/Scenarios/Feature.swift +++ b/Scenarios/Feature.swift @@ -1,9 +1,10 @@ // Copyright © 2015 Outware Mobile. All rights reserved. +import Quick + /// Subclass `Feature` and override `scenarios()` to define the steps for the /// scenarios in your feature. open class Feature: QuickSpec { - override open func setUp() { super.setUp() continueAfterFailure = false @@ -18,7 +19,7 @@ open class Feature: QuickSpec { #if swift(>=4) override open func recordFailure(withDescription description: String, inFile filePath: String, atLine lineNumber: Int, expected: Bool) { if let sourceLocation = StepDefinition.executingStep?.sourceLocation { - super.recordFailure(withDescription: description, inFile: sourceLocation.filePath, atLine: Int(sourceLocation.lineNumber), expected: expected) + super.recordFailure(withDescription: description, inFile: String(describing: sourceLocation.filePath), atLine: Int(sourceLocation.lineNumber), expected: expected) } else { super.recordFailure(withDescription: description, inFile: filePath, atLine: lineNumber, expected: expected) } @@ -32,7 +33,4 @@ open class Feature: QuickSpec { } } #endif - } - -import Quick diff --git a/Scenarios/Scenario.swift b/Scenarios/Scenario.swift index 859dd48..b850074 100644 --- a/Scenarios/Scenario.swift +++ b/Scenarios/Scenario.swift @@ -1,5 +1,11 @@ // Copyright © 2015 Outware Mobile. All rights reserved. +#if !SWIFT_PACKAGE +import func Nimble.fail +#endif +import Quick +import XCTest + /// Define a scenario by giving it a name and then adding steps, like so: /// /// Scenario("Greeting on first load") @@ -10,7 +16,6 @@ /// block by looking up the step definitions based on the step names. The test /// fails if any of the steps are undefined. public final class Scenario: Preparable, Actionable, ScenarioBuilder { - private let name: String private let file: StaticString private let line: UInt @@ -82,23 +87,21 @@ public final class Scenario: Preparable, Actionable, ScenarioBuilder { internal func add(stepWithDescription description: String, file: StaticString, line: UInt) { stepDescriptions.append((description: description, file: file, line: line)) } - } public typealias CommitFunc = (String, StaticString, UInt, @escaping () -> Void) -> Void private let quick_it: CommitFunc = { description, file, line, closure in +#if SWIFT_PACKAGE + it(description, file: file, line: line, closure: closure) +#else it(description, file: String(describing: file), line: line, closure: closure) +#endif } private typealias StepMetadata = (description: String, file: StaticString, line: UInt) private enum ResolvedSteps { - case missingStep(StepMetadata) case matchedActions([StepActionFunc]) - } - -import Quick -import XCTest diff --git a/Scenarios/Step.swift b/Scenarios/Step.swift index 86cd34c..03b8e64 100644 --- a/Scenarios/Step.swift +++ b/Scenarios/Step.swift @@ -1,20 +1,16 @@ // Copyright © 2015 Outware Mobile. All rights reserved. internal struct SourceLocation { - - var filePath: String + var filePath: StaticString var lineNumber: UInt - } internal struct Step { - let name: String let sourceLocation: SourceLocation init(name: String, inFile filePath: StaticString, atLine lineNumber: UInt) { self.name = name - self.sourceLocation = SourceLocation(filePath: String(describing: filePath), lineNumber: lineNumber) + self.sourceLocation = SourceLocation(filePath: filePath, lineNumber: lineNumber) } - } diff --git a/Scenarios/StepArguments.swift b/Scenarios/StepArguments.swift index 534f1d2..ed05644 100644 --- a/Scenarios/StepArguments.swift +++ b/Scenarios/StepArguments.swift @@ -1,10 +1,10 @@ // Copyright © 2015 Outware Mobile. All rights reserved. -public struct StepArguments: Collection { +import Regex +public struct StepArguments: Collection { public let startIndex: Int = 0 public var endIndex: Int { return captures.endIndex } - private let captures: [String] internal init(_ matchResult: MatchResult) { @@ -18,7 +18,4 @@ public struct StepArguments: Collection { public func index(after i: Int) -> Int { return captures.index(after: i) } - } - -import Regex diff --git a/Scenarios/StepDefinition.swift b/Scenarios/StepDefinition.swift index a05d94d..f00bc90 100644 --- a/Scenarios/StepDefinition.swift +++ b/Scenarios/StepDefinition.swift @@ -1,10 +1,12 @@ // Copyright © 2015 Outware Mobile. All rights reserved. +import Quick +import Regex + public typealias StepDefinitionFunc = (StepArguments) -> Void internal typealias StepActionFunc = () -> Void open class StepDefinition: QuickSpec { - private typealias UnmatchedStep = (pattern: Regex, function: StepDefinitionFunc) private typealias MatchedStep = (arguments: StepArguments, function: StepDefinitionFunc) @@ -25,7 +27,6 @@ open class StepDefinition: QuickSpec { // MARK: Matching step definitions internal static func lookup(_ description: String, forStepInFile filePath: StaticString, atLine lineNumber: UInt) -> () -> StepActionFunc? { - let step = Step(name: description, inFile: filePath, atLine: lineNumber) func matchingStep(_ step: UnmatchedStep) -> MatchedStep? { @@ -46,7 +47,6 @@ open class StepDefinition: QuickSpec { executingStep = nil } } - } // MARK: Step definition hook @@ -81,8 +81,4 @@ open class StepDefinition: QuickSpec { } private static var stepDefinitions: [UnmatchedStep] = [] - } - -import Quick -import Regex diff --git a/Tests/ScenariosTests/ScenarioSpec.swift b/Tests/ScenariosTests/ScenarioSpec.swift index 13215a0..323ef9f 100644 --- a/Tests/ScenariosTests/ScenarioSpec.swift +++ b/Tests/ScenariosTests/ScenarioSpec.swift @@ -1,15 +1,14 @@ // Copyright © 2015 Outware Mobile. All rights reserved. -final class ScenarioSpec: QuickSpec { +import Quick +import Nimble +import Scenarios +final class ScenarioSpec: QuickSpec { override func spec() { - describe("A Scenario") { - describe("its generated test name") { - it("is the same as the name of the scenario") { - var capturedName: String? let commitFunction: CommitFunc = { (description: String, _, _, _) -> Void in @@ -19,11 +18,9 @@ final class ScenarioSpec: QuickSpec { _ = Scenario("a new scenario", commit: commitFunction) expect(capturedName).to(equal("a new scenario")) - } it("doesn't include any step names") { - var capturedName: String? let commitFunction: CommitFunc = { (description: String, _, _, _) -> Void in @@ -35,17 +32,8 @@ final class ScenarioSpec: QuickSpec { expect(capturedName).toNot(contain("a single step")) expect(capturedName).to(equal("a new scenario")) - } - } - } - } - } - -import Quick -import Nimble -import Scenarios diff --git a/Tests/ScenariosTests/StepArgumentsFeature.swift b/Tests/ScenariosTests/StepArgumentsFeature.swift index 0873c64..a1327e1 100644 --- a/Tests/ScenariosTests/StepArgumentsFeature.swift +++ b/Tests/ScenariosTests/StepArgumentsFeature.swift @@ -1,7 +1,9 @@ // Copyright © 2015 Outware Mobile. All rights reserved. -final class StepArgumentsFeature: Feature { +import Nimble +import Scenarios +final class StepArgumentsFeature: Feature { override func scenarios() { Scenario("Single argument") @@ -20,13 +22,10 @@ final class StepArgumentsFeature: Feature { .And("the third argument is baz") } - } final class StepArgumentsSteps: StepDefinition { - override func steps() { - var capturedArgs: StepArguments! Given("I provide arguments \\[1:(\\S+)\\]") { args in @@ -62,10 +61,5 @@ final class StepArgumentsSteps: StepDefinition { expect(subject).to(equal(expected)) } - } - } - -import Nimble -import Scenarios From cc1c66e1ebf2116e4d59cff972037225d5a9a727 Mon Sep 17 00:00:00 2001 From: Adam Sharp Date: Sat, 25 May 2019 15:47:54 -0400 Subject: [PATCH 3/5] Migrate project to Swift 5 --- Package.swift | 4 +-- Package@swift-3.swift | 32 ------------------- Scenarios.xcodeproj/project.pbxproj | 16 +++++++--- .../xcschemes/Scenarios-iOS.xcscheme | 2 +- Scenarios/StepDefinition.swift | 2 +- 5 files changed, 15 insertions(+), 41 deletions(-) delete mode 100644 Package@swift-3.swift diff --git a/Package.swift b/Package.swift index e8d8f25..7e622d2 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.0 +// swift-tools-version:5.0 import PackageDescription @@ -27,5 +27,5 @@ let package = Package( path: "Tests" ), ], - swiftLanguageVersions: [4, 5] + swiftLanguageVersions: [.v5] ) diff --git a/Package@swift-3.swift b/Package@swift-3.swift deleted file mode 100644 index 0a79978..0000000 --- a/Package@swift-3.swift +++ /dev/null @@ -1,32 +0,0 @@ -// swift-tools-version:3.1 - -import Foundation -import PackageDescription - -var isTesting: Bool { - let environment = ProcessInfo.processInfo.environment - guard let value = environment["SCENARIOS_SWIFTPM_TEST"] else { return false } - return NSString(string: value).boolValue -} - -var package = Package( - name: "Scenarios", - targets: [ - Target(name: "Scenarios"), - ], - dependencies: [ - .Package(url: "https://github.com/Quick/Quick.git", majorVersion: 1), - .Package(url: "https://github.com/sharplet/Regex.git", majorVersion: 1), - ], - swiftLanguageVersions: [3, 4], - exclude: [ - "Carthage", - "Demo", - ] -) - -if isTesting { - package.dependencies.append(contentsOf: [ - .Package(url: "https://github.com/Quick/Nimble.git", majorVersion: 7), - ]) -} diff --git a/Scenarios.xcodeproj/project.pbxproj b/Scenarios.xcodeproj/project.pbxproj index eb0c87c..b76e430 100644 --- a/Scenarios.xcodeproj/project.pbxproj +++ b/Scenarios.xcodeproj/project.pbxproj @@ -241,26 +241,26 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0700; - LastUpgradeCheck = 0940; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Outware Mobile"; TargetAttributes = { CE05088C1BDDE75100B21C8C = { CreatedOnToolsVersion = 7.0.1; - LastSwiftMigration = 0830; + LastSwiftMigration = 1020; }; CE0508961BDDE75100B21C8C = { CreatedOnToolsVersion = 7.0.1; - LastSwiftMigration = 0830; + LastSwiftMigration = 1020; }; }; }; buildConfigurationList = CE0508871BDDE75100B21C8C /* Build configuration list for PBXProject "Scenarios" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, + Base, ); mainGroup = CE0508831BDDE75100B21C8C; productRefGroup = CE05088E1BDDE75100B21C8C /* Products */; @@ -329,6 +329,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -389,6 +390,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -463,6 +465,7 @@ PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -489,6 +492,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "au.com.outware.$(PROJECT_NAME)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -503,6 +507,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "au.com.outware.$(PROJECT_NAME)Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -517,6 +522,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "au.com.outware.$(PROJECT_NAME)Tests"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; }; name = Release; }; diff --git a/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios-iOS.xcscheme b/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios-iOS.xcscheme index 231143e..a3b548b 100644 --- a/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios-iOS.xcscheme +++ b/Scenarios.xcodeproj/xcshareddata/xcschemes/Scenarios-iOS.xcscheme @@ -1,6 +1,6 @@ Date: Sat, 25 May 2019 16:03:07 -0400 Subject: [PATCH 4/5] Modernise Travis CI configuration --- .travis.yml | 8 +- Brewfile | 2 + Demo/Demo.xcodeproj/project.pbxproj | 35 +++++- .../xcshareddata/xcschemes/Demo-iOS.xcscheme | 2 +- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++ Demo/iOS/Features/GreetingFeature.swift | 4 +- Demo/iOS/Features/Steps/AppSteps.swift | 8 +- Demo/iOS/Features/Steps/GreetingSteps.swift | 8 +- Demo/iOS/Source/AppDelegate.swift | 8 +- Demo/iOS/Source/GreetingViewController.swift | 6 +- Demo/iOS/Source/ViewController.swift | 6 +- Rakefile | 108 +++--------------- 12 files changed, 80 insertions(+), 123 deletions(-) create mode 100644 Brewfile create mode 100644 Demo/Demo.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/.travis.yml b/.travis.yml index e1cd6c3..b641c86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ -language: objective-c -osx_image: xcode9.4 +os: osx +osx_image: xcode10.2 install: - - brew update && brew uninstall --force carthage && brew install carthage + - brew bundle - gem install xcpretty -before_script: carthage bootstrap --platform iphoneos +before_script: carthage bootstrap --platform iOS script: rake test:all diff --git a/Brewfile b/Brewfile new file mode 100644 index 0000000..5134701 --- /dev/null +++ b/Brewfile @@ -0,0 +1,2 @@ +# vim: ft=ruby +brew "carthage" diff --git a/Demo/Demo.xcodeproj/project.pbxproj b/Demo/Demo.xcodeproj/project.pbxproj index 2b26360..b717a37 100644 --- a/Demo/Demo.xcodeproj/project.pbxproj +++ b/Demo/Demo.xcodeproj/project.pbxproj @@ -228,7 +228,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0710; - LastUpgradeCheck = 0710; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "Adam Sharp"; TargetAttributes = { CE81C84A1BF28C7000DD6AF9 = { @@ -244,7 +244,7 @@ }; buildConfigurationList = CE81C8461BF28C7000DD6AF9 /* Build configuration list for PBXProject "Demo" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( en, @@ -336,17 +336,28 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -383,17 +394,28 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -415,6 +437,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "$(ORGANISATION_IDENTIFIER).$(PRODUCT_NAME)"; PROJECT_NAME = Demo; SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; VALIDATE_PRODUCT = YES; }; name = Release; @@ -426,7 +449,7 @@ INFOPLIST_FILE = "$(SRCROOT)/iOS/Source/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(PROJECT_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Debug; }; @@ -437,7 +460,7 @@ INFOPLIST_FILE = "$(SRCROOT)/iOS/Source/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_NAME = "$(PROJECT_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; }; name = Release; }; @@ -451,7 +474,7 @@ INFOPLIST_FILE = iOS/Features/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(PROJECT_NAME)Features"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = "Demo-iOS"; USES_XCTRUNNER = YES; }; @@ -467,7 +490,7 @@ INFOPLIST_FILE = iOS/Features/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_NAME = "$(PROJECT_NAME)Features"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 5.0; TEST_TARGET_NAME = "Demo-iOS"; USES_XCTRUNNER = YES; }; diff --git a/Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo-iOS.xcscheme b/Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo-iOS.xcscheme index a868af8..be61d13 100644 --- a/Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo-iOS.xcscheme +++ b/Demo/Demo.xcodeproj/xcshareddata/xcschemes/Demo-iOS.xcscheme @@ -1,6 +1,6 @@ + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Demo/iOS/Features/GreetingFeature.swift b/Demo/iOS/Features/GreetingFeature.swift index 4b9221a..c11f96d 100644 --- a/Demo/iOS/Features/GreetingFeature.swift +++ b/Demo/iOS/Features/GreetingFeature.swift @@ -1,5 +1,7 @@ // Copyright © 2015 Adam Sharp. All rights reserved. +import Scenarios + final class GreetingFeature: Feature { override func scenarios() { @@ -18,5 +20,3 @@ final class GreetingFeature: Feature { } } - -import Scenarios diff --git a/Demo/iOS/Features/Steps/AppSteps.swift b/Demo/iOS/Features/Steps/AppSteps.swift index 3c838e1..2351311 100644 --- a/Demo/iOS/Features/Steps/AppSteps.swift +++ b/Demo/iOS/Features/Steps/AppSteps.swift @@ -1,5 +1,9 @@ // Copyright © 2015 Adam Sharp. All rights reserved. +import Nimble +import Scenarios +import XCTest + final class AppSteps: StepDefinition { override func steps() { @@ -9,7 +13,3 @@ final class AppSteps: StepDefinition { } } - -import Scenarios -import Nimble -import XCTest diff --git a/Demo/iOS/Features/Steps/GreetingSteps.swift b/Demo/iOS/Features/Steps/GreetingSteps.swift index e77c6ae..0d01c72 100644 --- a/Demo/iOS/Features/Steps/GreetingSteps.swift +++ b/Demo/iOS/Features/Steps/GreetingSteps.swift @@ -1,5 +1,9 @@ // Copyright © 2015 Adam Sharp. All rights reserved. +import Nimble +import Scenarios +import XCTest + final class GreetingSteps: StepDefinition { override func steps() { @@ -29,7 +33,3 @@ final class GreetingSteps: StepDefinition { } } - -import Scenarios -import Nimble -import XCTest diff --git a/Demo/iOS/Source/AppDelegate.swift b/Demo/iOS/Source/AppDelegate.swift index 8fbe628..a37ffaf 100644 --- a/Demo/iOS/Source/AppDelegate.swift +++ b/Demo/iOS/Source/AppDelegate.swift @@ -1,10 +1,8 @@ // Copyright © 2015 Adam Sharp. All rights reserved. -@UIApplicationMain -class AppDelegate: UIResponder, UIApplicationDelegate { +import UIKit +@UIApplicationMain +final class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - } - -import UIKit diff --git a/Demo/iOS/Source/GreetingViewController.swift b/Demo/iOS/Source/GreetingViewController.swift index c95575a..b11bd58 100644 --- a/Demo/iOS/Source/GreetingViewController.swift +++ b/Demo/iOS/Source/GreetingViewController.swift @@ -1,7 +1,8 @@ // Copyright © 2015 Adam Sharp. All rights reserved. -final class GreetingViewController: UIViewController { +import UIKit +final class GreetingViewController: UIViewController { @IBOutlet var greetingLabel: UILabel! var subject: String? @@ -14,7 +15,4 @@ final class GreetingViewController: UIViewController { super.viewDidLoad() greetingLabel.text = greeting } - } - -import UIKit diff --git a/Demo/iOS/Source/ViewController.swift b/Demo/iOS/Source/ViewController.swift index c4692cc..90d3e9e 100644 --- a/Demo/iOS/Source/ViewController.swift +++ b/Demo/iOS/Source/ViewController.swift @@ -1,7 +1,8 @@ // Copyright © 2015 Adam Sharp. All rights reserved. -class ViewController: UIViewController { +import UIKit +class ViewController: UIViewController { @IBOutlet var nameField: UITextField! override func prepare(for segue: UIStoryboardSegue, sender: Any?) { @@ -12,7 +13,4 @@ class ViewController: UIViewController { break } } - } - -import UIKit diff --git a/Rakefile b/Rakefile index 02923cf..c42a67c 100644 --- a/Rakefile +++ b/Rakefile @@ -1,116 +1,46 @@ -include Rake::DSL +DESTINATION = "platform=iOS Simulator,name=iPhone X" +SCHEME = "Scenarios-iOS" -SUPPORTED_PLATFORMS = "iphoneos" -CARTHAGE_PLATFORMS = {'platform' => "#{SUPPORTED_PLATFORMS}"} -SWIFT_3_1_TOOLCHAIN = {'toolchain' => 'com.apple.dt.toolchain.Swift_3_1'} +def xcpretty(cmd) + sh "#{cmd} | xcpretty -c; exit ${PIPESTATUS[0]}" +end -SCHEME = "Scenarios-iOS" -DESTINATION = "platform=iOS Simulator,name=iPhone 6s" +task :default => :test desc "Setup Scenarios for development" task :setup do - CarthageTask::Bootstrap.execute + sh "carthage bootstrap --platform iOS" end -namespace :test do +desc "Run the specs & UI tests" +task :test => ["test:specs", "test:demo"] + +desc "Cleans the Scenarios development workspace" +task :clean do + xcpretty "xcodebuild clean -scheme Scenarios-iOS -destination '#{DESTINATION}'" +end +namespace :test do desc "Attempts to build Scenarios and its dependencies" task :build do - CarthageTask::Build.execute + sh "carthage build --no-skip-current --platform iOS" end desc "Runs the unit tests for Scenarios" task :specs do - sh "xcodebuild test -configuration Release -scheme #{SCHEME} -destination '#{DESTINATION}' | xcpretty -c; exit ${PIPESTATUS[0]}" + xcpretty "xcodebuild test -scheme Scenarios-iOS -destination '#{DESTINATION}'" end desc "Runs the unit tests for Scenarios via swiftpm" task :package do - sh "env SCENARIOS_SWIFTPM_TEST=true swift test" + sh "swift test" end desc "Runs the UI tests / demo for Scenarios" task :demo do - sh "xcodebuild test -configuration Release -workspace Demo/Demo.xcworkspace -scheme Demo-iOS -destination '#{DESTINATION}' | xcpretty -c; exit ${PIPESTATUS[0]}" + xcpretty "xcodebuild test -workspace Demo/Demo.xcworkspace -scheme Demo-iOS -destination '#{DESTINATION}'" end desc "Run all tests" task :all => ["test:package", "test:specs", "test:demo"] - -end - -desc "Run the specs & UI tests" -task :test => ["test:specs", "test:demo"] - -desc "Cleans the Scenarios development workspace" -task :clean do - sh "xcodebuild clean -configuration Release -scheme #{SCHEME} -destination '#{DESTINATION}' | xcpretty -c; exit ${PIPESTATUS[0]}" -end - -task :default => :test - -# Utility - -class Array - def includeAny? (arrayOfElements) - raise "'#{arrayOfElements}' is not an `Array`" unless arrayOfElements.is_a? Array - arrayOfElements.each { |element| return true if self.include? element } - return false - end - - def appendUnique (element) - self << element unless self.include? element - end -end - -class Task - @command - - def initialize (task, arguments) - @task = task - @arguments = arguments - end - - def execute - self.executeWith @arguments - end - - def executeWith (arguments) - function = @command - function += " #{@task}" - arguments.each { |element| - if element.is_a? Hash - element.each { |flag, value| - function += " --#{flag}" - function += " #{value}" unless value.nil? - } - else - function += " --#{element}" - end - } - system exec function - end -end - -class CarthageTask < Task - def initialize (task, arguments) - super(task, arguments) - @command = 'carthage' - end - - def execute - arguments = @arguments - arguments.appendUnique SWIFT_3_1_TOOLCHAIN if canUseSwift2_3? - super.executeWith arguments - end - - Bootstrap = CarthageTask.new 'bootstrap', ['no-use-binaries', CARTHAGE_PLATFORMS] - Build = CarthageTask.new 'build', ['no-skip-current', CARTHAGE_PLATFORMS] -end - -def canUseSwift2_3? - `xcodebuild -version | grep 'Xcode 8'` - .split - .map { |text| text.to_f } - .includeAny? [8.0, 8.1, 8.2] end From 5f71c1670f852a3653f13fea9de80d5452bc91b0 Mon Sep 17 00:00:00 2001 From: Adam Sharp Date: Sat, 25 May 2019 16:10:30 -0400 Subject: [PATCH 5/5] Declare Scenarios library as a swiftpm product --- Package.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Package.swift b/Package.swift index 7e622d2..086b419 100644 --- a/Package.swift +++ b/Package.swift @@ -4,6 +4,9 @@ import PackageDescription let package = Package( name: "Scenarios", + products: [ + .library(name: "Scenarios", targets: ["Scenarios"]), + ], dependencies: [ .package(url: "https://github.com/sharplet/Regex.git", from: "2.0.0"), .package(url: "https://github.com/Quick/Quick.git", from: "2.0.0"),