iOS-Tagent
iOS-Tagent copied to clipboard
xcode12.0.1和iOS 14运行不了
使用环境: Xcode: 12.0.1 iPhone: iOS 14.0
运行错误日志: Test Case '-[UITestingUITests testRunner]' started. t = 0.00s Start Test at 2020-09-28 17:08:29.464 t = 0.00s Set Up 2020-09-28 17:08:34.094588+0800 WebDriverAgentRunner-Runner[539:40815] Built at Apr 15 2020 16:38:43 2020-09-28 17:08:34.137186+0800 WebDriverAgentRunner-Runner[539:40815] ServerURLHere->http://10.10.36.28:8100<-ServerURLHere 2020-09-28 17:08:34.137703+0800 WebDriverAgentRunner-Runner[539:40832] +[XCTestDriver sharedTestDriver]: unrecognized selector sent to class 0x10131aed8 2020-09-28 17:08:34.138183+0800 WebDriverAgentRunner-Runner[539:40832] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[XCTestDriver sharedTestDriver]: unrecognized selector sent to class 0x10131aed8' *** First throw call stack: (0x19145d114 0x1a4c83cb4 0x191371e6c 0x19145f758 0x1914616cc 0x104b42efc 0x104b42eb0 0x191096280 0x191067d5c 0x104b42e88 0x104b20d84 0x191096280 0x191067d5c 0x104b20d60 0x104b2053c 0x191095298 0x191096280 0x1910724fc 0x191072fe8 0x19107c808 0x1d6d405a4 0x1d6d43874) libc++abi.dylib: terminating with uncaught exception of type NSException *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[XCTestDriver sharedTestDriver]: unrecognized selector sent to class 0x10131aed8' terminating with uncaught exception of type NSException
me to
same occurring
求解决,一样的问题
他们还不支持ios14和xcode12
Same problem here - Xcode 12.0.1 and iOS 14.0.1 with iPhone XR
Xcode 12.0.1 and iOS 14.0.1 with iPhone 6s Plus,我这面也遇到了这样的问题。经我调试发现,iOS14确实是没有+[XCTestDriver sharedTestDriver]
方法了。
翻了下WebDriverAgent
中相关源代码,发现问题是在FBXCTestDaemonsProxy
类testRunnerProxy
方法里面,初始化了proxy
对象导致的崩溃。因此感觉可以改掉不需要的初始化判断,因为我这面只是要iOS14能运行起来,所以没有兼容判断以前的系统版本,目前测试在我手机上面,可以运行起来。AirtestIDE
里面也能连接上手机,看到手机屏幕。简单测试了下,点击预览图像,手机那面也能正常响应。 @rill @uwenlee @MacGuffinLife @Naruto @GXH-Developer @rill @mikalaikarol
贴上下面代码:
//
// FBXCTestDaemonsProxy+Hook.m
// WebDriverAgentRunner
//
// Created by txh on 2020/10/27.
// Copyright © 2020 TangXianHai. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
@interface XCTRunnerDaemonSession : NSObject
+ (instancetype)sharedSession;
@property(readonly) id daemonProxy;
@end
@interface FBXCTestDaemonsProxy : NSObject
+ (id)testRunnerProxy;
@end
#import "FBXCTestDaemonsProxy+Hook.h"
@implementation FBXCTestDaemonsProxy (Hook)
+ (void)load {
// load something
[self swizzleClassMethod:objc_getClass("FBXCTestDaemonsProxy") orgSel:NSSelectorFromString(@"testRunnerProxy") swizzSel:NSSelectorFromString(@"hy_testRunnerProxy")];
}
+ (id)hy_testRunnerProxy {
static id proxy = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class runnerClass = objc_lookUpClass("XCTRunnerDaemonSession");
proxy = ((XCTRunnerDaemonSession *)[runnerClass sharedSession]).daemonProxy;
});
NSAssert(proxy != NULL, @"Could not determin testRunnerProxy", proxy);
return proxy;
}
+ (BOOL)swizzleClassMethod:(Class)class orgSel:(SEL)origSel swizzSel:(SEL)altSel {
Method origMethod = class_getClassMethod(class, origSel);
Method altMethod = class_getClassMethod(class, altSel);
if (!origMethod || !altMethod) {
return NO;
}
BOOL didAddMethod = class_addMethod(object_getClass(class),origSel,
method_getImplementation(altMethod),
method_getTypeEncoding(altMethod));
if (didAddMethod) {
class_replaceMethod(class,altSel,
method_getImplementation(origMethod),
method_getTypeEncoding(origMethod));
} else {
method_exchangeImplementations(origMethod, altMethod);
}
return YES;
}
@end
Xcode 12.0.1 and iOS 14.0.1 with iPhone 6s Plus,我这面也遇到了这样的问题。经我调试发现,iOS14确实是没有
+[XCTestDriver sharedTestDriver]
方法了。 翻了下WebDriverAgent 中相关源代码,发现问题是在FBXCTestDaemonsProxy
类testRunnerProxy
方法里面,初始化了proxy
对象导致的崩溃。因此感觉可以改掉不需要的初始化判断,因为我这面只是要iOS14能运行起来,所以没有兼容判断以前的系统版本,目前测试在我手机上面,可以运行起来。AirtestIDE
里面也能连接上手机,看到手机屏幕。简单测试了下,点击预览图像,手机那面也能正常响应。 @rill @uwenlee @MacGuffinLife @Naruto @GXH-Developer @rill @mikalaikarol 贴上下面代码:// // FBXCTestDaemonsProxy+Hook.m // WebDriverAgentRunner // // Created by txh on 2020/10/27. // Copyright © 2020 TangXianHai. All rights reserved. // #import <Foundation/Foundation.h> #import <objc/runtime.h> @interface XCTRunnerDaemonSession : NSObject + (instancetype)sharedSession; @property(readonly) id daemonProxy; @end @interface FBXCTestDaemonsProxy : NSObject + (id)testRunnerProxy; @end #import "FBXCTestDaemonsProxy+Hook.h" @implementation FBXCTestDaemonsProxy (Hook) + (void)load { // load something [self swizzleClassMethod:objc_getClass("FBXCTestDaemonsProxy") orgSel:NSSelectorFromString(@"testRunnerProxy") swizzSel:NSSelectorFromString(@"hy_testRunnerProxy")]; } + (id)hy_testRunnerProxy { static id proxy = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ Class runnerClass = objc_lookUpClass("XCTRunnerDaemonSession"); proxy = ((XCTRunnerDaemonSession *)[runnerClass sharedSession]).daemonProxy; }); NSAssert(proxy != NULL, @"Could not determin testRunnerProxy", proxy); return proxy; } + (BOOL)swizzleClassMethod:(Class)class orgSel:(SEL)origSel swizzSel:(SEL)altSel { Method origMethod = class_getClassMethod(class, origSel); Method altMethod = class_getClassMethod(class, altSel); if (!origMethod || !altMethod) { return NO; } BOOL didAddMethod = class_addMethod(object_getClass(class),origSel, method_getImplementation(altMethod), method_getTypeEncoding(altMethod)); if (didAddMethod) { class_replaceMethod(class,altSel, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); } else { method_exchangeImplementations(origMethod, altMethod); } return YES; } @end
可以简单说下这个代码改哪里吗
是没有
老铁,说一下改在什么地方可以吗
大概又没赶上适配吧
Xcode 12.0.1 and iOS 14.0.1 with iPhone 6s Plus,我这面也遇到了这样的问题。经我调试发现,iOS14确实是没有
+[XCTestDriver sharedTestDriver]
方法了。 翻了下WebDriverAgent 中相关源代码,发现问题是在FBXCTestDaemonsProxy
类testRunnerProxy
方法里面,初始化了proxy
对象导致的崩溃。因此感觉可以改掉不需要的初始化判断,因为我这面只是要iOS14能运行起来,所以没有兼容判断以前的系统版本,目前测试在我手机上面,可以运行起来。AirtestIDE
里面也能连接上手机,看到手机屏幕。简单测试了下,点击预览图像,手机那面也能正常响应。 @rill @uwenlee @MacGuffinLife @Naruto @GXH-Developer @rill @mikalaikarol 贴上下面代码:// // FBXCTestDaemonsProxy+Hook.m // WebDriverAgentRunner // // Created by txh on 2020/10/27. // Copyright © 2020 TangXianHai. All rights reserved. // #import <Foundation/Foundation.h> #import <objc/runtime.h> @interface XCTRunnerDaemonSession : NSObject + (instancetype)sharedSession; @property(readonly) id daemonProxy; @end @interface FBXCTestDaemonsProxy : NSObject + (id)testRunnerProxy; @end #import "FBXCTestDaemonsProxy+Hook.h" @implementation FBXCTestDaemonsProxy (Hook) + (void)load { // load something [self swizzleClassMethod:objc_getClass("FBXCTestDaemonsProxy") orgSel:NSSelectorFromString(@"testRunnerProxy") swizzSel:NSSelectorFromString(@"hy_testRunnerProxy")]; } + (id)hy_testRunnerProxy { static id proxy = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ Class runnerClass = objc_lookUpClass("XCTRunnerDaemonSession"); proxy = ((XCTRunnerDaemonSession *)[runnerClass sharedSession]).daemonProxy; }); NSAssert(proxy != NULL, @"Could not determin testRunnerProxy", proxy); return proxy; } + (BOOL)swizzleClassMethod:(Class)class orgSel:(SEL)origSel swizzSel:(SEL)altSel { Method origMethod = class_getClassMethod(class, origSel); Method altMethod = class_getClassMethod(class, altSel); if (!origMethod || !altMethod) { return NO; } BOOL didAddMethod = class_addMethod(object_getClass(class),origSel, method_getImplementation(altMethod), method_getTypeEncoding(altMethod)); if (didAddMethod) { class_replaceMethod(class,altSel, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); } else { method_exchangeImplementations(origMethod, altMethod); } return YES; } @end
可以简单说下这个代码改哪里吗
可以发一个加了这段代码的代码仓库么
FBXCTestDaemonsProxy+Hook.m
就在原项目的基础上面,新建一个 FBXCTestDaemonsProxy+Hook.m
文件,然后拖拽进去,运行就行了啊,随便放在项目哪里。
FBXCTestDaemonsProxy+Hook.m
就在原项目的基础上面,新建一个
FBXCTestDaemonsProxy+Hook.m
文件,然后拖拽进去,运行就行了啊,随便放在项目哪里。
感谢大佬,已解决问题~
FBXCTestDaemonsProxy+Hook.m
就在原项目的基础上面,新建一个
FBXCTestDaemonsProxy+Hook.m
文件,然后拖拽进去,运行就行了啊,随便放在项目哪里。
感谢大佬可以运行啦,但是浏览器看不到投屏,可以看到JSON信息,airtest连接不到127.0.0.1:8100 无反应,请问一下为什么呢?Xcode12和IOS14.0
@yangshuang520 请问你的问题解决了吗?我是XCode12.2+iOS14.2 遇到了同样的情况。然后我访问/screenshot接口然后保存成文件,只有在mac的Finder中才能显示图片,其他工具都不能正常显示。而且返回的图片size明显比较小。似乎是苹果专有的heic格式的图片。
Xcode 12.0.1 and iOS 14.0.1 with iPhone 6s Plus,我这面也遇到了这样的问题。经我调试发现,iOS14确实是没有
+[XCTestDriver sharedTestDriver]
方法了。 翻了下WebDriverAgent 中相关源代码,发现问题是在FBXCTestDaemonsProxy
类testRunnerProxy
方法里面,初始化了proxy
对象导致的崩溃。因此感觉可以改掉不需要的初始化判断,因为我这面只是要iOS14能运行起来,所以没有兼容判断以前的系统版本,目前测试在我手机上面,可以运行起来。AirtestIDE
里面也能连接上手机,看到手机屏幕。简单测试了下,点击预览图像,手机那面也能正常响应。 @rill @uwenlee @MacGuffinLife @Naruto @GXH-Developer @rill @mikalaikarol 贴上下面代码:// // FBXCTestDaemonsProxy+Hook.m // WebDriverAgentRunner // // Created by txh on 2020/10/27. // Copyright © 2020 TangXianHai. All rights reserved. // #import <Foundation/Foundation.h> #import <objc/runtime.h> @interface XCTRunnerDaemonSession : NSObject + (instancetype)sharedSession; @property(readonly) id daemonProxy; @end @interface FBXCTestDaemonsProxy : NSObject + (id)testRunnerProxy; @end #import "FBXCTestDaemonsProxy+Hook.h" @implementation FBXCTestDaemonsProxy (Hook) + (void)load { // load something [self swizzleClassMethod:objc_getClass("FBXCTestDaemonsProxy") orgSel:NSSelectorFromString(@"testRunnerProxy") swizzSel:NSSelectorFromString(@"hy_testRunnerProxy")]; } + (id)hy_testRunnerProxy { static id proxy = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ Class runnerClass = objc_lookUpClass("XCTRunnerDaemonSession"); proxy = ((XCTRunnerDaemonSession *)[runnerClass sharedSession]).daemonProxy; }); NSAssert(proxy != NULL, @"Could not determin testRunnerProxy", proxy); return proxy; } + (BOOL)swizzleClassMethod:(Class)class orgSel:(SEL)origSel swizzSel:(SEL)altSel { Method origMethod = class_getClassMethod(class, origSel); Method altMethod = class_getClassMethod(class, altSel); if (!origMethod || !altMethod) { return NO; } BOOL didAddMethod = class_addMethod(object_getClass(class),origSel, method_getImplementation(altMethod), method_getTypeEncoding(altMethod)); if (didAddMethod) { class_replaceMethod(class,altSel, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); } else { method_exchangeImplementations(origMethod, altMethod); } return YES; } @end
iOS-Tagent里面没有WebDriverAgent的源码,只是一个lib,是要改完WebDriverAgent的源码,然后编译一个WebDriverAgentLib.framework再拷贝过来吗
ios14适配了通知一下
iOS14急需适配
Xcode 12.0.1 and iOS 14.0.1 with iPhone 6s Plus,我这面也遇到了这样的问题。经我调试发现,iOS14确实是没有
+[XCTestDriver sharedTestDriver]
方法了。 翻了下WebDriverAgent 中相关源代码,发现问题是在FBXCTestDaemonsProxy
类testRunnerProxy
方法里面,初始化了proxy
对象导致的崩溃。因此感觉可以改掉不需要的初始化判断,因为我这面只是要iOS14能运行起来,所以没有兼容判断以前的系统版本,目前测试在我手机上面,可以运行起来。AirtestIDE
里面也能连接上手机,看到手机屏幕。简单测试了下,点击预览图像,手机那面也能正常响应。 @rill @uwenlee @MacGuffinLife @Naruto @GXH-Developer @rill @mikalaikarol 贴上下面代码:// // FBXCTestDaemonsProxy+Hook.m // WebDriverAgentRunner // // Created by txh on 2020/10/27. // Copyright © 2020 TangXianHai. All rights reserved. // #import <Foundation/Foundation.h> #import <objc/runtime.h> @interface XCTRunnerDaemonSession : NSObject + (instancetype)sharedSession; @property(readonly) id daemonProxy; @end @interface FBXCTestDaemonsProxy : NSObject + (id)testRunnerProxy; @end #import "FBXCTestDaemonsProxy+Hook.h" @implementation FBXCTestDaemonsProxy (Hook) + (void)load { // load something [self swizzleClassMethod:objc_getClass("FBXCTestDaemonsProxy") orgSel:NSSelectorFromString(@"testRunnerProxy") swizzSel:NSSelectorFromString(@"hy_testRunnerProxy")]; } + (id)hy_testRunnerProxy { static id proxy = nil; static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ Class runnerClass = objc_lookUpClass("XCTRunnerDaemonSession"); proxy = ((XCTRunnerDaemonSession *)[runnerClass sharedSession]).daemonProxy; }); NSAssert(proxy != NULL, @"Could not determin testRunnerProxy", proxy); return proxy; } + (BOOL)swizzleClassMethod:(Class)class orgSel:(SEL)origSel swizzSel:(SEL)altSel { Method origMethod = class_getClassMethod(class, origSel); Method altMethod = class_getClassMethod(class, altSel); if (!origMethod || !altMethod) { return NO; } BOOL didAddMethod = class_addMethod(object_getClass(class),origSel, method_getImplementation(altMethod), method_getTypeEncoding(altMethod)); if (didAddMethod) { class_replaceMethod(class,altSel, method_getImplementation(origMethod), method_getTypeEncoding(origMethod)); } else { method_exchangeImplementations(origMethod, altMethod); } return YES; } @end
大佬,可以提供一个WebDriverAgentLib的可执行文件吗?