Skip to content

Commit

Permalink
Merge pull request #115 from macacajs/migrate-swift4
Browse files Browse the repository at this point in the history
Migrate swift4
  • Loading branch information
SamuelZhaoY authored Mar 8, 2018
2 parents 60ed7d1 + 02de743 commit 36293c0
Show file tree
Hide file tree
Showing 17 changed files with 128 additions and 72 deletions.
1 change: 1 addition & 0 deletions Cartfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ github "glock45/swifter" == 1.3.3
github "SwiftyJSON/SwiftyJSON"
github "cezheng/Fuzi" ~> 1.0.0
github "tadija/AEXML"
github "CocoaLumberjack/CocoaLumberjack"
65 changes: 52 additions & 13 deletions XCTestWD/XCTestWD.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
63D4083C1EAB62D500198736 /* Swifter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 63D4083B1EAB62D500198736 /* Swifter.framework */; };
63D408671EAB62EB00198736 /* XCTestWDRunner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 63D408551EAB62EB00198736 /* XCTestWDRunner.swift */; };
7F36D5351EADC18300C83CF0 /* SwiftyJSON.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F4F31341EACECD900F8D82C /* SwiftyJSON.framework */; };
7F536465204C35BB0041990F /* CocoaLumberjackSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F536464204C35BB0041990F /* CocoaLumberjackSwift.framework */; };
7F8D629B203E57CD00D92323 /* XCTestWD.h in Headers */ = {isa = PBXBuildFile; fileRef = 7F8D6299203E57CD00D92323 /* XCTestWD.h */; settings = {ATTRIBUTES = (Public, ); }; };
7F8D629E203E57CD00D92323 /* XCTestWD.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F8D6297203E57CD00D92323 /* XCTestWD.framework */; };
7F8D629F203E57CD00D92323 /* XCTestWD.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 7F8D6297203E57CD00D92323 /* XCTestWD.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand Down Expand Up @@ -94,14 +95,14 @@
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
7F8D629C203E57CD00D92323 /* PBXContainerItemProxy */ = {
7F53645D204C2DA20041990F /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 63D4080F1EAB629400198736 /* Project object */;
proxyType = 1;
remoteGlobalIDString = 7F8D6296203E57CD00D92323;
remoteInfo = XCTestWD;
};
7F8D6329203E75F100D92323 /* PBXContainerItemProxy */ = {
7F8D629C203E57CD00D92323 /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 63D4080F1EAB629400198736 /* Project object */;
proxyType = 1;
Expand Down Expand Up @@ -140,6 +141,9 @@
7F2B01DA203BDEF500B07F50 /* Fuzi.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Fuzi.framework; path = ../Carthage/Build/iOS/Fuzi.framework; sourceTree = "<group>"; };
7F2B01DB203BDEF500B07F50 /* AEXML.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AEXML.framework; path = ../Carthage/Build/iOS/AEXML.framework; sourceTree = "<group>"; };
7F4F31341EACECD900F8D82C /* SwiftyJSON.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SwiftyJSON.framework; path = ../Carthage/Build/iOS/SwiftyJSON.framework; sourceTree = "<group>"; };
7F53645B204C2D5B0041990F /* XCTestWD.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTestWD.framework; path = Frameworks/XCTestWD.framework; sourceTree = "<group>"; };
7F536461204C35350041990F /* XCTestWD.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = XCTestWD.xcodeproj; sourceTree = "<group>"; };
7F536464204C35BB0041990F /* CocoaLumberjackSwift.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CocoaLumberjackSwift.framework; path = ../Carthage/Build/iOS/CocoaLumberjackSwift.framework; sourceTree = "<group>"; };
7F5D35D1203C470800BCC922 /* XCElementSnapshot.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XCElementSnapshot.h; path = XCTestWD/PrivateHeaders/XCElementSnapshot.h; sourceTree = SOURCE_ROOT; };
7F5D35D2203C470800BCC922 /* XCTestPrivateSymbols.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = XCTestPrivateSymbols.m; path = XCTestWD/PrivateHeaders/XCTestPrivateSymbols.m; sourceTree = SOURCE_ROOT; };
7F5D35D3203C470800BCC922 /* XCRuntimeUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = XCRuntimeUtils.h; path = XCTestWD/PrivateHeaders/XCRuntimeUtils.h; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -224,6 +228,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7F536465204C35BB0041990F /* CocoaLumberjackSwift.framework in Frameworks */,
7F8D62DD203E59EE00D92323 /* libxml2.tbd in Frameworks */,
7F8D62DE203E5A1300D92323 /* AEXML.framework in Frameworks */,
7F8D62DF203E5A1300D92323 /* Fuzi.framework in Frameworks */,
Expand Down Expand Up @@ -282,6 +287,9 @@
63D4083A1EAB62D500198736 /* Frameworks */ = {
isa = PBXGroup;
children = (
7F536464204C35BB0041990F /* CocoaLumberjackSwift.framework */,
7F536461204C35350041990F /* XCTestWD.xcodeproj */,
7F53645B204C2D5B0041990F /* XCTestWD.framework */,
7F5D363D203C4AD000BCC922 /* XCTestWDModule.framework */,
7F5D3640203DB5E300BCC922 /* XCTestWDModule.framework */,
7F2B01DB203BDEF500B07F50 /* AEXML.framework */,
Expand All @@ -295,6 +303,11 @@
name = Frameworks;
sourceTree = "<group>";
};
7F536462204C35350041990F /* Products */ = {
isa = PBXGroup;
name = Products;
sourceTree = "<group>";
};
7F8D6298203E57CD00D92323 /* XCTestWD */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -484,7 +497,7 @@
buildRules = (
);
dependencies = (
7F8D632A203E75F100D92323 /* PBXTargetDependency */,
7F53645E204C2DA20041990F /* PBXTargetDependency */,
);
name = XCTestWDUITests;
productName = XCTestWDUITests;
Expand Down Expand Up @@ -518,7 +531,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 0830;
LastUpgradeCheck = 0920;
ORGANIZATIONNAME = XCTestWD;
TargetAttributes = {
63D408161EAB629400198736 = {
Expand All @@ -527,7 +540,7 @@
};
63D4082A1EAB629400198736 = {
CreatedOnToolsVersion = 8.3.1;
LastSwiftMigration = 0820;
LastSwiftMigration = 0910;
ProvisioningStyle = Manual;
};
7F2B0207203C265F00B07F50 = {
Expand All @@ -536,6 +549,7 @@
};
7F8D6296203E57CD00D92323 = {
CreatedOnToolsVersion = 9.1;
LastSwiftMigration = 0910;
ProvisioningStyle = Automatic;
};
};
Expand All @@ -551,6 +565,12 @@
mainGroup = 63D4080E1EAB629400198736;
productRefGroup = 63D408181EAB629400198736 /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = 7F536462204C35350041990F /* Products */;
ProjectRef = 7F536461204C35350041990F /* XCTestWD.xcodeproj */;
},
);
projectRoot = "";
targets = (
63D408161EAB629400198736 /* XCTestWDDemo */,
Expand Down Expand Up @@ -657,6 +677,7 @@
"$(SRCROOT)/../Carthage/Build/iOS/AEXML.framework",
"$(SRCROOT)/../Carthage/Build/iOS/Fuzi.framework",
"$(SRCROOT)/../Carthage/Build/iOS/SwiftyJSON.framework",
"$(SRCROOT)/../Carthage/Build/iOS/CocoaLumberjackSwift.framework",
);
outputPaths = (
);
Expand Down Expand Up @@ -752,15 +773,15 @@
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
7F8D629D203E57CD00D92323 /* PBXTargetDependency */ = {
7F53645E204C2DA20041990F /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 7F8D6296203E57CD00D92323 /* XCTestWD */;
targetProxy = 7F8D629C203E57CD00D92323 /* PBXContainerItemProxy */;
targetProxy = 7F53645D204C2DA20041990F /* PBXContainerItemProxy */;
};
7F8D632A203E75F100D92323 /* PBXTargetDependency */ = {
7F8D629D203E57CD00D92323 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 7F8D6296203E57CD00D92323 /* XCTestWD */;
targetProxy = 7F8D6329203E75F100D92323 /* PBXContainerItemProxy */;
targetProxy = 7F8D629C203E57CD00D92323 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

Expand Down Expand Up @@ -794,15 +815,21 @@
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_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
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_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;
Expand Down Expand Up @@ -847,15 +874,21 @@
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_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
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_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;
Expand Down Expand Up @@ -950,7 +983,8 @@
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
XCTESTWD_PORT = 8001;
};
name = Debug;
Expand Down Expand Up @@ -981,7 +1015,8 @@
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE = "";
PROVISIONING_PROFILE_SPECIFIER = "";
SWIFT_VERSION = 3.0;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
XCTESTWD_PORT = 8001;
};
name = Release;
Expand Down Expand Up @@ -1015,6 +1050,7 @@
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
Expand All @@ -1041,7 +1077,8 @@
PRODUCT_BUNDLE_IDENTIFIER = XCTestWD.Test.XCTestWD;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.2;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand All @@ -1062,6 +1099,7 @@
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
Expand All @@ -1088,7 +1126,8 @@
PRODUCT_BUNDLE_IDENTIFIER = XCTestWD.Test.XCTestWD;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 3.2;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
TARGETED_DEVICE_FAMILY = "1,2";
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0910"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
4 changes: 2 additions & 2 deletions XCTestWD/XCTestWD/PrivateHeaders/XCTestPrivateSymbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ extern NSNumber *XCAXAIsVisibleAttribute;
extern NSNumber *XCAXAIsElementAttribute;

/*! Getter for XCTest logger */
extern id<XCDebugLogDelegate> (*XCDebugLogger)();
extern id<XCDebugLogDelegate> (*XCDebugLogger)(void);

/*! Setter for XCTest logger */
extern void (*XCSetDebugLogger)(id <XCDebugLogDelegate>);
Expand All @@ -34,4 +34,4 @@ void *RetrieveXCTestSymbol(const char *name);
/*! Static constructor that will retrieve XCTest private symbols */
__attribute__((constructor)) void LoadXCTestSymbols(void);

int portNumber();
int portNumber(void);
2 changes: 1 addition & 1 deletion XCTestWD/XCTestWD/PrivateHeaders/XCTestPrivateSymbols.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
NSNumber *XCAXAIsElementAttribute;

void (*XCSetDebugLogger)(id <XCDebugLogDelegate>);
id<XCDebugLogDelegate> (*XCDebugLogger)();
id<XCDebugLogDelegate> (*XCDebugLogger)(void);

__attribute__((constructor)) void LoadXCTestSymbols(void)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import Swifter
import SwiftyJSON
import XCTest

internal class XCTestWDElementController: Controller {

Expand Down Expand Up @@ -117,12 +118,12 @@ internal class XCTestWDElementController: Controller {
return XCTestWDResponse.response(session: nil, error: WDStatus.NoSuchElement)
}

if element?.elementType == XCUIElementType.pickerWheel {
if element?.elementType == XCUIElement.ElementType.picker {
element?.adjust(toPickerWheelValue: value!)
return XCTestWDResponse.response(session: nil, error: WDStatus.Success)
}

if element?.elementType == XCUIElementType.slider {
if element?.elementType == XCUIElement.ElementType.slider {
element?.adjust(toNormalizedSliderPosition: CGFloat((value! as NSString).floatValue))
return XCTestWDResponse.response(session: nil, error: WDStatus.Success)
}
Expand Down Expand Up @@ -196,7 +197,9 @@ internal class XCTestWDElementController: Controller {
}

if element?.hasKeyboardFocus == true {
element?.typeText((element?.value as? String ?? "").characters.map { _ in XCUIKeyboardKeyDelete }.joined(separator: ""))
let content:String = element?.value as? String ?? ""

element?.typeText(String(describing: Array(content).map { _ in XCUIKeyboardKey.delete }))
dismissKeyboard()
return XCTestWDResponse.response(session: nil, error: WDStatus.Success)
} else {
Expand Down Expand Up @@ -435,7 +438,7 @@ internal class XCTestWDElementController: Controller {

internal static func homeScreen(request: Swifter.HttpRequest) -> Swifter.HttpResponse {

XCUIDevice.shared().press(XCUIDeviceButton.home)
XCUIDevice.shared.press(XCUIDevice.Button.home)
sleep(3);
return XCTestWDResponse.response(session: nil, error: WDStatus.Success)
}
Expand All @@ -445,14 +448,14 @@ internal class XCTestWDElementController: Controller {
let session = XCTestWDSessionManager.singleton.checkDefaultSession()
let application = session.application

let elements = application?.descendants(matching: XCUIElementType.window).allElementsBoundByIndex
let elements = application?.descendants(matching: XCUIElement.ElementType.window).allElementsBoundByIndex

if elements == nil || elements?.count == 0 {
return XCTestWDResponse.response(session: nil, error: WDStatus.ElementNotVisible)
}

let window = elements![0]
let navBar = window.descendants(matching: XCUIElementType.navigationBar).allElementsBoundByIndex.first
let navBar = window.descendants(matching: XCUIElement.ElementType.navigationBar).allElementsBoundByIndex.first
window.resolve()
let digest = window.digest(windowName: navBar?.identifier == nil ? "" : (navBar?.identifier)!)
return XCTestWDResponse.response(session: nil, value: JSON(digest as Any))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class XCTestWDScreenshotController: Controller {
//MARK: Routing Logic Specification
internal static func getScreenshot(request: Swifter.HttpRequest) -> Swifter.HttpResponse {
var base64String:String!
let xcScreen = NSClassFromString("XCUIScreen")
let xcScreen:AnyClass? = NSClassFromString("XCUIScreen")
if xcScreen != nil {
let data = xcScreen?.value(forKeyPath: "mainScreen.screenshot.PNGRepresentation") as? NSData
base64String = ((data?.base64EncodedString()))!
Expand Down
Loading

0 comments on commit 36293c0

Please sign in to comment.