Skip to content

Commit

Permalink
Migrated to swift 5 + resolved public modifier is redundant for insta…
Browse files Browse the repository at this point in the history
…nce method declared in a public extension
  • Loading branch information
Stefan Renne authored and bartoszj committed May 8, 2019
1 parent b02c5e2 commit 8367c7a
Show file tree
Hide file tree
Showing 25 changed files with 87 additions and 83 deletions.
2 changes: 1 addition & 1 deletion .swift-version
@@ -1 +1 @@
4.2
5.0
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,5 +1,5 @@
language: objective-c
osx_image: xcode10
osx_image: xcode10.2

env:
global:
Expand Down
19 changes: 11 additions & 8 deletions AutoMate.xcodeproj/project.pbxproj
Expand Up @@ -470,26 +470,27 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = "PGS Software";
TargetAttributes = {
E425D55C1CED928100A7CA03 = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
E4EE41C01CFD7246004F0FFE = {
CreatedOnToolsVersion = 7.3.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
};
};
};
buildConfigurationList = E425D5571CED928100A7CA03 /* Build configuration list for PBXProject "AutoMate" */;
compatibilityVersion = "Xcode 3.2";
developmentRegion = English;
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
en,
Base,
);
mainGroup = E425D5531CED928100A7CA03;
productRefGroup = E425D55E1CED928100A7CA03 /* Products */;
Expand Down Expand Up @@ -649,6 +650,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -710,6 +712,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -782,7 +785,7 @@
PRODUCT_NAME = AutoMate;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -806,7 +809,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.pgs-soft.AutoMate";
PRODUCT_NAME = AutoMate;
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand All @@ -817,7 +820,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.pgs-soft.AutoMateTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -828,7 +831,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.pgs-soft.AutoMateTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
6 changes: 3 additions & 3 deletions AutoMate/AutoMateLaunchEnvironments.swift
Expand Up @@ -22,15 +22,15 @@ public extension AutoMateLaunchEnvironment where Self: LaunchEnvironmentWithMult

// MARK: Properties
/// Implementation overriding `uniqueIdentifier` property from `LaunchOption` protocol to use `rawValue` of `AutoMateKey`.
public var uniqueIdentifier: String {
var uniqueIdentifier: String {
return Self.key.rawValue
}

// MARK: Initialization
/// Intializes `AutoMateLaunchEnvironment` with tuples describing `LaunchEnvironmentResourceValue`.
///
/// - Parameter resources: `(String, String?)` tuples describing `LaunchEnvironmentResourceValue`
public init(resources: (fileName: String, bundleName: String?)...) {
init(resources: (fileName: String, bundleName: String?)...) {
self.init(valuesCollection: resources.map(Value.init))
}
}
Expand All @@ -40,7 +40,7 @@ public extension AutoMateLaunchEnvironment where Self: LaunchEnvironmentWithSing

// MARK: Properties
/// Implementation of `key` property from `LaunchEnvironmentWithSingleValue` protocol to use `rawValue` of `AutoMateKey`.
public var key: String {
var key: String {
return Self.key.rawValue
}
}
Expand Down
2 changes: 1 addition & 1 deletion AutoMate/Foundation extensions/Sequence.swift
Expand Up @@ -13,7 +13,7 @@ public extension Sequence where Iterator.Element: Hashable {
/// Returns an array with unique elements preserving an order of elements.
///
/// - Returns: Unique elements.
public func unique() -> [Iterator.Element] {
func unique() -> [Iterator.Element] {
var buffer: [Iterator.Element] = []
var added = Set<Iterator.Element>()
for element in self {
Expand Down
4 changes: 2 additions & 2 deletions AutoMate/LaunchArgumentProtocols.swift
Expand Up @@ -30,14 +30,14 @@ public protocol LaunchArgument: LaunchOption {
public extension LaunchArgument {

/// Unique value to use when comparing with other launch options.
public var uniqueIdentifier: String {
var uniqueIdentifier: String {
return key
}

/// Launch environment variables provided by this option.
///
/// Launch argument does not have to provide launch environments.
public var launchEnvironments: [String: String]? {
var launchEnvironments: [String: String]? {
return nil
}
}
Expand Down
18 changes: 9 additions & 9 deletions AutoMate/LaunchEnvironmentProtocols.swift
Expand Up @@ -43,7 +43,7 @@ public extension LaunchEnvironmentProtocol {
/// Launch arguments provided by this
///
/// Launch environment does not have to provide launch arguments.
public var launchArguments: [String]? {
var launchArguments: [String]? {
return nil
}
}
Expand Down Expand Up @@ -77,12 +77,12 @@ public protocol LaunchEnvironmentWithSingleValue: LaunchEnvironmentProtocol {
public extension LaunchEnvironmentWithSingleValue {

/// Unique value to use when comparing with other launch options.
public var uniqueIdentifier: String {
var uniqueIdentifier: String {
return key
}

/// Dictionary added to `XCUIApplication` `launchEnviroment`.
public var launchEnvironments: [String: String]? {
var launchEnvironments: [String: String]? {
return [key: value.value]
}
}
Expand All @@ -103,7 +103,7 @@ public extension LaunchEnvironmentWithSingleValue where Self: CleanableLaunchEnv
///
/// ```swift
/// ["LAUNCH_KEY": "AM_CLEAN_DATA_FLAG,PGS_WITH_LOVE"]
public var launchEnvironments: [String: String]? {
var launchEnvironments: [String: String]? {
return shouldCleanBefore ? [key: "\(type(of: self).CleanFlag),\(value.value)"] : [key: value.value]
}
}
Expand Down Expand Up @@ -178,7 +178,7 @@ public extension LaunchEnvironmentWithMultipleValues where Self: CleanableLaunch
///
/// ```swift
/// ["CleanableArrayLaunchEnvironment": "AM_CLEAN_DATA_FLAG,PGS_WITH_LOVE,PGS_WITH_LOVE"]
public var launchEnvironments: [String: String]? {
var launchEnvironments: [String: String]? {
return shouldCleanBefore ? [uniqueIdentifier: "\(type(of: self).CleanFlag),\(valuesCollection.launchEnvironment)"] : [uniqueIdentifier: valuesCollection.launchEnvironment]
}
}
Expand Down Expand Up @@ -210,7 +210,7 @@ public protocol CleanableLaunchEnvironment: LaunchEnvironmentProtocol {
public extension CleanableLaunchEnvironment {

/// Flag which is inserted at the beginning of launch enviroment value if `shouldCleanBefore` is set to true.
public static var CleanFlag: String {
static var CleanFlag: String {
return "AM_CLEAN_DATA_FLAG"
}
}
Expand Down Expand Up @@ -255,12 +255,12 @@ public extension CleanableLaunchEnvironmentWithMultipleValues {

// MARK: Initialization
/// Calls `init(shouldCleanBefore: Bool, valuesCollection: [Value])` with before clean turned off.
public init(valuesCollection: [Value]) {
init(valuesCollection: [Value]) {
self.init(shouldCleanBefore: false, valuesCollection: valuesCollection)
}

/// Calls `init(shouldCleanBefore: Bool, valuesCollection: [Value])` with before clean turned off.
public init(arrayLiteral elements: Value...) {
init(arrayLiteral elements: Value...) {
self.init(shouldCleanBefore: false, valuesCollection: elements)
}
}
Expand All @@ -271,7 +271,7 @@ public extension CleanableLaunchEnvironmentWithMultipleValues where Self.Value =

// MARK: Initialization
/// Calls `init(shouldCleanBefore: Bool, valuesCollection: [Value])` with before clean turned off.
public init(shouldCleanBefore: Bool, resources: (fileName: String, bundleName: String?)...) {
init(shouldCleanBefore: Bool, resources: (fileName: String, bundleName: String?)...) {
self.init(shouldCleanBefore: shouldCleanBefore, valuesCollection: resources.map(Value.init))
}
}
2 changes: 1 addition & 1 deletion AutoMate/LaunchOptionProtocol.swift
Expand Up @@ -29,7 +29,7 @@ public protocol LaunchOption {
public extension LaunchOption {

/// Unique value to use when comparing with other launch options.
public var uniqueIdentifier: String {
var uniqueIdentifier: String {
return "\(type(of: self))"
}
}
4 changes: 2 additions & 2 deletions AutoMate/LaunchOptionsSet.swift
Expand Up @@ -82,7 +82,7 @@ extension LaunchOptionsSet: SetAlgebra {
- returns: Removed element (or nil if it didn't exist).
*/
public mutating func remove(_ member: LaunchOption) -> LaunchOption? {
guard let index = options.index(where: { member.uniqueIdentifier == $0.uniqueIdentifier }) else { return nil }
guard let index = options.firstIndex(where: { member.uniqueIdentifier == $0.uniqueIdentifier }) else { return nil }
return options.remove(at: index)
}

Expand Down Expand Up @@ -148,7 +148,7 @@ extension LaunchOptionsSet {
- returns: Matching elements or nil if it doesn't exists in set.
*/
fileprivate func contains(andReturns member: LaunchOption) -> LaunchOption? {
guard let index = options.index(where: { $0.uniqueIdentifier == member.uniqueIdentifier }) else {
guard let index = options.firstIndex(where: { $0.uniqueIdentifier == member.uniqueIdentifier }) else {
return nil
}
return options[index]
Expand Down
2 changes: 1 addition & 1 deletion AutoMate/Locator.swift
Expand Up @@ -32,7 +32,7 @@ public protocol Locator {
public extension Locator where Self: RawRepresentable, Self.RawValue == String {

/// Element identifier.
public var identifier: String {
var identifier: String {
return rawValue
}
}
2 changes: 1 addition & 1 deletion AutoMate/PageObjects/HealthPermissionPage.swift
Expand Up @@ -55,7 +55,7 @@ public extension HealthPermissionPage {
/// Locators used in the HealthKit permission view.
///
/// - `healthAccess`: Navigation bar identifier.
public enum Locators: String, Locator {
enum Locators: String, Locator {
/// Navigation bar identifier.
case healthAccess = "Health Access"
}
Expand Down
4 changes: 2 additions & 2 deletions AutoMate/PageObjects/ModalPage.swift
Expand Up @@ -45,14 +45,14 @@ public extension ModalPage {
///
/// - note:
/// The button with "close" as `accessibilityIdentifier` is used.
public var closeButton: XCUIElement {
var closeButton: XCUIElement {
return view.buttons[Locators.closeModalButton]
}

// MARK: Actions
/// Close modal view by tapping on `closeButton` button.
#if !os(tvOS)
public func closeModalPage() {
func closeModalPage() {
#if os(iOS)
closeButton.tap()
#elseif os(macOS)
Expand Down
4 changes: 2 additions & 2 deletions AutoMate/PageObjects/PushedPage.swift
Expand Up @@ -45,14 +45,14 @@ public extension PushedPage {
///
/// - note:
/// The button with "back" as `accessibilityIdentifier` is used.
public var backButton: XCUIElement {
var backButton: XCUIElement {
return view.navigationBars.buttons.firstMatch
}

// MARK: Actions
/// Pop view by tapping on `backButton` button.
#if !os(tvOS)
public func goBack() {
func goBack() {
#if os(iOS)
backButton.tap()
#elseif os(macOS)
Expand Down
4 changes: 2 additions & 2 deletions AutoMate/XCTest extensions/XCTestCase+Identifiable.swift
Expand Up @@ -51,7 +51,7 @@ public extension XCTestCase {
/// - timeout: Waiting time (default: 10 seconds).
/// - file: Current source file.
/// - line: Current source line.
public func wait<T: IdentifiableByElement>(forExistanceOf element: T, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
func wait<T: IdentifiableByElement>(forExistanceOf element: T, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
wait(forExistanceOf: element.identifingElement, timeout: timeout, file: file, line: line)
}

Expand All @@ -69,7 +69,7 @@ public extension XCTestCase {
/// - timeout: Waiting time (default: 10 seconds).
/// - file: Current source file.
/// - line: Current source line.
public func wait<T: IdentifiableByElement>(forVisibilityOf element: T, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
func wait<T: IdentifiableByElement>(forVisibilityOf element: T, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
wait(forVisibilityOf: element.identifingElement, timeout: timeout, file: file, line: line)
}
}
8 changes: 4 additions & 4 deletions AutoMate/XCTest extensions/XCTestCase.swift
Expand Up @@ -34,7 +34,7 @@ public extension XCTestCase {
/// - timeout: Waiting time in seconds (default: 10 seconds).
/// - file: Current source file.
/// - line: Current source line.
public func wait(forFulfillmentOf predicate: NSPredicate,
func wait(forFulfillmentOf predicate: NSPredicate,
for element: XCUIElement,
withFailingMessage message: String = "Failed to fulfill predicate %@ for %@ within %.2f seconds.",
timeout: TimeInterval = XCTestCase.defaultTimeOut,
Expand Down Expand Up @@ -67,7 +67,7 @@ public extension XCTestCase {
/// - timeout: Waiting time in seconds (default: 10 seconds).
/// - file: Current source file.
/// - line: Current source line.
public func wait(forExistanceOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
func wait(forExistanceOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
let existancePredicate = NSPredicate(format: "exists == true")
wait(forFulfillmentOf: existancePredicate, for: element, withFailingMessage: "Failed to find %2$@ within %3$.2f seconds. Predicate was: %1$@.", timeout: timeout, file: file, line: line)
}
Expand All @@ -86,7 +86,7 @@ public extension XCTestCase {
/// - timeout: Waiting time in seconds (default: 10 seconds).
/// - file: Current source file.
/// - line: Current source line.
public func wait(forVisibilityOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
func wait(forVisibilityOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
let visibilityPredicate = NSPredicate(format: "exists == true && hittable == true")
wait(forFulfillmentOf: visibilityPredicate, for: element, withFailingMessage: "Failed to find %2$@ as visible within %3$.2f seconds. Predicate was: %1$@.", timeout: timeout, file: file, line: line)
}
Expand All @@ -105,7 +105,7 @@ public extension XCTestCase {
/// - timeout: Waiting time in seconds (default: 10 seconds).
/// - file: Current source file.
/// - line: Current source line.
public func wait(forInvisibilityOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
func wait(forInvisibilityOf element: XCUIElement, timeout: TimeInterval = XCTestCase.defaultTimeOut, file: StaticString = #file, line: UInt = #line) {
let invisibilityPredicate = NSPredicate(format: "hittable == false")
wait(forFulfillmentOf: invisibilityPredicate, for: element, withFailingMessage: "Failed to find %2$@ as invisible within %3$.2f seconds. Predicate was: %1$@.", timeout: timeout, file: file, line: line)
}
Expand Down

0 comments on commit 8367c7a

Please sign in to comment.