-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix pre-built library evolution and testability (#265)
Library Evolution Module stability is currently broken despite enabling the `BUILD_LIBRARIES_FOR_DISTRIBUTION` build setting, due to a known issue since Xcode 11.2 (FB5863238). Specifically, Mockingbird returns an `XCTest.XCTestExpectation` for asynchronous testing which is ambiguous in the module interface since `XCTest` itself exports a class named `XCTest`. To fix the issue, this change avoids referencing XCTest symbols in the Swift module interface by bridging them from Objective-C. Testability The release version is set to strip debug symbols which prevents testable imports of Mockingbird. This explicitly sets `COPY_PHASE_STRIP` to `NO` for both Carthage and CocoaPods.
- Loading branch information
1 parent
cc5c43b
commit 12b8440
Showing
14 changed files
with
193 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
Sources/MockingbirdFramework/Objective-C/Bridge/include/MKBTestExpectation.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#import <XCTest/XCTest.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
/// An expected outcome in an asynchronous test. | ||
/// | ||
/// Library evolution as of Swift 5.5.2 breaks when publicly including any types from the `XCTest` | ||
/// framework due to the `XCTest` class declaration. Using a bridged type that can be casted to and | ||
/// from `XCTestExpectation` allows us to avoid a direct reference in the Swift module interface. | ||
/// See https://github.com/birdrides/mockingbird/issues/242 for more information. | ||
NS_SWIFT_NAME(TestExpectation) | ||
@interface MKBTestExpectation : XCTestExpectation | ||
|
||
/// Convert an `XCTestExpectation` to a `MKBTestExpectation`. | ||
/// @param expectation An `XCTestExpectation` instance. | ||
+ (instancetype)createFromExpectation:(XCTestExpectation *)expectation; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
1 change: 1 addition & 0 deletions
1
Sources/MockingbirdFramework/Objective-C/Bridge/include/Mockingbird.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#import "MKBMocking.h" | ||
#import "MKBTestExpectation.h" | ||
#import "MKBTestUtils.h" | ||
#import "MKBTypeFacade.h" |
10 changes: 10 additions & 0 deletions
10
Sources/MockingbirdFramework/Objective-C/Bridge/sources/MKBTestExpectation.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#import "../include/MKBTestExpectation.h" | ||
|
||
@implementation MKBTestExpectation | ||
|
||
+ (instancetype)createFromExpectation:(XCTestExpectation *)expectation | ||
{ | ||
return (MKBTestExpectation *)expectation; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.