Skip to content

This tool allows comparing 2 versions of a swift (sdk) project and lists all changes in a human readable way.

License

Notifications You must be signed in to change notification settings

Adyen/adyen-swift-public-api-diff

πŸ§ͺ Run Tests

github-header

Swift Public API diff

This tool allows comparing 2 versions of a swift (sdk) project and lists all changes in a human readable way.

It makes use of .swiftinterface files that get produced during the archiving of a swift project and parses them using swift-syntax.

Contributing

We strongly encourage you to contribute to our repository. Find out more in our contribution guidelines

Requirements

  • Xcode >= 16.0 (incl. Xcode command line tools)
  • Swift >= 5.9

Usage

From Project to Output

  • Build using the iOS sdk (Requires an iOS Simulator to be installed)
swift run public-api-diff \ project \ --platform iOS \ --new "develop~https://github.com/Adyen/adyen-ios.git" \ --old "5.12.0~https://github.com/Adyen/adyen-ios.git"
  • Build using the macOS sdk
swift run public-api-diff \ project \ --platform macOS \ --new "main~https://github.com/Adyen/adyen-swift-public-api-diff" \ --old "0.4.0~https://github.com/Adyen/adyen-swift-public-api-diff"
--help:
USAGE: public-api-diff project --new <new> --old <old> --platform <platform> [--scheme <scheme>] [--swift-interface-type <swift-interface-type>] [--output <output>] [--log-output <log-output>] [--log-level <log-level>] OPTIONS: --new <new> Specify the updated version to compare to --old <old> Specify the old version to compare to --platform <platform> The platform to build the project for (iOS/macOS) --scheme <scheme> [Optional] Which scheme to build (Needed when comparing 2 xcode projects) --swift-interface-type <swift-interface-type> [Optional] Specify the type of .swiftinterface you want to compare (public/private) (default: public) --output <output> [Optional] Where to output the result (File path) --log-output <log-output> [Optional] Where to output the logs (File path) --log-level <log-level> [Optional] The log level to use during execution (default: default) -h, --help Show help information. 

From .swiftinterface to Output

1. Build 2 versions of your project with BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild clean build \ -scheme "YOUR_TARGET_NAME" \ -derivedDataPath .build \ -sdk "$(xcrun --sdk iphonesimulator --show-sdk-path)" \ -destination "generic/platform=iOS" \ BUILD_LIBRARY_FOR_DISTRIBUTION=YES

2. Provide the .swiftinterface files to the public api diff

swift run public-api-diff \ swift-interface \ --new "new/path/to/project.swiftinterface" \ --old "old/path/to/project.swiftinterface"
--help:
USAGE: public-api-diff swift-interface --new <new> --old <old> [--target-name <target-name>] [--old-version-name <old-version-name>] [--new-version-name <new-version-name>] [--output <output>] [--log-output <log-output>] [--log-level <log-level>] OPTIONS: --new <new> Specify the updated .swiftinterface file to compare to --old <old> Specify the old .swiftinterface file to compare to --target-name <target-name> [Optional] The name of your target/module to show in the output --old-version-name <old-version-name> [Optional] The name of your old version (e.g. v1.0 / main) to show in the output --new-version-name <new-version-name> [Optional] The name of your new version (e.g. v2.0 / develop) to show in the output --output <output> [Optional] Where to output the result (File path) --log-output <log-output> [Optional] Where to output the logs (File path) --log-level <log-level> [Optional] The log level to use during execution (default: default) -h, --help Show help information. 

From .framework to Output

swift run public-api-diff \ framework \ --target-name "TargetName" \ --new "new/path/to/project.framework" \ --old "old/path/to/project.framework"
--help:
USAGE: public-api-diff framework --new <new> --old <old> --target-name <target-name> [--swift-interface-type <swift-interface-type>] [--old-version-name <old-version-name>] [--new-version-name <new-version-name>] [--output <output>] [--log-output <log-output>] [--log-level <log-level>] OPTIONS: --new <new> Specify the updated .framework to compare to --old <old> Specify the old .framework to compare to --target-name <target-name> The name of your target/module to show in the output --swift-interface-type <swift-interface-type> [Optional] Specify the type of .swiftinterface you want to compare (public/private) (default: public) --old-version-name <old-version-name> [Optional] The name of your old version (e.g. v1.0 / main) to show in the output --new-version-name <new-version-name> [Optional] The name of your new version (e.g. v2.0 / develop) to show in the output --output <output> [Optional] Where to output the result (File path) --log-output <log-output> [Optional] Where to output the logs (File path) --log-level <log-level> [Optional] The log level to use during execution (default: default) -h, --help Show help information. 

Release Build

Create

swift build --configuration release

Run

./public-api-diff \ project \ --new "develop~https://github.com/Adyen/adyen-ios.git" \  --old "5.12.0~https://github.com/Adyen/adyen-ios.git"
./public-api-diff \ swift-interface \ --new "new/path/to/project.swiftinterface" \ --old "old/path/to/project.swiftinterface"
./public-api-diff \ framework \ --target-name "TargetName" \ --new "new/path/to/project.framework" \ --old "old/path/to/project.framework"

Github Action

The public-api-diff can be used easily via the provided github action, which creates a comment on a PR (if applicable) and also adds it to the Github step summary.

- name: πŸ” Detect Changes uses: Adyen/adyen-swift-public-api-diff@0.4.0 with: platform: "iOS" new: "develop~https://github.com/Adyen/adyen-ios.git" old: "5.12.0~https://github.com/Adyen/adyen-ios.git"

See: example workflow

Alternatives

  • swift-api-digester
    • xcrun swift-api-digester -dump-sdk
    • xcrun swift-api-digester -diagnose-sdk

Projects using public-api-diff

Inspiration

Support

If you have a feature request, or spotted a bug or a technical problem, create a GitHub issue.

License

MIT license. For more information, see the LICENSE file.

About

This tool allows comparing 2 versions of a swift (sdk) project and lists all changes in a human readable way.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages