ChargePoint / xcparse

Command line tool & Swift framework for parsing Xcode 11+ xcresult
MIT License
390 stars 47 forks source link

[BUG] It errors out on Xcode 16 #87

Open marinofelipe opened 2 months ago

marinofelipe commented 2 months ago

Describe the bug

The xcresulttool version that comes bundled with Xcode 16 deprecates the commands currently used, such as xcresulttool get object, and introduces new ones.

For it to work normally, without changing to use the new commands, it requires the --legacy argument to be passed when calling deprecated methods, otherwise it errors out, for example

mint run xcparse screenshots my_repo/someTarget.xcresult my_repo/output_dir

fails with

Error: Error: This command is deprecated and will be removed in a future release, --legacy flag is required to use it.
Usage: xcresulttool get object [--legacy] --path <path> [--id <id>] [--version <version>] [--format <format>]
  See 'xcresulttool get object --help' for more information.

Desktop (please complete the following information):

To Reproduce use xcparse with Xcode 16 as the selected toolchain (i.e. via xcode-select -s)

Expected behavior It should not error out

Additional context I've a fork with a simple fix for it, let me know if I should move a PR with it, which I would have to ask a few follow up questions before opening it

Here's an example of a similar issue opened and addressed by the fastlane community: https://github.com/fastlane/fastlane/issues/22132

TheMetalCode commented 2 months ago

None of what I'm about to say should prevent xcparse from being patched to use xcresulttool in a manner compatible with Xcode 16!

But for those curious, I was able to come up with workarounds the xcparse commands I was using.

The functionality of xcparse logs can be replicated with a few separate xcresulttool calls (using --legacy if Xcode 16+) and a couple jq queries:

# get xcresult into json form so we can parse out some IDs to use for exports
xcrun xcresulttool get --path YourXCResult.xcresult --format json --legacy > YourXCResult.json

# get the ids for Diagnostics and the action log
DIAGNOSTICS_ID=$(cat YourXCResult.json | jq '.actions._values[0].actionResult.diagnosticsRef.id._value')
DIAGNOSTICS_ID=${DIAGNOSTICS_ID//\"/}
ACTION_LOG_ID=$(cat YourXCResult.json | jq '.actions._values[0].actionResult.logRef.id._value')
ACTION_LOG_ID=${ACTION_LOG_ID//\"/}

# export diagnostics and action log from .xcresult
xcrun xcresulttool export --type directory --path YourXCResult.xcresult --id ${DIAGNOSTICS_ID} --output-path test_logs/Diagnostics --legacy
xcrun xcresulttool export --type file --path YourXCResult.xcresult --id ${ACTION_LOG_ID} --output-path test_logs/action.txt --legacy

And for xcparse codecov - it all depends on what you were using it for. In my case, I was only using it to generate the .xccovreport that I would generate a json report from with xcrun xccov view MyXCCovReport.xccovreport" --json > coverage.json. But I was able to get the same json directly from the .xcresult file using a slightly different xccov command: xcrun xccov view --report MyXCResult.xcresult --json > coverage.json. So in my case I ended up just not needing to use xcparse codecov, but of course your mileage may vary.

rsukumar-cpi commented 2 months ago

@marinofelipe Thanks for flagging the issue. You can go ahead and raise a PR. We will also look into updating the deprecated methods in the future.

CC: @abotkin-cpi

megastep commented 2 months ago

I'm running into this issue as well, and found a simple temporary workaround if you still have a copy of Xcode 15 installed on your system, to force the old version of xcresulttool being used.

Just set the DEVELOPER_DIR environment variable to the location of your Xcode 15 binary, i.e. /Applications/Xcode15.app/Contents/Developer before calling xcparse. This will only affect the version of Xcode being used while calling it when that environment variable is set, so you can still have your existing processes run with Xcode 16 except for extracting screenshots.

abotkin-cpi commented 1 month ago

We plan to release an updated xcparse 2.4 next week that will include the legacy workaround once backwards compatibility with older Xcode toolchains is confirmed working. Thanks for bringing this up and working up a PR, @marinofelipe !

tahirmt commented 2 weeks ago

Now that the pull request is merged, can we please get the 2.4 release published?