Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5/x] Fix pre-built library evolution and testability #265

Merged
merged 3 commits into from
Jan 10, 2022

Conversation

andrewchang-bird
Copy link
Contributor

@andrewchang-bird andrewchang-bird commented Jan 10, 2022

Stack

πŸ“š #266 [6/x] Update example projects to use 0.19.1
πŸ“š #265 ← [5/x] Fix support for Swift library evolution
πŸ“š #264 [4/x] Fix configurator relative path handling
πŸ“š #263 [3/x] Fix package manager integrations
πŸ“š #261 [2/x] Archive supporting sources in release workflow
πŸ“š #260 [1/x] Fix CLI archiving and distribution

Overview

Library Evolution

Module stability is currently broken despite enabling the BUILD_LIBRARIES_FOR_DISTRIBUTION build setting which prevents using an β€œold” version of Mockingbird.framework if it hasn’t been compiled for the current toolchain and Swift version. After some investigation, it’s due to a known issue since Xcode 11.2 (SR-14195):

If a module is built with BUILD_LIBRARIES_FOR_DISTRIBUTION and contains a public type with the same name as the module itself, clients will fail to import the module. (19481048) (FB5863238)

Workaround: Rename either the type or the module to remove the conflict.

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 PR avoids referencing XCTest symbols in the Swift module interface by bridging them from Objective-C.

A side effect of the test expectation changes is that the asynchronous verification API is improved:

// Old
let expectation = eventually {
  verify(bird.canFly).wasCalled()
  verify(bird.fly()).wasCalled()
}
wait(for: [expectation], timeout: 1.0)

// New
eventually {
  verify(bird.canFly).wasCalled()
  verify(bird.fly()).wasCalled()
}
waitForExpectations(timeout: 1.0)

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.

Fixes #242

Test Plan

Archiving the framework with Xcode 13.0 / Swift 5.5 and compiling it against the Xcode 13.2 / Swift 5.5.2 toolchain no longer produces errors.

@andrewchang-bird andrewchang-bird force-pushed the dev/andrewchang-bird/fix-configurator-paths branch from 59c65de to c9a18a8 Compare January 10, 2022 21:32
Base automatically changed from dev/andrewchang-bird/fix-configurator-paths to master January 10, 2022 22:40
@andrewchang-bird andrewchang-bird force-pushed the dev/andrewchang-bird/fix-library-evolution branch from 6d7f995 to 3d3fbbc Compare January 10, 2022 22:41
@andrewchang-bird andrewchang-bird merged commit 12b8440 into master Jan 10, 2022
@andrewchang-bird andrewchang-bird deleted the dev/andrewchang-bird/fix-library-evolution branch January 10, 2022 23:16
andrewchang-bird added a commit that referenced this pull request Jan 19, 2022
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.
andrewchang-bird added a commit that referenced this pull request Jan 19, 2022
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Library evolution support is broken
2 participants