Is it possible to run jazzy as a phase of XCode Build Phases?
satroschenko opened this issue · 3 comments
If I add a new Run script phase
in XCode to run jazzy I get an error:
error: unable to attach DB: error: accessing build database ".../Build/Intermediates.noindex/XCBuildData/build.db": database is locked Possibly there are two concurrent builds running in the same filesystem location.
Is it possible to run jazzy in this way?
Well, jazzy does run xcodebuild
under the covers to figure out what to document so I guess I can understand where the Xcode error message here is coming from.
You could maybe explore having jazzy use a different DerivedData
directory than your main build with --build-tool-arguments
and -derivedDataPath
but it's kind of a shame to build it again; or try using jazzy in symbol graph mode against your swiftmodule?
Thanks a lot. Yes, the first variant with different DerivedData
works with some improvements.
Initially I added new Build Phase
. It runs jazzy
. Jazzy
run new build. New build runs jazzy
again and I had infinite recursion.
Had to add some checking for it.
As result I have following script:
#!/bin/bash
# Check is jazzy already running to remove recursion.
if [ -z $(printenv SKIP_JAZZY) ]; then
echo "jazzy starts..."
else
echo "Jazzy is already running. Skip this step."
exit 0
fi
export SKIP_JAZZY=1
TEMP_DERIVED_DIR=$(mktemp -d)
# Clean temp dir when script exits.
trap "rm -rf $TEMP_DERIVED_DIR" EXIT
jazzy --xcodebuild-arguments -derivedDataPath,$TEMP_DERIVED_DIR
infinite recursion
Oh haha, should have seen that coming! Glad you got it working.