Unrecognized selector error on app launch
rfodge opened this issue · comments
Do you know what could be causing this error for app.launch() with the latest version of 8.2.0:
2021-11-04 22:17:20.979857-0400 xUITests-Runner[5951:17083565] [SBTUITestTunnel] Did connect after, 10.973560s 2021-11-04 22:17:20.980108-0400 xUITests-Runner[5951:17083565] -[NSInvocation _dtx_serializedDictionaryForDistantObject:]: unrecognized selector sent to instance 0x60000380f600 /Users/fodgerl/repos/iOS/src/Pods/SBTUITestTunnelCommon/Sources/SBTUITestTunnelCommon/DetoxIPC/_DTXIPCDistantObject.m:89: error: -[xUITests.AccountSettingsNavigationUITest testNavBarText] : -[NSInvocation _dtx_serializedDictionaryForDistantObject:]: unrecognized selector sent to instance 0x60000380f600 (NSInvalidArgumentException) t = 14.56s Tear Down
Not sure if I am missing another setting now or 🤔
Is this systematic or a random error?
I’m running my tests on my simulators locally. Usually I run in parallel but due to this issue I tried just running one test even. It happens every time though. All I have it calling right now is app.launch() to try to troubleshoot and it does launch the app but crashes because I keep getting that error.
I reviewed a prior closed issue and saw that you noted:
"BTW you can opt out from IPC by setting SBTUITestTunnelDisableIPC to YES in the info.plist of the test runner app target"
I added this and this looks to resolve that error. (Note: i'm not familiar with why or what this means :) but this didn't throw that error anymore)
What version of Xcode are you running? On which version of iOS are you running the tests?
IPC tunneling should work on all simulators. On physical device we need to fallback to the old http tunnel we were using before.
There may be something peculiar in your setup and it would be interesting to find out what it is.
Review the initialization of client and server follows the documentation.
We are using Xcode 12.4 and macOS Catalina currently. We should be upgrading in the near future to Xcode 13 and Monetery.
For the setup, I believe we have everything according to the documentation but let me know if you see something here that i have incorrect or missing.
In our app and test bridging-header.h files:
#if UITESTS || UITESTSLOCAL
#import "SBTUITestTunnelServer.h"
#import "SBTUITunneledApplication.h"
#import "XCTestCase+AppExtension.h"
#endif
pod file uses:
pod 'SBTUITestTunnelClient', '> 8.2.0'> 3.5.4', :inhibit_warnings => true
pod 'GCDWebServer', '
pod 'SBTUITestTunnelCommon', '~> 8.2.0'
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.name == 'UI-TESTS' || config.name == 'UI-TESTS-LOCAL'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'ENABLE_UITUNNEL=1', 'ENABLE_UITUNNEL_SWIZZLING=1']
config.build_settings['SWIFT_ACTIVE_COMPILATION_CONDITIONS'] = "DEBUG"
end
end
end
end
In our AppDelegate:
#if UITESTS || UITESTSLOCAL
import SBTUITestTunnelServer
#endif
#if UITESTS || UITESTSLOCAL
SBTUITestTunnelServer.takeOff()
I was using the simulator of iPhone SE (1st generation) 14.4 i'll pick another newer device just to confirm its not a device specific error as well.
Just confirming that I am receiving the same error on other devices as well.
I do not in my test code, but I see the app does use DispatchQueues (eg DispatchQueue.main.async)
I created just a super simple test:
import XCTest
class SampleTest1: XCTestCase {
override func setUpWithError() throws {
try super.setUpWithError()
app.launchTunnel()
}
func testOne() {
XCTAssertTrue(true)
}
}
This will hit the breakpoint/error at line 84 shown above if I set SBTUITestTunnelDisableIPC to NO but does not fail if I set this to YES.
I don't believe so but I'm asking a Dev to confirm for me.
We have:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
...
self.configureLocalSettings()
...
return true
}
private func configureLocalSettings() {
#if UITESTS || UITESTSLOCAL
SBTUITestTunnelServer.takeOff()
#endif
}
I don't see any DispatchQueues in either of these functions, but I'll let you know once a Dev confirms that I'm not missing anything.
OK i confirmed that the takeOff() isn't wrapped in any Dispatch Queue
Just an update - I am upgraded to XCode 13 and Monterey and i'm still receiving the same error when trying to use IPC enabled.
Why are you importing the tunnel headers in the bridging headers instead of using modular imports (@import SBTUITest..
)?
Those installation instructions refer to the manual integration which should be used when you're not integrating through SPM or CocoaPods