Skip to content

Commit ed44129

Browse files
committed
Update build scripts: enhance ipabuild.sh with macOS support and improve Xcode selection in main.yml
1 parent c518bbd commit ed44129

3 files changed

Lines changed: 167 additions & 65 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,14 @@ jobs:
1919
outputs:
2020
artifact: ${{ env.scheme }}.ipa
2121
steps:
22-
- uses: maxim-lobanov/setup-xcode@v1
23-
with:
24-
xcode-version: '16.2'
2522
- name: Checkout
2623
uses: actions/checkout@v3
2724
with:
2825
submodules: recursive
26+
- name: Select Xcode
27+
run: sudo xcode-select -s /Applications/Xcode.app
28+
- name: show xcode version
29+
run: xcodebuild -version
2930
- name: Generate Xcode Project
3031
run: |
3132
if [ ! -f ${{ env.scheme }}.xcodeproj/project.pbxproj ]; then

ipabuild.sh

100644100755
Lines changed: 158 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,172 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
BUILD_MACOS=0
5+
for arg in "$@"; do
6+
case "$arg" in
7+
--macos)
8+
BUILD_MACOS=1
9+
;;
10+
-h|--help)
11+
echo "Usage: $0 [--macos]"
12+
echo " --macos Build the Mac Catalyst .app into dist/"
13+
exit 0
14+
;;
15+
*)
16+
echo "Unknown argument: $arg" >&2
17+
echo "Usage: $0 [--macos]" >&2
18+
exit 2
19+
;;
20+
esac
21+
done
22+
23+
PROJECT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
24+
SCHEME="lara"
25+
CONFIGURATION="Release"
26+
APP_NAME="lara"
27+
DIST_DIR="$PROJECT_DIR/dist"
28+
PAYLOAD_DIR="$DIST_DIR/Payload"
29+
IPA_PATH="$DIST_DIR/${APP_NAME}.ipa"
30+
DERIVED_DATA_DIR="$PROJECT_DIR/build/DerivedData"
31+
32+
SDK="iphoneos"
33+
DESTINATION="generic/platform=iOS"
34+
PRODUCT_SUBDIR="${CONFIGURATION}-iphoneos"
35+
if [[ "$BUILD_MACOS" == "1" ]]; then
36+
SDK="macosx"
37+
DESTINATION="platform=macOS,variant=Mac Catalyst"
38+
PRODUCT_SUBDIR="${CONFIGURATION}-maccatalyst"
39+
fi
240

41+
LARA_LDID_SIGN="${LARA_LDID_SIGN:-1}"
42+
LARA_LDID_ENTITLEMENTS="${LARA_LDID_ENTITLEMENTS:-$PROJECT_DIR/Config/lara.entitlements}"
43+
44+
rm -rf "$DIST_DIR" "$PROJECT_DIR/build"
45+
46+
XCODEBUILD_LOG="$PROJECT_DIR/build/xcodebuild.log"
47+
mkdir -p "$(dirname "$XCODEBUILD_LOG")"
48+
rm -f "$XCODEBUILD_LOG"
49+
50+
run_xcodebuild() {
51+
local destination="$1"
52+
xcodebuild \
53+
-project "$PROJECT_DIR/lara.xcodeproj" \
54+
-scheme "$SCHEME" \
55+
-configuration "$CONFIGURATION" \
56+
-sdk "$SDK" \
57+
-destination "$destination" \
58+
-derivedDataPath "$DERIVED_DATA_DIR" \
59+
build \
60+
CODE_SIGNING_ALLOWED=NO \
61+
CODE_SIGNING_REQUIRED=NO \
62+
CODE_SIGN_STYLE=Manual \
63+
ASSETCATALOG_COMPILER_APPICON_NAME="" \
64+
ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME="" \
65+
ASSETCATALOG_COMPILER_GENERATE_SWIFT_ASSET_SYMBOL_EXTENSIONS=NO \
66+
ENABLE_ON_DEMAND_RESOURCES=NO
67+
}
68+
69+
prepare_maccatalyst_linker_path_workaround() {
70+
local products_dir="$DERIVED_DATA_DIR/Build/Products"
71+
local intermediates_dir="$DERIVED_DATA_DIR/Build/Intermediates.noindex"
72+
73+
mkdir -p "$products_dir"
74+
if [[ ! -e "$products_dir/Release" ]]; then
75+
ln -s "Release-maccatalyst" "$products_dir/Release"
76+
fi
77+
78+
local pkg
79+
for pkg in ZIPFoundation SWCompression BitByteData; do
80+
local release_dir="$intermediates_dir/${pkg}.build/Release"
81+
local macabi_dir="$intermediates_dir/${pkg}.build/Release-maccatalyst"
82+
mkdir -p "$release_dir"
83+
if [[ -d "$macabi_dir" && ! -e "$release_dir/${pkg}.build" ]]; then
84+
ln -s "../Release-maccatalyst/${pkg}.build" "$release_dir/${pkg}.build"
85+
fi
86+
done
87+
}
88+
89+
set +e
90+
if [[ "$BUILD_MACOS" == "1" ]]; then
91+
echo "Building with destination: $DESTINATION"
92+
run_xcodebuild "$DESTINATION" 2>&1 | tee "$XCODEBUILD_LOG"
93+
XCODEBUILD_STATUS=${PIPESTATUS[0]}
94+
if [[ $XCODEBUILD_STATUS -ne 0 ]] && grep -q "Build input files cannot be found" "$XCODEBUILD_LOG"; then
95+
echo "Retrying macOS build with linker path workaround for Swift package object products"
96+
prepare_maccatalyst_linker_path_workaround
97+
run_xcodebuild "$DESTINATION" 2>&1 | tee "$XCODEBUILD_LOG"
98+
XCODEBUILD_STATUS=${PIPESTATUS[0]}
99+
fi
100+
else
101+
run_xcodebuild "$DESTINATION" 2>&1 | tee "$XCODEBUILD_LOG"
102+
XCODEBUILD_STATUS=${PIPESTATUS[0]}
103+
fi
3104
set -e
4105

5-
cd "$(dirname "$0")"
6-
7-
APPLICATION_NAME="lara"
8-
9-
echo "[*] $APPLICATION_NAME Build Script"
10-
11-
rm -rf build
12-
13-
if ls *.ipa 1> /dev/null 2>&1; then
14-
rm -rf *.ipa
106+
if [[ $XCODEBUILD_STATUS -ne 0 ]]; then
107+
echo "ERROR: xcodebuild failed (exit $XCODEBUILD_STATUS). Log: $XCODEBUILD_LOG" >&2
108+
echo "--- Last 200 lines ---" >&2
109+
tail -n 200 "$XCODEBUILD_LOG" >&2 || true
110+
exit "$XCODEBUILD_STATUS"
15111
fi
16112

17-
WORKING_LOCATION="$(pwd)"
113+
APP_DIR="$DERIVED_DATA_DIR/Build/Products/${PRODUCT_SUBDIR}/${APP_NAME}.app"
114+
if [[ ! -d "$APP_DIR" ]]; then
115+
echo "ERROR: Could not find built ${APP_NAME}.app at: $APP_DIR" >&2
116+
exit 1
117+
fi
18118

19-
if [ ! -d "build" ]; then
20-
mkdir build
119+
if [[ "$BUILD_MACOS" == "1" ]]; then
120+
mkdir -p "$DIST_DIR"
121+
DEST_APP="$DIST_DIR/${APP_NAME}.app"
122+
rm -rf "$DEST_APP"
123+
if command -v rsync >/dev/null 2>&1; then
124+
rsync -aL --delete "$APP_DIR/" "$DEST_APP/"
125+
else
126+
mkdir -p "$DEST_APP"
127+
cp -aL "$APP_DIR/." "$DEST_APP/"
128+
fi
129+
130+
echo "Created: $DEST_APP"
131+
echo "macOS app built successfully"
132+
exit 0
21133
fi
22134

23-
cd build
24-
25-
echo "[*] Building..."
26-
if [[ $* == *--debug* ]]; then
27-
xcodebuild -project "$WORKING_LOCATION/$APPLICATION_NAME.xcodeproj" \
28-
-scheme "$APPLICATION_NAME" \
29-
-configuration Debug \
30-
-derivedDataPath "$WORKING_LOCATION/build/DerivedDataApp" \
31-
-destination "generic/platform=${PLATFORM}" \
32-
clean build \
33-
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"
34-
35-
DD_APP_PATH="$WORKING_LOCATION/build/DerivedDataApp/Build/Products/Debug-iphoneos/$APPLICATION_NAME.app"
36-
TARGET_APP="$WORKING_LOCATION/build/$APPLICATION_NAME.app"
37-
cp -r "$DD_APP_PATH" "$TARGET_APP"
135+
mkdir -p "$PAYLOAD_DIR"
136+
rm -rf "$PAYLOAD_DIR"/*
137+
138+
DEST_APP="$PAYLOAD_DIR/${APP_NAME}.app"
139+
if command -v rsync >/dev/null 2>&1; then
140+
rsync -aL --delete "$APP_DIR/" "$DEST_APP/"
38141
else
39-
xcodebuild -project "$WORKING_LOCATION/$APPLICATION_NAME.xcodeproj" \
40-
-scheme "$APPLICATION_NAME" \
41-
-configuration Release \
42-
-derivedDataPath "$WORKING_LOCATION/build/DerivedDataApp" \
43-
-destination 'generic/platform=iOS' \
44-
clean build \
45-
CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO CODE_SIGN_ENTITLEMENTS="" CODE_SIGNING_ALLOWED="NO"
46-
47-
DD_APP_PATH="$WORKING_LOCATION/build/DerivedDataApp/Build/Products/Release-iphoneos/$APPLICATION_NAME.app"
48-
TARGET_APP="$WORKING_LOCATION/build/$APPLICATION_NAME.app"
49-
cp -r "$DD_APP_PATH" "$TARGET_APP"
142+
mkdir -p "$DEST_APP"
143+
cp -aL "$APP_DIR/." "$DEST_APP/"
50144
fi
51145

52-
echo "[*] Stripping signature..."
53-
codesign --remove "$TARGET_APP"
54-
if [ -e "$TARGET_APP/_CodeSignature" ]; then
55-
rm -rf "$TARGET_APP/_CodeSignature"
56-
fi
57-
if [ -e "$TARGET_APP/embedded.mobileprovision" ]; then
58-
rm -rf "$TARGET_APP/embedded.mobileprovision"
146+
rm -rf "$DEST_APP/_CodeSignature" "$DEST_APP/embedded.mobileprovision" || true
147+
148+
# Ensure UIFileSharingEnabled is present (Xcode 26 build system drops this INFOPLIST_KEY_ setting)
149+
plutil -replace UIFileSharingEnabled -bool YES "$DEST_APP/Info.plist"
150+
151+
if [[ "$LARA_LDID_SIGN" == "1" ]]; then
152+
if ! command -v ldid >/dev/null 2>&1; then
153+
echo "ERROR: LARA_LDID_SIGN=1 but 'ldid' is not installed. Try: brew install ldid" >&2
154+
exit 1
155+
fi
156+
if [[ ! -f "$LARA_LDID_ENTITLEMENTS" ]]; then
157+
echo "ERROR: Entitlements file not found: $LARA_LDID_ENTITLEMENTS" >&2
158+
exit 1
159+
fi
160+
echo "Signing $APP_NAME executable with ldid entitlements: $LARA_LDID_ENTITLEMENTS"
161+
ldid -S"$LARA_LDID_ENTITLEMENTS" "$DEST_APP/$APP_NAME"
59162
fi
60163

61-
echo "[*] Packaging..."
62-
mkdir Payload
63-
cp -r $APPLICATION_NAME.app Payload/$APPLICATION_NAME.app
64-
zip -vr $APPLICATION_NAME.ipa Payload
164+
mkdir -p "$DIST_DIR"
165+
rm -f "$IPA_PATH"
166+
(
167+
cd "$DIST_DIR"
168+
/usr/bin/zip -qr "$IPA_PATH" "Payload"
169+
)
65170

66-
echo "[*] All done, cleaning up..."
67-
rm -rf Payload
68-
69-
cd ..
70-
if [[ $* == *--debug* ]]; then
71-
mv "$WORKING_LOCATION/build/$APPLICATION_NAME.ipa" ./$APPLICATION_NAME.debug.ipa
72-
else
73-
mv "$WORKING_LOCATION/build/$APPLICATION_NAME.ipa" .
74-
fi
75-
rm -rf "$WORKING_LOCATION/build/"
171+
echo "Created: $IPA_PATH"
172+
echo "IPA built successfully"

project.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ targets:
1111
platform: iOS
1212

1313
sources:
14-
- path: lara
14+
- path: lara - name: Select Xcode
15+
run: sudo xcode-select -s /Applications/Xcode.app
16+
17+
- name: show xcode version
18+
run: xcodebuild -version
1519

1620
resources:
1721
- path: lara/fonts

0 commit comments

Comments
 (0)