From 877792fa0bc8465241bb6b1eaf0207d36a26f10b Mon Sep 17 00:00:00 2001 From: Leo Natan Date: Sun, 30 Jul 2017 07:56:15 +0300 Subject: [PATCH] Fix Swift crashes due to AppDelegate proxy cast issues. Instead, use ObjC runtime to dynamically subclass the delegate class with own functionality. Closes #165 Add Swift example project for testing. --- detox/ios/Detox.xcodeproj/project.pbxproj | 12 +- .../xcshareddata/xcschemes/Detox.xcscheme | 4 +- .../xcschemes/DetoxFramework.xcscheme | 4 +- detox/ios/Detox/DetoxAppDelegateProxy.h | 3 +- detox/ios/Detox/DetoxAppDelegateProxy.m | 90 ++-- detox/ios/Detox/DetoxManager.m | 2 +- .../SwiftExample.xcodeproj/project.pbxproj | 495 ++++++++++++++++++ .../SwiftExample/AppDelegate.swift | 45 ++ .../AppIcon.appiconset/Contents.json | 93 ++++ .../Base.lproj/LaunchScreen.storyboard | 32 ++ .../SwiftExample/Base.lproj/Main.storyboard | 31 ++ examples/SwiftExample/SwiftExample/Info.plist | 45 ++ .../SwiftExample/ViewController.swift | 25 + 13 files changed, 829 insertions(+), 52 deletions(-) create mode 100644 examples/SwiftExample/SwiftExample.xcodeproj/project.pbxproj create mode 100644 examples/SwiftExample/SwiftExample/AppDelegate.swift create mode 100644 examples/SwiftExample/SwiftExample/Assets.xcassets/AppIcon.appiconset/Contents.json create mode 100644 examples/SwiftExample/SwiftExample/Base.lproj/LaunchScreen.storyboard create mode 100644 examples/SwiftExample/SwiftExample/Base.lproj/Main.storyboard create mode 100644 examples/SwiftExample/SwiftExample/Info.plist create mode 100644 examples/SwiftExample/SwiftExample/ViewController.swift diff --git a/detox/ios/Detox.xcodeproj/project.pbxproj b/detox/ios/Detox.xcodeproj/project.pbxproj index 54d40915fe..86ce88de4b 100644 --- a/detox/ios/Detox.xcodeproj/project.pbxproj +++ b/detox/ios/Detox.xcodeproj/project.pbxproj @@ -479,7 +479,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 0900; ORGANIZATIONNAME = Wix; TargetAttributes = { 3928EFA41E47404900C19B6E = { @@ -729,7 +729,9 @@ 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; @@ -737,7 +739,10 @@ 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_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; @@ -784,7 +789,9 @@ 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; @@ -792,7 +799,10 @@ 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_SUSPICIOUS_MOVE = YES; CLANG_WARN_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; diff --git a/detox/ios/Detox.xcodeproj/xcshareddata/xcschemes/Detox.xcscheme b/detox/ios/Detox.xcodeproj/xcshareddata/xcschemes/Detox.xcscheme index 0ba5d01b5f..465e548ec7 100644 --- a/detox/ios/Detox.xcodeproj/xcshareddata/xcschemes/Detox.xcscheme +++ b/detox/ios/Detox.xcodeproj/xcshareddata/xcschemes/Detox.xcscheme @@ -1,6 +1,6 @@ @@ -56,6 +57,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/detox/ios/Detox.xcodeproj/xcshareddata/xcschemes/DetoxFramework.xcscheme b/detox/ios/Detox.xcodeproj/xcshareddata/xcschemes/DetoxFramework.xcscheme index 1172f27e41..33d1a3b3f0 100644 --- a/detox/ios/Detox.xcodeproj/xcshareddata/xcschemes/DetoxFramework.xcscheme +++ b/detox/ios/Detox.xcodeproj/xcshareddata/xcschemes/DetoxFramework.xcscheme @@ -1,6 +1,6 @@ @@ -36,6 +37,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/detox/ios/Detox/DetoxAppDelegateProxy.h b/detox/ios/Detox/DetoxAppDelegateProxy.h index ffa7b6fe08..4431311f0c 100644 --- a/detox/ios/Detox/DetoxAppDelegateProxy.h +++ b/detox/ios/Detox/DetoxAppDelegateProxy.h @@ -9,9 +9,8 @@ @import Foundation; @import UIKit; -@interface DetoxAppDelegateProxy : NSObject +@interface DetoxAppDelegateProxy : NSObject @property (class, nonatomic, strong, readonly) DetoxAppDelegateProxy* currentAppDelegateProxy; -@property (nonatomic, strong, readonly) id originalAppDelegate; @end diff --git a/detox/ios/Detox/DetoxAppDelegateProxy.m b/detox/ios/Detox/DetoxAppDelegateProxy.m index 67d1e9c54b..45e60a65c5 100644 --- a/detox/ios/Detox/DetoxAppDelegateProxy.m +++ b/detox/ios/Detox/DetoxAppDelegateProxy.m @@ -21,10 +21,6 @@ @interface DetoxAppDelegateProxy () @end @implementation DetoxAppDelegateProxy -{ - NSObject* _originalAppDelegate; - DetoxUserNotificationDispatcher* _notificationDispatcher; -} + (instancetype)currentAppDelegateProxy { @@ -36,44 +32,30 @@ + (void)load Method m = class_getInstanceMethod([UIApplication class], @selector(setDelegate:)); void (*orig)(id, SEL, id) = (void*)method_getImplementation(m); method_setImplementation(m, imp_implementationWithBlock(^ (id _self, id origDelegate) { - _currentAppDelegateProxy = [[DetoxAppDelegateProxy alloc] initWithOriginalAppDelegate:origDelegate]; - orig(_self, @selector(setDelegate:), _currentAppDelegateProxy); + NSString* clsName = [NSString stringWithFormat:@"%@(%@)", NSStringFromClass([origDelegate class]), NSStringFromClass([DetoxAppDelegateProxy class])]; + Class cls = objc_getClass(clsName.UTF8String); + + if(cls == nil) + { + cls = objc_duplicateClass([DetoxAppDelegateProxy class], clsName.UTF8String, 0); +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated" + class_setSuperclass(cls, origDelegate.class); +#pragma clang diagnostic pop + } + + object_setClass(origDelegate, cls); + + _currentAppDelegateProxy = origDelegate; + orig(_self, @selector(setDelegate:), origDelegate); + + [[NSNotificationCenter defaultCenter] addObserver:origDelegate selector:@selector(__dtx_applicationDidLaunchNotification:) name:UIApplicationDidFinishLaunchingNotification object:nil]; })); } -- (instancetype)initWithOriginalAppDelegate:(id)originalAppDelegate -{ - _originalAppDelegate = originalAppDelegate; - - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_applicationDidLaunchNotification:) name:UIApplicationDidFinishLaunchingNotification object:nil]; - - return self; -} - -- (id)originalAppDelegate -{ - return _originalAppDelegate; -} - -- (void)_applicationDidLaunchNotification:(NSNotification*)notification -{ - [self.userNotificationDispatcher dispatchOnAppDelegate:_originalAppDelegate simulateDuringLaunch:YES]; -} - -- (BOOL)respondsToSelector:(SEL)aSelector +- (void)__dtx_applicationDidLaunchNotification:(NSNotification*)notification { - return [_originalAppDelegate respondsToSelector:aSelector]; -} - -- (NSMethodSignature *)methodSignatureForSelector:(SEL)sel -{ - NSMethodSignature* ms = [super methodSignatureForSelector:sel]; - return ms ?: [_originalAppDelegate methodSignatureForSelector:sel]; -} - -- (void)forwardInvocation:(NSInvocation *)invocation -{ - [invocation invokeWithTarget:_originalAppDelegate]; + [self.userNotificationDispatcher dispatchOnAppDelegate:self simulateDuringLaunch:YES]; } - (NSURL*)_userNotificationDataURL @@ -125,31 +107,47 @@ - (NSDictionary*)_prepareLaunchOptions:(NSDictionary*)launchOptions userNotifica - (DetoxUserNotificationDispatcher*)userNotificationDispatcher { - if(_notificationDispatcher) { return _notificationDispatcher; } + DetoxUserNotificationDispatcher* rv = objc_getAssociatedObject(self, _cmd); - if([self _userNotificationDataURL]) { - _notificationDispatcher = [[DetoxUserNotificationDispatcher alloc] initWithUserNotificationDataURL:[self _userNotificationDataURL]]; + if([self _userNotificationDataURL]) + { + rv = [[DetoxUserNotificationDispatcher alloc] initWithUserNotificationDataURL:[self _userNotificationDataURL]]; + objc_setAssociatedObject(self, _cmd, rv, OBJC_ASSOCIATION_RETAIN_NONATOMIC); } - return _notificationDispatcher; + return rv; } - (BOOL)application:(UIApplication *)application willFinishLaunchingWithOptions:(nullable NSDictionary*)launchOptions { launchOptions = [self _prepareLaunchOptions:launchOptions userNotificationDispatcher:self.userNotificationDispatcher]; - return [_originalAppDelegate application:application willFinishLaunchingWithOptions:launchOptions]; + BOOL rv = YES; + if([class_getSuperclass(object_getClass(self)) instancesRespondToSelector:_cmd]) + { + struct objc_super super = {.receiver = self, .super_class = class_getSuperclass(object_getClass(self))}; + BOOL (*super_class)(struct objc_super*, SEL, id, id) = (void*)objc_msgSendSuper; + rv = super_class(&super, _cmd, application, launchOptions); + } + + return rv; } - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions { launchOptions = [self _prepareLaunchOptions:launchOptions userNotificationDispatcher:self.userNotificationDispatcher]; - BOOL rv = [_originalAppDelegate application:application didFinishLaunchingWithOptions:launchOptions]; + BOOL rv = YES; + if([class_getSuperclass(object_getClass(self)) instancesRespondToSelector:_cmd]) + { + struct objc_super super = {.receiver = self, .super_class = class_getSuperclass(object_getClass(self))}; + BOOL (*super_class)(struct objc_super*, SEL, id, id) = (void*)objc_msgSendSuper; + rv = super_class(&super, _cmd, application, launchOptions); + } - if(self.userNotificationDispatcher == nil && [self _URLOverride] && [_originalAppDelegate respondsToSelector:@selector(application:openURL:options:)]) + if(self.userNotificationDispatcher == nil && [self _URLOverride] && [class_getSuperclass(object_getClass(self)) instancesRespondToSelector:@selector(application:openURL:options:)]) { - [_originalAppDelegate application:[UIApplication sharedApplication] openURL:[self _URLOverride] options:launchOptions]; + [self application:application openURL:[self _URLOverride] options:launchOptions]; } return rv; diff --git a/detox/ios/Detox/DetoxManager.m b/detox/ios/Detox/DetoxManager.m index 2d407d4e83..1305dcaaaf 100644 --- a/detox/ios/Detox/DetoxManager.m +++ b/detox/ios/Detox/DetoxManager.m @@ -115,7 +115,7 @@ - (void) websocketDidReceiveAction:(NSString *)type withParams:(NSDictionary *)p { NSURL* userNotificationDataURL = [NSURL fileURLWithPath:params[@"detoxUserNotificationDataURL"]]; DetoxUserNotificationDispatcher* dispatcher = [[DetoxUserNotificationDispatcher alloc] initWithUserNotificationDataURL:userNotificationDataURL]; - [dispatcher dispatchOnAppDelegate:DetoxAppDelegateProxy.currentAppDelegateProxy.originalAppDelegate simulateDuringLaunch:NO]; + [dispatcher dispatchOnAppDelegate:DetoxAppDelegateProxy.currentAppDelegateProxy simulateDuringLaunch:NO]; [self.websocket sendAction:@"userNotificationDone" withParams:@{} withMessageId: messageId]; } else if([type isEqualToString:@"openURL"]) diff --git a/examples/SwiftExample/SwiftExample.xcodeproj/project.pbxproj b/examples/SwiftExample/SwiftExample.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..b78b0c7a7a --- /dev/null +++ b/examples/SwiftExample/SwiftExample.xcodeproj/project.pbxproj @@ -0,0 +1,495 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 48; + objects = { + +/* Begin PBXBuildFile section */ + 391679021F2D912E00066398 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 391679011F2D912E00066398 /* AppDelegate.swift */; }; + 391679041F2D912E00066398 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 391679031F2D912E00066398 /* ViewController.swift */; }; + 391679071F2D912E00066398 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 391679051F2D912E00066398 /* Main.storyboard */; }; + 391679091F2D912E00066398 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 391679081F2D912E00066398 /* Assets.xcassets */; }; + 3916790C1F2D912E00066398 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3916790A1F2D912E00066398 /* LaunchScreen.storyboard */; }; + 391679151F2D914700066398 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 391679031F2D912E00066398 /* ViewController.swift */; }; + 391679161F2D914700066398 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 391679011F2D912E00066398 /* AppDelegate.swift */; }; + 391679191F2D914700066398 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 3916790A1F2D912E00066398 /* LaunchScreen.storyboard */; }; + 3916791A1F2D914700066398 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 391679081F2D912E00066398 /* Assets.xcassets */; }; + 3916791B1F2D914700066398 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 391679051F2D912E00066398 /* Main.storyboard */; }; + 399522251F2D94DE00550710 /* Detox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 399522221F2D94CB00550710 /* Detox.framework */; }; + 399522261F2D94DE00550710 /* Detox.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 399522221F2D94CB00550710 /* Detox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 399522211F2D94CB00550710 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 399522191F2D94CB00550710 /* Detox.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 394767971DBF985400D72256; + remoteInfo = Detox; + }; + 399522231F2D94CB00550710 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 399522191F2D94CB00550710 /* Detox.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 3928EFA51E47404900C19B6E; + remoteInfo = DetoxUserNotificationTests; + }; + 399522271F2D94DE00550710 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 399522191F2D94CB00550710 /* Detox.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 394767961DBF985400D72256; + remoteInfo = Detox; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 399522291F2D94DF00550710 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 399522261F2D94DE00550710 /* Detox.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 391678FE1F2D912E00066398 /* SwiftExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 391679011F2D912E00066398 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 391679031F2D912E00066398 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; + 391679061F2D912E00066398 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 391679081F2D912E00066398 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 3916790B1F2D912E00066398 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 3916790D1F2D912E00066398 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 3916791F1F2D914700066398 /* SwiftExampleWithLocalDetox.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftExampleWithLocalDetox.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 399522191F2D94CB00550710 /* Detox.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Detox.xcodeproj; path = ../../detox/ios/Detox.xcodeproj; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 391678FB1F2D912E00066398 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 391679171F2D914700066398 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 399522251F2D94DE00550710 /* Detox.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 391678F51F2D912E00066398 = { + isa = PBXGroup; + children = ( + 399522191F2D94CB00550710 /* Detox.xcodeproj */, + 391679001F2D912E00066398 /* SwiftExample */, + 391678FF1F2D912E00066398 /* Products */, + ); + sourceTree = ""; + }; + 391678FF1F2D912E00066398 /* Products */ = { + isa = PBXGroup; + children = ( + 391678FE1F2D912E00066398 /* SwiftExample.app */, + 3916791F1F2D914700066398 /* SwiftExampleWithLocalDetox.app */, + ); + name = Products; + sourceTree = ""; + }; + 391679001F2D912E00066398 /* SwiftExample */ = { + isa = PBXGroup; + children = ( + 391679011F2D912E00066398 /* AppDelegate.swift */, + 391679031F2D912E00066398 /* ViewController.swift */, + 391679051F2D912E00066398 /* Main.storyboard */, + 391679081F2D912E00066398 /* Assets.xcassets */, + 3916790A1F2D912E00066398 /* LaunchScreen.storyboard */, + 3916790D1F2D912E00066398 /* Info.plist */, + ); + path = SwiftExample; + sourceTree = ""; + }; + 3995221A1F2D94CB00550710 /* Products */ = { + isa = PBXGroup; + children = ( + 399522221F2D94CB00550710 /* Detox.framework */, + 399522241F2D94CB00550710 /* DetoxUserNotificationTests.xctest */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 391678FD1F2D912E00066398 /* SwiftExample */ = { + isa = PBXNativeTarget; + buildConfigurationList = 391679101F2D912E00066398 /* Build configuration list for PBXNativeTarget "SwiftExample" */; + buildPhases = ( + 391678FA1F2D912E00066398 /* Sources */, + 391678FB1F2D912E00066398 /* Frameworks */, + 391678FC1F2D912E00066398 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = SwiftExample; + productName = SwiftExample; + productReference = 391678FE1F2D912E00066398 /* SwiftExample.app */; + productType = "com.apple.product-type.application"; + }; + 391679131F2D914700066398 /* SwiftExampleWithLocalDetox */ = { + isa = PBXNativeTarget; + buildConfigurationList = 3916791C1F2D914700066398 /* Build configuration list for PBXNativeTarget "SwiftExampleWithLocalDetox" */; + buildPhases = ( + 391679141F2D914700066398 /* Sources */, + 391679171F2D914700066398 /* Frameworks */, + 391679181F2D914700066398 /* Resources */, + 399522291F2D94DF00550710 /* Embed Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 399522281F2D94DE00550710 /* PBXTargetDependency */, + ); + name = SwiftExampleWithLocalDetox; + productName = SwiftExample; + productReference = 3916791F1F2D914700066398 /* SwiftExampleWithLocalDetox.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 391678F61F2D912E00066398 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 0900; + LastUpgradeCheck = 0900; + ORGANIZATIONNAME = "Leo Natan (Wix)"; + TargetAttributes = { + 391678FD1F2D912E00066398 = { + CreatedOnToolsVersion = 9.0; + }; + }; + }; + buildConfigurationList = 391678F91F2D912E00066398 /* Build configuration list for PBXProject "SwiftExample" */; + compatibilityVersion = "Xcode 8.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 391678F51F2D912E00066398; + productRefGroup = 391678FF1F2D912E00066398 /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 3995221A1F2D94CB00550710 /* Products */; + ProjectRef = 399522191F2D94CB00550710 /* Detox.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 391678FD1F2D912E00066398 /* SwiftExample */, + 391679131F2D914700066398 /* SwiftExampleWithLocalDetox */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 399522221F2D94CB00550710 /* Detox.framework */ = { + isa = PBXReferenceProxy; + fileType = wrapper.framework; + path = Detox.framework; + remoteRef = 399522211F2D94CB00550710 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; + 399522241F2D94CB00550710 /* DetoxUserNotificationTests.xctest */ = { + isa = PBXReferenceProxy; + fileType = wrapper.cfbundle; + path = DetoxUserNotificationTests.xctest; + remoteRef = 399522231F2D94CB00550710 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 391678FC1F2D912E00066398 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 3916790C1F2D912E00066398 /* LaunchScreen.storyboard in Resources */, + 391679091F2D912E00066398 /* Assets.xcassets in Resources */, + 391679071F2D912E00066398 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 391679181F2D914700066398 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 391679191F2D914700066398 /* LaunchScreen.storyboard in Resources */, + 3916791A1F2D914700066398 /* Assets.xcassets in Resources */, + 3916791B1F2D914700066398 /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 391678FA1F2D912E00066398 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 391679041F2D912E00066398 /* ViewController.swift in Sources */, + 391679021F2D912E00066398 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + 391679141F2D914700066398 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 391679151F2D914700066398 /* ViewController.swift in Sources */, + 391679161F2D914700066398 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 399522281F2D94DE00550710 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = Detox; + targetProxy = 399522271F2D94DE00550710 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin PBXVariantGroup section */ + 391679051F2D912E00066398 /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 391679061F2D912E00066398 /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 3916790A1F2D912E00066398 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 3916790B1F2D912E00066398 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 3916790E1F2D912E00066398 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + 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_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; + }; + name = Debug; + }; + 3916790F1F2D912E00066398 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + 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_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + CODE_SIGN_IDENTITY = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 391679111F2D912E00066398 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = SwiftExample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.wix.SwiftExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 391679121F2D912E00066398 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = SwiftExample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.wix.SwiftExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 4.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; + 3916791D1F2D914700066398 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = SwiftExample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.wix.SwiftExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 3916791E1F2D914700066398 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + INFOPLIST_FILE = SwiftExample/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + PRODUCT_BUNDLE_IDENTIFIER = com.wix.SwiftExample; + PRODUCT_NAME = "$(TARGET_NAME)"; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 391678F91F2D912E00066398 /* Build configuration list for PBXProject "SwiftExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3916790E1F2D912E00066398 /* Debug */, + 3916790F1F2D912E00066398 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 391679101F2D912E00066398 /* Build configuration list for PBXNativeTarget "SwiftExample" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 391679111F2D912E00066398 /* Debug */, + 391679121F2D912E00066398 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 3916791C1F2D914700066398 /* Build configuration list for PBXNativeTarget "SwiftExampleWithLocalDetox" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 3916791D1F2D914700066398 /* Debug */, + 3916791E1F2D914700066398 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 391678F61F2D912E00066398 /* Project object */; +} diff --git a/examples/SwiftExample/SwiftExample/AppDelegate.swift b/examples/SwiftExample/SwiftExample/AppDelegate.swift new file mode 100644 index 0000000000..51d4ddd03d --- /dev/null +++ b/examples/SwiftExample/SwiftExample/AppDelegate.swift @@ -0,0 +1,45 @@ +// +// AppDelegate.swift +// SwiftExample +// +// Created by Leo Natan (Wix) on 30/07/2017. +// Copyright © 2017 Leo Natan (Wix). All rights reserved. +// + +import UIKit + +@UIApplicationMain +class AppDelegate: UIResponder, UIApplicationDelegate { + + var window: UIWindow? + + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + // Override point for customization after application launch. + return true + } + + func applicationWillResignActive(_ application: UIApplication) { + // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. + // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. + } + + func applicationDidEnterBackground(_ application: UIApplication) { + // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. + // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. + } + + func applicationWillEnterForeground(_ application: UIApplication) { + // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. + } + + func applicationDidBecomeActive(_ application: UIApplication) { + // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. + } + + func applicationWillTerminate(_ application: UIApplication) { + // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. + } + + +} + diff --git a/examples/SwiftExample/SwiftExample/Assets.xcassets/AppIcon.appiconset/Contents.json b/examples/SwiftExample/SwiftExample/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 0000000000..1d060ed288 --- /dev/null +++ b/examples/SwiftExample/SwiftExample/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,93 @@ +{ + "images" : [ + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "20x20", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "29x29", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "40x40", + "scale" : "3x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "2x" + }, + { + "idiom" : "iphone", + "size" : "60x60", + "scale" : "3x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "20x20", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "29x29", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "40x40", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "1x" + }, + { + "idiom" : "ipad", + "size" : "76x76", + "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/SwiftExample/SwiftExample/Base.lproj/LaunchScreen.storyboard b/examples/SwiftExample/SwiftExample/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 0000000000..9f2ce964ef --- /dev/null +++ b/examples/SwiftExample/SwiftExample/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/SwiftExample/SwiftExample/Base.lproj/Main.storyboard b/examples/SwiftExample/SwiftExample/Base.lproj/Main.storyboard new file mode 100644 index 0000000000..dbe6b7982a --- /dev/null +++ b/examples/SwiftExample/SwiftExample/Base.lproj/Main.storyboard @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/SwiftExample/SwiftExample/Info.plist b/examples/SwiftExample/SwiftExample/Info.plist new file mode 100644 index 0000000000..16be3b6811 --- /dev/null +++ b/examples/SwiftExample/SwiftExample/Info.plist @@ -0,0 +1,45 @@ + + + + + CFBundleDevelopmentRegion + $(DEVELOPMENT_LANGUAGE) + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + armv7 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + + diff --git a/examples/SwiftExample/SwiftExample/ViewController.swift b/examples/SwiftExample/SwiftExample/ViewController.swift new file mode 100644 index 0000000000..3007620e4f --- /dev/null +++ b/examples/SwiftExample/SwiftExample/ViewController.swift @@ -0,0 +1,25 @@ +// +// ViewController.swift +// SwiftExample +// +// Created by Leo Natan (Wix) on 30/07/2017. +// Copyright © 2017 Leo Natan (Wix). All rights reserved. +// + +import UIKit + +class ViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + // Do any additional setup after loading the view, typically from a nib. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + +} +