I recently released a Swift framework that had an ABI incompatibility issue (adding final to a class). As an SDK developer, I don't want to ship these kinds of regressions and am hoping a tool exists that can help me spot them early.
Are there any existing tools that can analyze either Swift/Mach-O binaries or .abi.json files and report on breaking differences.
Just doing a JSON diff on arm64-apple-ios.abi.json shows me that "Final" was added to a bunch of definitions, so it seems like such a tool should be possible.
This tool ships as part of the downloadable toolchains on swift.orgbut it's not part of the Swift toolchain in Xcode. Be advised it's a compiler-internal tool at this point so it may change or disappear, etc. (EDIT: This is incorrect. I see it's part of Xcode 16.3.)
In your example, a simpler check would also work. If you run nm -jg on your binary to get a list of symbols, you will see that introducing final causes certain symbols to disappear. In general, you always want the exported symbols of a new version of your library to be a superset of what was exported before. However this won't catch, eg, adding a new stored property to a @frozen struct; the swift-api-digester is a little bit more exhaustive in what it can check. (It's still not perfect though).
Thank you! The nm suggestion is particularly helpful. I'm still trying to understand swift-api-digester but nm's output is very straightforward and easy to pass into diff.
Running diff -u <(nm -jg old/HeapSwiftCore.framework/HeapSwiftCore) <(nm -jg ~new/HeapSwiftCore.framework/HeapSwiftCore) quickly shows me what all has disappeared.