From ff6a2c020754dc3ba3f5950c514ae6b764786ce3 Mon Sep 17 00:00:00 2001 From: yulingtianxia Date: Thu, 5 Apr 2018 20:39:25 +0800 Subject: [PATCH] fix gesture crash https://github.com/yulingtianxia/TBUIAutoTest/pull/2/files --- TBUIAutoTest.podspec | 2 +- TBUIAutoTest/UIView+TBUIAutoTest.m | 11 ++++++++--- .../TBUIAutoTestDemo.xcodeproj/project.pbxproj | 6 +++++- .../xcshareddata/IDEWorkspaceChecks.plist | 8 ++++++++ .../xcshareddata/xcschemes/TBUIAutoTestDemo.xcscheme | 4 +--- .../xcshareddata/xcschemes/TBUIAutoTestKit.xcscheme | 4 +--- 6 files changed, 24 insertions(+), 11 deletions(-) create mode 100644 TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist diff --git a/TBUIAutoTest.podspec b/TBUIAutoTest.podspec index 5450a3d..6725ccb 100644 --- a/TBUIAutoTest.podspec +++ b/TBUIAutoTest.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "TBUIAutoTest" -s.version = "1.1.3" +s.version = "1.1.4" s.summary = "Generating accessibilityIdentifier for UIAutomation." s.description = <<-DESC TBUIAutoTest generates UIAutomation `accessibilityIdentifier` for you. diff --git a/TBUIAutoTest/UIView+TBUIAutoTest.m b/TBUIAutoTest/UIView+TBUIAutoTest.m index 0869a99..66eb7c3 100644 --- a/TBUIAutoTest/UIView+TBUIAutoTest.m +++ b/TBUIAutoTest/UIView+TBUIAutoTest.m @@ -9,6 +9,7 @@ #import "UIView+TBUIAutoTest.h" #import "UIResponder+TBUIAutoTest.h" #import "TBUIAutoTest.h" +#import #define kiOS8Later SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0") @@ -126,9 +127,13 @@ - (void)tb_addSubview:(UIView *)view { return; } [self tb_addSubview:view]; - UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:view action:@selector(longPress:)]; - longPress.delegate = [TBUIAutoTest sharedInstance]; - [view addGestureRecognizer:longPress]; + UILongPressGestureRecognizer *longPress = objc_getAssociatedObject(view, _cmd); + if (!longPress) { + longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:view action:@selector(longPress:)]; + longPress.delegate = [TBUIAutoTest sharedInstance]; + [view addGestureRecognizer:longPress]; + objc_setAssociatedObject(view, _cmd, longPress, OBJC_ASSOCIATION_RETAIN); + } } - (UIViewController*)viewController { diff --git a/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/project.pbxproj b/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/project.pbxproj index 5a13511..f80c9ad 100644 --- a/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/project.pbxproj +++ b/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/project.pbxproj @@ -220,7 +220,7 @@ A477FDBF1DD07657000F8482 /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 0920; + LastUpgradeCheck = 0930; ORGANIZATIONNAME = "杨萧玉"; TargetAttributes = { A477FDC61DD07657000F8482 = { @@ -343,6 +343,7 @@ 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_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -350,6 +351,7 @@ 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; @@ -398,6 +400,7 @@ 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_DOCUMENTATION_COMMENTS = YES; CLANG_WARN_EMPTY_BODY = YES; @@ -405,6 +408,7 @@ 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; diff --git a/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/xcshareddata/xcschemes/TBUIAutoTestDemo.xcscheme b/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/xcshareddata/xcschemes/TBUIAutoTestDemo.xcscheme index 7dbc9d0..6703588 100644 --- a/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/xcshareddata/xcschemes/TBUIAutoTestDemo.xcscheme +++ b/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/xcshareddata/xcschemes/TBUIAutoTestDemo.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +45,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO" diff --git a/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/xcshareddata/xcschemes/TBUIAutoTestKit.xcscheme b/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/xcshareddata/xcschemes/TBUIAutoTestKit.xcscheme index 3adab28..d3bc30c 100644 --- a/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/xcshareddata/xcschemes/TBUIAutoTestKit.xcscheme +++ b/TBUIAutoTestDemo/TBUIAutoTestDemo.xcodeproj/xcshareddata/xcschemes/TBUIAutoTestKit.xcscheme @@ -1,6 +1,6 @@ @@ -37,7 +36,6 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" - language = "" launchStyle = "0" useCustomWorkingDirectory = "NO" ignoresPersistentStateOnLaunch = "NO"