@@ -12,6 +12,7 @@ COMPILE_DIR="${TARGET_BUILD_DIR}/LibSessionUtil"
1212INDEX_DIR=" ${DERIVED_DATA_PATH} /Index.noindex/Build/Products/Debug-${PLATFORM_NAME} "
1313LAST_SUCCESSFUL_HASH_FILE=" ${TARGET_BUILD_DIR} /last_successful_source_tree.hash.log"
1414LAST_BUILT_FRAMEWORK_SLICE_DIR_FILE=" ${TARGET_BUILD_DIR} /last_built_framework_slice_dir.log"
15+ TIMESTAMP_FILE=" ${TARGET_BUILD_DIR} /LibSessionUtil_BuildCache/libsession_util_built.timestamp"
1516
1617# Modify the platform detection to handle archive builds
1718if [ " ${ACTION} " = " install" ] || [ " ${CONFIGURATION} " = " Release" ]; then
@@ -44,14 +45,14 @@ sync_headers() {
4445 for dest in " ${destinations[@]} " ; do
4546 if [ -n " $dest " ]; then
4647 local unique_id=$( uuidgen)
47- local temp_dest=" ${BUILD_DIR} /headers_staging_$( unique_id) "
48+ local temp_dest=" ${BUILD_DIR} /headers_staging_${ unique_id} "
4849 rm -rf " $temp_dest "
4950 mkdir -p " $temp_dest "
5051
5152 rsync -rtc --delete --exclude=' .DS_Store' " ${source_dir} /" " $temp_dest /"
5253
5354 # Atomically move the old directory out of the way
54- local old_dest=" ${BUILD_DIR} /headers_old_$( unique_id) "
55+ local old_dest=" ${BUILD_DIR} /headers_old_${ unique_id} "
5556 if [ -d " $dest " ]; then
5657 mv " $dest " " $old_dest "
5758 fi
@@ -71,6 +72,27 @@ sync_headers() {
7172 done
7273}
7374
75+ # Robustly removes a directory, first clearing any immutable flags (work around Xcode's indexer file locking)
76+ remove_locked_dir () {
77+ local dir_to_remove=" $1 "
78+ if [ -d " ${dir_to_remove} " ]; then
79+ echo " - Unlocking and removing ${dir_to_remove} "
80+ chflags -R nouchg " ${dir_to_remove} " & > /dev/null || true
81+ rm -rf " ${dir_to_remove} "
82+ fi
83+ }
84+
85+ # Modify the platform detection to handle archive builds
86+ if [ " ${ACTION} " = " install" ] || [ " ${CONFIGURATION} " = " Release" ]; then
87+ # Archive builds typically use 'install' action
88+ if [ -z " $PLATFORM_NAME " ]; then
89+ # During archive, PLATFORM_NAME might not be set correctly
90+ # Default to device build for archives
91+ PLATFORM_NAME=" iphoneos"
92+ echo " Missing 'PLATFORM_NAME' value, manually set to ${PLATFORM_NAME} "
93+ fi
94+ fi
95+
7496# Determine whether we want to build from source
7597TARGET_ARCH_DIR=" "
7698
86108if [ " ${COMPILE_LIB_SESSION} " != " YES" ]; then
87109 echo " Using pre-packaged SessionUtil"
88110
89- if [ " $CI " = " true" ] || [ " $DRONE " = " true" ]; then
111+ if [ " $CI " = " true" ] || [ " $DRONE " = " true" ]; then
90112 # In CI, Xcode's SPM integration is reliable. Skip manual header sync
91113 # to avoid the 'redefinition of module' error.
92114 echo " - CI environment detected, skipping manual header sync to rely on SPM"
@@ -98,6 +120,10 @@ if [ "${COMPILE_LIB_SESSION}" != "YES" ]; then
98120 # Create the placeholder in the FINAL products directory to satisfy dependency
99121 touch " ${BUILT_PRODUCTS_DIR} /libsession-util.a"
100122
123+ # Create the timestamp file to satisfy Xcode's output file requirement
124+ mkdir -p " $( dirname " ${TIMESTAMP_FILE} " ) "
125+ echo " Using SPM pre-built version at $( date) " > " ${TIMESTAMP_FILE} "
126+
101127 echo " - Revert to SPM complete."
102128 exit 0
103129fi
186212fi
187213
188214if [ " ${REQUIRES_BUILD} " == 1 ]; then
215+
189216 # Import settings from XCode (defaulting values if not present)
190217 VALID_SIM_ARCHS=(arm64 x86_64)
191218 VALID_DEVICE_ARCHS=(arm64)
@@ -272,6 +299,8 @@ if [ "${REQUIRES_BUILD}" == 1 ]; then
272299 -DBUILD_TESTS=OFF \
273300 -DBUILD_STATIC_DEPS=ON \
274301 -DENABLE_VISIBILITY=ON \
302+ -DSROUTER_FULL=OFF \
303+ -DSROUTER_DAEMON=OFF \
275304 -DSUBMODULE_CHECK=$submodule_check \
276305 -DCMAKE_BUILD_TYPE=$build_type \
277306 -DLOCAL_MIRROR=https://oxen.rocks/deps
@@ -332,7 +361,7 @@ if [ "${REQUIRES_BUILD}" == 1 ]; then
332361 echo " - Saving successful build cache files"
333362 echo " ${TARGET_ARCH_DIR} " > " ${LAST_BUILT_FRAMEWORK_SLICE_DIR_FILE} "
334363 echo " ${CURRENT_SOURCE_TREE_HASH} " > " ${LAST_SUCCESSFUL_HASH_FILE} "
335-
364+
336365 echo " - Build complete"
337366fi
338367
351380sync_headers " ${COMPILE_DIR} /Headers/"
352381echo " - Sync complete."
353382
383+ # Update the timestamp to indicate build completed
384+ mkdir -p " $( dirname " ${TIMESTAMP_FILE} " ) "
385+ echo " Built from source at $( date) " > " ${TIMESTAMP_FILE} "
386+
354387# Output to XCode just so the output is good
355388echo " LibSession is Ready"
0 commit comments