Skip to content

Upgrading

Marko Justinek edited this page Aug 15, 2022 · 20 revisions

Changes in v1.x.x

Minimum Xcode version required is 13.x.
Last PactSwift version to support Xcode up to and including 12.4 version is v0.13.1.

Dropped support for Carthage. Linking binary frameworks has been broken from Xcode 13.3+.

Changes in v0.7.x

Breaking change

baseUrl is no longer exposed on a MockService instance. The url for your Pact unit test is provided within the testFunction's completion block allowing each of the tests to run independently.

# This no longer works
let baseURL = MockService.baseUrl

# Use this instead
mockService.run { baseURL, done in
  yourAPIClient(baseURL: baseURL).doThings()
  done()
}

Changes in v0.6.x

Linux Support

PactSwift now runs on Linux too, although Linux users must provide their own libpact_ffi.so library.
It can be built from Rust code found at pact-reference/pact_ffi. In order to build it you must have Rust installed:

# Getting Rust
curl https://sh.rustup.rs -sSf | sh

# Building libpact_ffi.so
git clone https://github.com/pact-foundation/pact-reference
cd pact-reference/rust/pact_ffi
cargo build --release

# Building and Testing your Swift project on Linux
cd /path/to/your/swift/project/
export LD_LIBRARY_PATH=/absolute/path/to/pact-reference/rust/target/release/
swift build -Xlinker -L/absolute/path/to/pact-reference/rust/target/release/
swift test -Xlinker -L/absolute/path/to/pact-reference/rust/target/release/

Breaking changes

  1. PactSwiftMockServer automatically assigns an available port. Since PactSwift runs in-process on localhost it really does not make any sense specifying a port at init. In order to be able to run PactSwift on Apple and Linux platforms, the darwin specific code that found an available port has been dropped in favour of socket address 127.0.0.1:0 which converts to an address of a found available port.
// This no longer works:
mockService = MockService(port: 1234)

// Use this:
mockService = MockService()
  1. MockService has been renamed to PFMockService for Objective-C projects. In order for PactSwift to provide support on Linux a decision has been made to remove any @objc annotations for MockService. PFMockService has been introduced as a wrapper around MockService.
// This no longer works:
_mockService = [[MockService alloc] init];

// Use this:
_mockService = [[PFMockService alloc] init]; 

Changes in v0.5.x

Swift Package distributed

Exposed as an open source swift package instead of an XCFramework binary.

Breaking changes

MockService.run() method signature changed. Renamed waitFor argument into timeout.

waitFor is confusing as it might indicate the test will wait for x amount of time before it runs. timeout is a more appropriate argument name for the implemented behaviour.

// <0.4.x
mockService.run(waitFor: 1) { [unowned self] testCompleted in ... }
// >=0.5.0
mockService.run(timeout: 1) { [unowned self] testCompleted in ... }

Changes in v0.4.x

Dropping Rust dependency. MockServer was moved into a separate project dependency PactSwiftMockServer and is exposed as a XCFramework in PactSwiftMockServer-Dist. This means there is no need to make changes to the build process in the Xcode project settings.

PactSwift 0.4.0 migrated to XCFrameworks.

SPM

  1. Remove the Build Phase that builds the libpact_mock_server.a binary using ./Scripts/BuildPhases/build-spm-dependency script.
  2. Remove $BUILD_DIR/../../SourcePackages/checkouts/.. entry for Library Search Paths in Build Settings.
  3. Optional: Remove cargo and rustup from PATH

Carthage

  1. Delete your Carthage/Build folder to remove any existing framework bundles.
  2. Build new XCFrameworks by running carthage build --use-xcframeworks. Any other arguments you build with can be provided like normal.
  3. Remove references to the old frameworks in each of your targets:
    • Delete references to Carthage frameworks from the target's Frameworks, Libraries, and Embedded Content section and/or its Link Binary with Libraries build phase.
    • Delete references to Carthage frameworks from any Copy Files build phases.
    • Delete the target's carthage copy-frameworks build phase, if present.
  4. Add references to XCFrameworks in each of your targets:
    • For an application test target: In the Build Phases settings tab, in the Link Binary With Libraries build phase, add the PactSwift.xcframework from the Carthage/Build folder on disk.
  5. Remove $(FRAMEWORK_SEARCH_PATHS) entry for Runpath Search Paths in Build Settings for your test target.
  6. Remove $(PROJECT_DIR)/Carthage/Build/iOS entry for Framework Search Paths in Build Settings for your test target.