I was able to get a version of this working, just not using the tool built into SPM, but I'm posting it here in case its useful
Step 1: Use swift build
to build your product
swift build -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios16.4-simulator"
Step 2: Use swift api-digester -dump-sdk
to get a JSON dump of the declarations
swift api-digester -dump-sdk -module <MODULE_NAME> -o new.json -I .build/debug -sdk "`xcrun --sdk iphonesimulator --show-sdk-path`" -target "x86_64-apple-ios16.4-simulator"
Step 3: Repeat steps 1 & 2 for the "old" version of the API to test against
Step 4: Use swift api-digester -diagnose-sdk
to compare the JSON files and spit out a report
swift api-digester -diagnose-sdk --input-paths old.json --input-paths new.json
I'm still testing whether xcodebuild
can work instead. Also, to make this viable you'd probably have to write something that parsed the output of -diagnose-sdk
. Presumably this could be kind of stupid, though, the output looks like this:
/* Generic Signature Changes */
/* RawRepresentable Changes */
/* Removed Decls */
Protocol Cache has been removed
Var DIFactory.cache has been removed
/* Moved Decls */
/* Renamed Decls */
/* Type Changes */
/* Decl Attribute changes */
/* Fixed-layout Type Changes */
/* Protocol Conformance Change */
/* Protocol Requirement Change */
/* Class Inheritance Change */
/* Others */
So my gut says you could strip the known comment lines and empty lines from the file, then pass anything remaining to stderr with a little emoji to get the same behavior.