Tests running in Xcode 8.3 do not use same version of GCDAsyncSocketDelegate main app uses
| Originator: | paulo | ||
| Number: | rdar://31344564 | Date Originated: | |
| Status: | Open | Resolved: | |
| Product: | Developer Tools | Product Version: | Xcode 8.3 |
| Classification: | Serious bug | Reproducible: | Always |
Summary:
Apparently Xcode 8.3 test suite is including a symbols from popular networking library CocoaAsyncSocket. Namely, GCDAsyncSocketDelegate. This may conflict with a custom version of the library used in the main app.
Steps to Reproduce:
1. Create a new project using Xcode and enable unit testing
2. Run the following test:
- (void)testExample {
XCTAssertNil(NSProtocolFromString(@"GCDAsyncSocketDelegate"), @"This should be nil");
}
Expected Results:
NSProtocolFromString(@"GCDAsyncSocketDelegate") should return nil and the test should pass.
Actual Results:
The test fails because GCDAsyncSocketDelegate protocol exists at runtime.
Regression:
This problem only started after upgrading to Xcode 8.3. My tests ran fine on previous version.
Notes:
I’ve determined which classes are implementing that protocol with the following code:
Class* classes = NULL;
int numClasses = objc_getClassList(NULL, 0);
if (numClasses > 0 ) {
classes = (Class *)malloc(sizeof(Class) * numClasses);
numClasses = objc_getClassList(classes, numClasses);
for (int index = 0; index < numClasses; index++) {
Class nextClass = classes[index];
if (class_conformsToProtocol(nextClass, NSProtocolFromString(@"GCDAsyncSocketDelegate"))) {
NSLog(@"%@", nextClass);
}
}
free(classes);
}
which prints:
DTAssetHTTPRequestHandler
DTAssetHTTPServer
Those two classes appear to be from Developer Tools provided with Xcode.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!