Skip to content

Commit ab6afc9

Browse files
committed
fix: Improve xcodebuild docbuild command for Swift packages
- Try generating Xcode project first - Fallback to direct package build if scheme doesn't work - Better error handling
1 parent 3d8b3db commit ab6afc9

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

scripts/publish-docc-to-github-pages.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,21 @@ mkdir -p "$DOCBUILD_DIR"
7373

7474
# Build documentation using xcodebuild docbuild
7575
echo "Building documentation with xcodebuild..."
76-
# For Swift packages, we need to use -packagePath instead of -scheme
76+
# First, generate an Xcode project if it doesn't exist
77+
if [ ! -f "$REPO_ROOT/${PACKAGE_NAME}.xcodeproj/project.pbxproj" ]; then
78+
echo "Generating Xcode project..."
79+
cd "$REPO_ROOT"
80+
swift package generate-xcodeproj 2>/dev/null || {
81+
echo "Note: generate-xcodeproj may not be available, trying direct build..."
82+
}
83+
fi
84+
85+
# Build documentation - try with scheme first, then with package
7786
if xcodebuild docbuild \
87+
-scheme "$PACKAGE_NAME" \
88+
-derivedDataPath "$DOCBUILD_DIR" \
89+
-destination 'generic/platform=macOS' 2>&1 || \
90+
xcodebuild docbuild \
7891
-packagePath "$REPO_ROOT" \
7992
-derivedDataPath "$DOCBUILD_DIR" \
8093
-destination 'generic/platform=macOS' 2>&1; then

0 commit comments

Comments
 (0)