ws233
(Cyril)
1
What is a way to run diagnose-api-breaking-changes for iOS?
I've tried different ways. The only one I could succeed was this.
swift package -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk iphonesimulator --show-sdk-path`" -Xswiftc "-target" -Xswiftc "x86_64-apple-ios11.0-simulator" diagnose-api-breaking-changes -v 1.0.0
But it results in "No breaking changes detected"
Furthermore there are many MacOSX12.3.sdk or x86_64-apple-macosx in logs.
Seems like an error in my command.
Could you please tell the correct command parameters to run it for iOS?
jonprescott
(Jonathan Prescott)
2
You are running against the simulator, not the device. Change the ```--sdk`` parameter to the appropriate device SDK
ws233
(Cyril)
3
Can I use it for simulator? What the correct parameters are? @jonprescott
jonprescott
(Jonathan Prescott)
4
You are already using it for the simulator. You need to look up the options for the --sdk parameter if you want to use it against a specific device. Maybe --sdk iphone
ws233
(Cyril)
5
@jonprescott I don't need it for the device. I want to compile it for the simulator, but the parameters above doesn't work. This parameters still produce a lot of macOS mentions in the logs. That's the issue. I need to correct parameters to avoid all the macOS mentions from the logs.
Otherwise it seems like diagnose-api-breaking-changes still does some part of job (for example, compilation) for the MacOS instead of iOS simulator.
Could you provide correct command line for iOS simulator?
ws233
(Cyril)
6
lipo -info .build/x86_64-apple-macosx/debug/libMyLib.dylib
Non-fat file: .build/x86_64-apple-macosx/debug/libMyLib.dylib is architecture: x86_64
dacvrijma
(Deva Vrijma)
7
Any update on this? I am running into the same issue.
If I run the command with:
swift package --arch arm64 -Xswiftc "-sdk" -Xswiftc "`xcrun --sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS16.2.sdk --show-sdk-path`" -Xswiftc "-target" -Xswiftc "arm64-apple-ios16.2" diagnose-api-breaking-changes 84db9ae
I always get the message "No breaking changes detected in TestPackage" When I am 100% I have introduced breaking changes.
I have tested that adding iOS sdk options to the command always produces this result, even when I don't have any iOS related code and do not have any platform set in the Package.swift file.
Without changing any code after running the command mentioned above, when I run the same command without the additional options:
swift package diagnose-api-breaking-changes d1730d8
I get the following result:
1 breaking change detected in TestPackage:
💔 API breakage: struct Person has been removed
So clearly adding these options prevents the diagnose-breaking-changes from working properly.
Any help with this would be much appreciated
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.
1 Like
In case it's helpful to anybody else this does work with xcodebuild as well, you just gotta change the paths a bit:
xcodebuild -derivedDataPath .build -sdk "`xcrun --sdk iphonesimulator --show-sdk-path`" -scheme "MY_SCHEME" -target "x86_64-apple-ios16.4-simulator" -destination "platform=iOS,name=Any iOS Device"
swift api-digester -dump-sdk -module MY_MODULE -o old.json -I .build/Build/Products/Debug-iphonesimulator -sdk "`xcrun --sdk iphonesimulator --show-sdk-path`" -target "x86_64-apple-ios16.4-simulator"
Then run swift api-digester -diagnose-sdk against your old/new json files like normal.
It's also worth noting I needed to explicitly add platforms to my Package.swift to get this to chill out on availability when using xcodebuild.
1 Like