MobileNativeFoundation / XCLogParser

Tool to parse Xcode and xcodebuild logs stored in the xcactivitylog format
Apache License 2.0
1.73k stars 121 forks source link

Error: xcactivitylog is not a valid xcactivitylog file #159

Closed CraigSiemens closed 2 years ago

CraigSiemens commented 2 years ago

We're currently getting the following error after running xclogparser.

Error: /PATH/TO/.../F0DAEBCF-B096-4FAD-917D-1BFED5DC43F4.xcactivitylog is not a valid xcactivitylog file

At first we thought it was from EnableSwiftBuildSystemIntegration in Xcode 13.2+ but disabling it and going down to Xcode 13.1 have the same issue.

The file is created at the shown location and is 15.9 MB. I don't know what else I could look for to troubleshoot the issue. There's previous issues with the same error, but the solutions don't apply (like adding -resultBundlePath since we already have it).

Versions

XCLogParser: 0.2.32 Xcode: 13.1, 13.2.1, 13.3 beta 1

Script we're running

RESULT_BUNDLE_PATH="$HOME/Desktop/Neo.xcresult"
xcodebuild \
  -scheme Neo \
  clean

xcodebuild \
  -scheme Neo \
  -destination "platform=iOS Simulator,name=iPhone SE (2nd generation)" \
  -resultBundlePath "$RESULT_BUNDLE_PATH" \
  OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies -Xfrontend -debug-time-expression-type-checking" \
  build

sleep 10

xclogparser parse \
  --project Neo \
  --reporter html \
  --output ~/Desktop
ecamacho commented 2 years ago

Hi we also had the same issue when using the -debug-time-function-bodies and -debug-time-expression-type-checking flags with Xcode 13.x. For some reason Xcode was creating truncated log files. But somehow it's working now that we bumped to use Xcode 13.2.1. I'm pinging @aleksandergrzyb since he verified this recently, maybe he can have some insights about it.

aleksandergrzyb commented 2 years ago

Yes, it is a known problem. 😔 Currently I am investigating why it happens. I will give an update here if I would be able to figure out what's wrong.

aleksandergrzyb commented 2 years ago

We've noticed that in our case .xcactivitylog is invalid, because xcodebuild didn't finish creating it before exiting. Probably the process terminates, because it takes lots of time to generate .xcactivitylog in our case (it has over 50 MB). We solved this issue by executing clean action after build action to occupy xcodebuild process a little bit longer.

In your case please execute following and check if that helps:

xcodebuild \
  -scheme Neo \
  -destination "platform=iOS Simulator,name=iPhone SE (2nd generation)" \
  -resultBundlePath "$RESULT_BUNDLE_PATH" \
  OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies -Xfrontend -debug-time-expression-type-checking" \
  build clean
CraigSiemens commented 2 years ago

Interesting, that seems to work most of the time. Through sometimes it looks like the clean is removing the xcactivitylog of the build. It's not all the time though so I'm not sure if it's a race condition or if there's something else causing it.

This also meant that the xclogparser now starts grabbing the xcactivitylog from the clean since it's the newest log. I had to change our script to take the second newest file and pass it using the --file option.

But at least we've got some stats to work with now, thanks! But we're still slightly limited by another issue https://github.com/MobileNativeFoundation/XCLogParser/issues/148.

ecamacho commented 2 years ago

Closing this and moving the conversation to #148