Skip to content

Commit dbe3a2f

Browse files
committed
xcf : use check for visionos build version
This commit adds a check for the visionos build version used with vtool in build-xcframework.sh. The script now checks the Xcode version and determines whether to use "xros" or "visionos" for the build version. This commit also uses xcrun for the vtool so that the version of vtool in xcode command line tools is used instead of the one in the system path. Refs: ggml-org#2994 (comment)
1 parent b1f5c11 commit dbe3a2f

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

build-xcframework.sh

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ COMMON_CMAKE_ARGS=(
4141
-DGGML_OPENMP=${GGML_OPENMP}
4242
)
4343

44+
XCODE_VERSION=$(xcodebuild -version 2>/dev/null | head -n1 | awk '{ print $2 }')
45+
MAJOR_VERSION=$(echo $XCODE_VERSION | cut -d. -f1)
46+
MINOR_VERSION=$(echo $XCODE_VERSION | cut -d. -f2)
47+
echo "Detected Xcode version: $XCODE_VERSION"
48+
4449
check_required_tool() {
4550
local tool=$1
4651
local install_message=$2
@@ -335,21 +340,28 @@ combine_static_libraries() {
335340

336341
# Platform-specific post-processing for device builds
337342
if [[ "$is_simulator" == "false" ]]; then
338-
if command -v vtool &>/dev/null; then
343+
if command -v xcrun vtool &>/dev/null; then
339344
case "$platform" in
340345
"ios")
341346
echo "Marking binary as a framework binary for iOS..."
342-
vtool -set-build-version ios ${IOS_MIN_OS_VERSION} ${IOS_MIN_OS_VERSION} -replace \
347+
xcrun vtool -set-build-version ios ${IOS_MIN_OS_VERSION} ${IOS_MIN_OS_VERSION} -replace \
343348
-output "${base_dir}/${output_lib}" "${base_dir}/${output_lib}"
344349
;;
345350
"visionos")
346351
echo "Marking binary as a framework binary for visionOS..."
347-
vtool -set-build-version xros ${VISIONOS_MIN_OS_VERSION} ${VISIONOS_MIN_OS_VERSION} -replace \
352+
if [[ "$MAJOR_VERSION" -gt 16 ]] || [[ "$MAJOR_VERSION" -eq 16 && "$MINOR_VERSION" -gt 2 ]]; then
353+
echo "Xcode version greater than 16.2, using visionOS."
354+
VISION_OS_BUILD_VERSION="visionos"
355+
else
356+
echo "Xcode version less than or equal to 16.2, using xros."
357+
VISION_OS_BUILD_VERSION="xros"
358+
fi
359+
xcrun vtool -set-build-version ${VISION_OS_BUILD_VERSION} ${VISIONOS_MIN_OS_VERSION} ${VISIONOS_MIN_OS_VERSION} -replace \
348360
-output "${base_dir}/${output_lib}" "${base_dir}/${output_lib}"
349361
;;
350362
"tvos")
351363
echo "Marking binary as a framework binary for tvOS..."
352-
vtool -set-build-version tvos ${TVOS_MIN_OS_VERSION} ${TVOS_MIN_OS_VERSION} -replace \
364+
xcrun vtool -set-build-version tvos ${TVOS_MIN_OS_VERSION} ${TVOS_MIN_OS_VERSION} -replace \
353365
-output "${base_dir}/${output_lib}" "${base_dir}/${output_lib}"
354366
;;
355367
esac

0 commit comments

Comments
 (0)