MobileNativeFoundation / XCLogParser

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

Invalid or no xcactivitylog file #107

Closed birwin93 closed 2 years ago

birwin93 commented 3 years ago

Looks like there were some previous posts but none of the existing suggestions seem to work for.

Versions

Xcode 11.5

Problem

Running the following command leads to no xcactivitlylog being generated

set -o pipefail && env NSUnbufferedIO=YES xcodebuild clean build \
    -project Project.xcodeproj \
    -scheme 'Development' \
    -configuration Debug  \
    -derivedDataPath /tmp/test_build

Running the following command generates a xcactivitlylog but running xclogparser parse throws an error saying is not a valid xcactivitylog file. This just add -resultBundlePath

set -o pipefail && env NSUnbufferedIO=YES xcodebuild clean build \
    -project Project.xcodeproj \
    -scheme 'Development' \
    -configuration Debug  \
    -derivedDataPath /tmp/test_build
     -resultBundlePath /tmp/test_build/result_bundle

What's even weirder, is if I rerun the second command, it then produces a valid xcactivitylog. I've been able to repro that behavior twice now.

Is there something I should be doing here? I've also confirmed that waiting a few minutes to run xclogparser doesn't fix the problem

birwin93 commented 3 years ago

Seems like the is not valid xcativitylog file is due to issues when unzipping the log. Setup some breakpoints and it looks like gzip library is throwing an error correlating to

// Z_STREAM_ERROR The stream structure was inconsistent (for example if next_in or next_out was NULL).
ecamacho commented 3 years ago

Hi! Yes, Xcode can take a while to dump the log into the file. So if you read the file before Xcode finishes, you get that error. What we do is to wait a few seconds before reading it, and if we got the error, we retry a few more times.

akkrat commented 3 years ago

The issue still reproduces on Xcode 12.1. Output logs from Xcode's Build command are parseable, but from xcodebuild -archive isn't. Archive's logs are smaller than those were build with Xcode (1 MB vs 13 MB). I validate logs withgzip -t ...

ptrkstr commented 3 years ago

I'm having the same issue on Xcode 12.4 in large projects but smaller projects work fine. Even when both use xcodebuild.

ptrkstr commented 3 years ago

I've switched to using Xcode directly to build instead of xcodebuild and that works. I do need to wait a few seconds after the build is finished before running xclogparser.