char-fork/llama.cpp
git clone https://git.t4t.associates/char-fork/llama.cpp
e9b6350e6
char/aliceai-t5-moe
1#!/usr/bin/env bash 2# validate-visionos.sh - Validate visionOS Application with embedded llama.xcframework using SwiftUI 3 4# Authentication options (optional) (can be set via environment variables) 5# To use: export APPLE_ID=your.email@example.com 6# export APPLE_PASSWORD=your-app-specific-password 7# ./validate-visionos.sh 8APPLE_ID =${ APPLE_ID :- "" } 9APPLE_PASSWORD =${ APPLE_PASSWORD :- "" } 10 11# Ensure the script exits on error 12set -e 13 14# Function to print usage instructions 15print_usage () { 16echo "Usage: ./validate-visionos.sh [OPTIONS]" 17echo "" 18echo "Options:" 19echo " --help Show this help message" 20echo " --apple-id EMAIL Apple ID email for validation" 21echo " --apple-password PWD App-specific password for Apple ID" 22echo "" 23echo "Environment variables:" 24echo " APPLE_ID Apple ID email for validation" 25echo " APPLE_PASSWORD App-specific password for Apple ID" 26echo "" 27echo "Notes:" 28echo " - Command line options take precedence over environment variables" 29echo " - Authentication is optional. If not provided, alternative validation will be performed" 30echo " - For APPLE_PASSWORD, use an app-specific password generated at https://appleid.apple.com/account/manage" 31} 32 33# Parse command line arguments 34while [[$ # -gt 0 ]];do 35case $ 1 in 36 --help) 37print_usage 38exit 0 39 ;; 40 --apple-id) 41APPLE_ID =" $ 2 " 42shift 2 43 ;; 44 --apple-password) 45APPLE_PASSWORD =" $ 2 " 46shift 2 47 ;; 48 *) 49echo "Unknown option: $ 1 " 50print_usage 51exit 1 52 ;; 53esac 54done 55 56# Function to clean up in case of error 57cleanup () { 58# Don't clean up temp files on error to help with debugging 59echo "===== visionOS Validation Process Failed =====" 60exit 1 61} 62 63# Set up trap to call cleanup function on error 64trap cleanup ERR 65 66set -e # Exit on any error 67 68ROOT_DIR =" $( cd " $( dirname " ${ BASH_SOURCE [0]} " ) /../.." && pwd ) " 69BUILD_DIR =" ${ ROOT_DIR } /validation-builds/visionos" 70 71# Configuration 72APP_NAME ="VisionOSLlamaTest" 73BUNDLE_ID ="org.ggml.VisionOSLlamaTest" 74XCFRAMEWORK_PATH =" ${ ROOT_DIR } /build-apple/llama.xcframework" 75TEMP_DIR =" ${ BUILD_DIR } /temp" 76ARCHIVE_PATH =" ${ BUILD_DIR } / ${ APP_NAME } .xcarchive" 77IPA_PATH =" ${ BUILD_DIR } / ${ APP_NAME } .ipa" 78VALIDATION_DIR =" ${ BUILD_DIR } /validation" 79 80# Create necessary directories 81mkdir -p " ${ BUILD_DIR } " 82mkdir -p " ${ TEMP_DIR } " 83mkdir -p " ${ VALIDATION_DIR } " 84 85echo "===== visionOS Validation Process Started =====" 86 87# 1. Create a simple test app project 88echo "Creating test visionOS app project..." 89mkdir -p " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } " 90cat > " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } /Info.plist" <<EOF 91<?xml version="1.0" encoding="UTF-8"?> 92<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 93<plist version="1.0"> 94<dict> 95<key>CFBundleDevelopmentRegion</key> 96<string>en</string> 97<key>CFBundleExecutable</key> 98<string> ${ APP_NAME } </string> 99<key>CFBundleIdentifier</key> 100<string> ${ BUNDLE_ID } </string> 101<key>CFBundleInfoDictionaryVersion</key> 102<string>6.0</string> 103<key>CFBundleName</key> 104<string> ${ APP_NAME } </string> 105<key>CFBundlePackageType</key> 106<string>APPL</string> 107<key>CFBundleShortVersionString</key> 108<string>1.0</string> 109<key>CFBundleVersion</key> 110<string>1</string> 111</dict> 112</plist> 113EOF 114 115# Create SwiftUI app files 116mkdir -p " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } /Sources" 117 118# Create App.swift 119cat > " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } /Sources/App.swift" <<EOF 120import SwiftUI 121import llama 122 123@main 124struct LlamaTestApp: App { 125var body: some Scene { 126WindowGroup { 127ContentView() 128} 129} 130} 131EOF 132 133# Create ContentView.swift with visionOS specific elements 134cat > " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } /Sources/ContentView.swift" <<EOF 135import SwiftUI 136import llama 137 138struct ContentView: View { 139// Test that we can initialize a llama context params struct 140let params = llama_context_default_params() 141 142var body: some View { 143VStack(spacing: 20) { 144Text("Llama Framework Test on visionOS") 145.font(.largeTitle) 146.padding() 147 148Text("llama_context_default_params() created successfully") 149.font(.headline) 150.multilineTextAlignment(.center) 151.padding() 152 153// Display some param values to confirm the framework is working 154Text("n_ctx: \(params.n_ctx)") 155.font(.body) 156 157Text("n_batch: \(params.n_batch)") 158.font(.body) 159 160Spacer() 161} 162.padding() 163.frame(width: 500, height: 400) 164} 165} 166 167struct ContentView_Previews: PreviewProvider { 168static var previews: some View { 169ContentView() 170} 171} 172EOF 173 174# Create project.pbxproj, fixing the framework search paths issues 175mkdir -p " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj" 176cat > " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj/project.pbxproj" <<'EOF' 177// !$*UTF8*$! 178{ 179archiveVersion = 1; 180classes = { 181}; 182objectVersion = 54; 183objects = { 184 185/* Begin PBXBuildFile section */ 18611111111111111111111111 /* App.swift in Sources */ = {isa = PBXBuildFile; fileRef = 22222222222222222222222; }; 18733333333333333333333333 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44444444444444444444444; }; 18855555555555555555555555 /* llama.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66666666666666666666666; }; 18977777777777777777777777 /* llama.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 66666666666666666666666; }; 190/* End PBXBuildFile section */ 191 192/* Begin PBXCopyFilesBuildPhase section */ 19388888888888888888888888 /* Embed Frameworks */ = { 194isa = PBXCopyFilesBuildPhase; 195buildActionMask = 2147483647; 196dstPath = ""; 197dstSubfolderSpec = 10; 198files = ( 19977777777777777777777777 /* llama.xcframework in Embed Frameworks */, 200); 201name = "Embed Frameworks"; 202runOnlyForDeploymentPostprocessing = 0; 203}; 204/* End PBXCopyFilesBuildPhase section */ 205 206/* Begin PBXFileReference section */ 207EOF 208 209# Continue with the project.pbxproj file, using the APP_NAME variable appropriately 210cat >> " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj/project.pbxproj" <<EOF 21199999999999999999999999 /* ${ APP_NAME } .app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = " ${ APP_NAME } .app"; sourceTree = BUILT_PRODUCTS_DIR; }; 21222222222222222222222222 /* App.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = App.swift; sourceTree = "<group>"; }; 21344444444444444444444444 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; }; 214AAAAAAAAAAAAAAAAAAAAAAA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; 21566666666666666666666666 /* llama.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; path = llama.xcframework; sourceTree = "<group>"; }; 216/* End PBXFileReference section */ 217EOF 218 219# Add the rest of the project file with fixed framework search paths 220cat >> " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj/project.pbxproj" <<'EOF' 221/* Begin PBXFrameworksBuildPhase section */ 222BBBBBBBBBBBBBBBBBBBBBBBB /* Frameworks */ = { 223isa = PBXFrameworksBuildPhase; 224buildActionMask = 2147483647; 225files = ( 22655555555555555555555555 /* llama.xcframework in Frameworks */, 227); 228runOnlyForDeploymentPostprocessing = 0; 229}; 230/* End PBXFrameworksBuildPhase section */ 231 232/* Begin PBXGroup section */ 233EOF 234 235# Continue with the project.pbxproj file, using the APP_NAME variable appropriately 236cat >> " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj/project.pbxproj" <<EOF 237CCCCCCCCCCCCCCCCCCCCCCCC /* Products */ = { 238isa = PBXGroup; 239children = ( 24099999999999999999999999 /* ${ APP_NAME } .app */, 241); 242name = Products; 243sourceTree = "<group>"; 244}; 245EOF 246 247cat >> " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj/project.pbxproj" <<'EOF' 248DDDDDDDDDDDDDDDDDDDDDDDD /* Frameworks */ = { 249isa = PBXGroup; 250children = ( 25166666666666666666666666 /* llama.xcframework */, 252); 253name = Frameworks; 254sourceTree = "<group>"; 255}; 256EEEEEEEEEEEEEEEEEEEEEEEE = { 257isa = PBXGroup; 258children = ( 259FFFFFFFFFFFFFFFFFFFFFFFF /* VisionOSLlamaTest */, 260CCCCCCCCCCCCCCCCCCCCCCCC /* Products */, 261DDDDDDDDDDDDDDDDDDDDDDDD /* Frameworks */, 262); 263sourceTree = "<group>"; 264}; 265FFFFFFFFFFFFFFFFFFFFFFFF /* VisionOSLlamaTest */ = { 266isa = PBXGroup; 267children = ( 2681111111111111111111111AA /* Sources */, 269AAAAAAAAAAAAAAAAAAAAAAA /* Info.plist */, 270); 271path = "VisionOSLlamaTest"; 272sourceTree = "<group>"; 273}; 2741111111111111111111111AA /* Sources */ = { 275isa = PBXGroup; 276children = ( 27722222222222222222222222 /* App.swift */, 27844444444444444444444444 /* ContentView.swift */, 279); 280path = Sources; 281sourceTree = "<group>"; 282}; 283/* End PBXGroup section */ 284EOF 285 286# Continue with the project.pbxproj file, using the APP_NAME variable appropriately 287cat >> " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj/project.pbxproj" <<EOF 288/* Begin PBXNativeTarget section */ 2893333333333333333333333AA /* ${ APP_NAME } */ = { 290isa = PBXNativeTarget; 291buildConfigurationList = 4444444444444444444444AA /* Build configuration list for PBXNativeTarget " ${ APP_NAME } " */; 292buildPhases = ( 2935555555555555555555555AA /* Sources */, 294BBBBBBBBBBBBBBBBBBBBBBBB /* Frameworks */, 2956666666666666666666666AA /* Resources */, 29688888888888888888888888 /* Embed Frameworks */, 297); 298buildRules = ( 299); 300dependencies = ( 301); 302name = " ${ APP_NAME } "; 303productName = " ${ APP_NAME } "; 304productReference = 99999999999999999999999 /* ${ APP_NAME } .app */; 305productType = "com.apple.product-type.application"; 306}; 307/* End PBXNativeTarget section */ 308 309/* Begin PBXProject section */ 3107777777777777777777777AA /* Project object */ = { 311isa = PBXProject; 312attributes = { 313LastSwiftUpdateCheck = 1510; 314LastUpgradeCheck = 1510; 315TargetAttributes = { 3163333333333333333333333AA = { 317CreatedOnToolsVersion = 15.1; 318}; 319}; 320}; 321buildConfigurationList = 8888888888888888888888AA /* Build configuration list for PBXProject " ${ APP_NAME } " */; 322compatibilityVersion = "Xcode 15.0"; 323developmentRegion = en; 324hasScannedForEncodings = 0; 325knownRegions = ( 326en, 327Base, 328); 329mainGroup = EEEEEEEEEEEEEEEEEEEEEEEE; 330productRefGroup = CCCCCCCCCCCCCCCCCCCCCCCC /* Products */; 331projectDirPath = ""; 332projectRoot = ""; 333targets = ( 3343333333333333333333333AA /* ${ APP_NAME } */, 335); 336}; 337/* End PBXProject section */ 338EOF 339 340# Add the rest of the file with correct FRAMEWORK_SEARCH_PATHS 341cat >> " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj/project.pbxproj" <<'EOF' 342/* Begin PBXResourcesBuildPhase section */ 3436666666666666666666666AA /* Resources */ = { 344isa = PBXResourcesBuildPhase; 345buildActionMask = 2147483647; 346files = ( 347); 348runOnlyForDeploymentPostprocessing = 0; 349}; 350/* End PBXResourcesBuildPhase section */ 351 352/* Begin PBXSourcesBuildPhase section */ 3535555555555555555555555AA /* Sources */ = { 354isa = PBXSourcesBuildPhase; 355buildActionMask = 2147483647; 356files = ( 35733333333333333333333333 /* ContentView.swift in Sources */, 35811111111111111111111111 /* App.swift in Sources */, 359); 360runOnlyForDeploymentPostprocessing = 0; 361}; 362/* End PBXSourcesBuildPhase section */ 363 364/* Begin XCBuildConfiguration section */ 3659999999999999999999999AA /* Debug */ = { 366isa = XCBuildConfiguration; 367buildSettings = { 368ALWAYS_SEARCH_USER_PATHS = NO; 369CLANG_ANALYZER_NONNULL = YES; 370CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 371CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 372CLANG_CXX_LIBRARY = "libc++"; 373CLANG_ENABLE_MODULES = YES; 374CLANG_ENABLE_OBJC_ARC = YES; 375CLANG_ENABLE_OBJC_WEAK = YES; 376CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 377CLANG_WARN_BOOL_CONVERSION = YES; 378CLANG_WARN_COMMA = YES; 379CLANG_WARN_CONSTANT_CONVERSION = YES; 380CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 381CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 382CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 383CLANG_WARN_EMPTY_BODY = YES; 384CLANG_WARN_ENUM_CONVERSION = YES; 385CLANG_WARN_INFINITE_RECURSION = YES; 386CLANG_WARN_INT_CONVERSION = YES; 387CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 388CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 389CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 390CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 391CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 392CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 393CLANG_WARN_STRICT_PROTOTYPES = YES; 394CLANG_WARN_SUSPICIOUS_MOVE = YES; 395CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 396CLANG_WARN_UNREACHABLE_CODE = YES; 397CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 398COPY_PHASE_STRIP = NO; 399DEBUG_INFORMATION_FORMAT = dwarf; 400ENABLE_STRICT_OBJC_MSGSEND = YES; 401ENABLE_TESTABILITY = YES; 402GCC_C_LANGUAGE_STANDARD = gnu11; 403GCC_DYNAMIC_NO_PIC = NO; 404GCC_NO_COMMON_BLOCKS = YES; 405GCC_OPTIMIZATION_LEVEL = 0; 406GCC_PREPROCESSOR_DEFINITIONS = ( 407"DEBUG=1", 408"$(inherited)", 409); 410GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 411GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 412GCC_WARN_UNDECLARED_SELECTOR = YES; 413GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 414GCC_WARN_UNUSED_FUNCTION = YES; 415GCC_WARN_UNUSED_VARIABLE = YES; 416MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; 417MTL_FAST_MATH = YES; 418ONLY_ACTIVE_ARCH = YES; 419SDKROOT = xros; 420SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 421SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 422XROS_DEPLOYMENT_TARGET = 1.0; 423}; 424name = Debug; 425}; 426AAAAAAAAAAAAAAAAAAAAABBB /* Release */ = { 427isa = XCBuildConfiguration; 428buildSettings = { 429ALWAYS_SEARCH_USER_PATHS = NO; 430CLANG_ANALYZER_NONNULL = YES; 431CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 432CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 433CLANG_CXX_LIBRARY = "libc++"; 434CLANG_ENABLE_MODULES = YES; 435CLANG_ENABLE_OBJC_ARC = YES; 436CLANG_ENABLE_OBJC_WEAK = YES; 437CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 438CLANG_WARN_BOOL_CONVERSION = YES; 439CLANG_WARN_COMMA = YES; 440CLANG_WARN_CONSTANT_CONVERSION = YES; 441CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 442CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 443CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 444CLANG_WARN_EMPTY_BODY = YES; 445CLANG_WARN_ENUM_CONVERSION = YES; 446CLANG_WARN_INFINITE_RECURSION = YES; 447CLANG_WARN_INT_CONVERSION = YES; 448CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 449CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 450CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 451CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 452CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 453CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 454CLANG_WARN_STRICT_PROTOTYPES = YES; 455CLANG_WARN_SUSPICIOUS_MOVE = YES; 456CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 457CLANG_WARN_UNREACHABLE_CODE = YES; 458CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 459COPY_PHASE_STRIP = NO; 460DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 461ENABLE_NS_ASSERTIONS = NO; 462ENABLE_STRICT_OBJC_MSGSEND = YES; 463GCC_C_LANGUAGE_STANDARD = gnu11; 464GCC_NO_COMMON_BLOCKS = YES; 465GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 466GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 467GCC_WARN_UNDECLARED_SELECTOR = YES; 468GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 469GCC_WARN_UNUSED_FUNCTION = YES; 470GCC_WARN_UNUSED_VARIABLE = YES; 471MTL_ENABLE_DEBUG_INFO = NO; 472MTL_FAST_MATH = YES; 473SDKROOT = xros; 474SWIFT_COMPILATION_MODE = wholemodule; 475SWIFT_OPTIMIZATION_LEVEL = "-O"; 476VALIDATE_PRODUCT = YES; 477XROS_DEPLOYMENT_TARGET = 1.0; 478}; 479name = Release; 480}; 481BBBBBBBBBBBBBBBBBBBBBBCCC /* Debug */ = { 482isa = XCBuildConfiguration; 483buildSettings = { 484ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 485ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 486CODE_SIGN_STYLE = Manual; 487DEVELOPMENT_TEAM = ""; 488ENABLE_PREVIEWS = YES; 489FRAMEWORK_SEARCH_PATHS = "$(PROJECT_DIR)"; 490INFOPLIST_FILE = "VisionOSLlamaTest/Info.plist"; 491LD_RUNPATH_SEARCH_PATHS = ( 492"$(inherited)", 493"@executable_path/Frameworks", 494); 495PRODUCT_BUNDLE_IDENTIFIER = "org.ggml.VisionOSLlamaTest"; 496PRODUCT_NAME = "$(TARGET_NAME)"; 497PROVISIONING_PROFILE_SPECIFIER = ""; 498SUPPORTED_PLATFORMS = "xros xrsimulator"; 499SWIFT_VERSION = 5.0; 500TARGETED_DEVICE_FAMILY = "1,2,7"; 501}; 502name = Debug; 503}; 504CCCCCCCCCCCCCCCCCCCCCCDDD /* Release */ = { 505isa = XCBuildConfiguration; 506buildSettings = { 507ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 508ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; 509CODE_SIGN_STYLE = Manual; 510DEVELOPMENT_TEAM = ""; 511ENABLE_PREVIEWS = YES; 512FRAMEWORK_SEARCH_PATHS = ( 513"$(inherited)", 514"$(PROJECT_DIR)", 515); 516INFOPLIST_FILE = "VisionOSLlamaTest/Info.plist"; 517LD_RUNPATH_SEARCH_PATHS = ( 518"$(inherited)", 519"@executable_path/Frameworks", 520); 521PRODUCT_BUNDLE_IDENTIFIER = "org.ggml.VisionOSLlamaTest"; 522PRODUCT_NAME = "$(TARGET_NAME)"; 523PROVISIONING_PROFILE_SPECIFIER = ""; 524SUPPORTED_PLATFORMS = "xros xrsimulator"; 525SWIFT_VERSION = 5.0; 526TARGETED_DEVICE_FAMILY = "1,2,7"; 527}; 528name = Release; 529}; 530/* End XCBuildConfiguration section */ 531EOF 532 533# Finish the project.pbxproj file 534cat >> " ${ TEMP_DIR } / ${ APP_NAME } / ${ APP_NAME } .xcodeproj/project.pbxproj" <<EOF 535/* Begin XCConfigurationList section */ 5368888888888888888888888AA /* Build configuration list for PBXProject " ${ APP_NAME } " */ = { 537isa = XCConfigurationList; 538buildConfigurations = ( 5399999999999999999999999AA /* Debug */, 540AAAAAAAAAAAAAAAAAAAAABBB /* Release */, 541); 542defaultConfigurationIsVisible = 0; 543defaultConfigurationName = Release; 544}; 5454444444444444444444444AA /* Build configuration list for PBXNativeTarget " ${ APP_NAME } " */ = { 546isa = XCConfigurationList; 547buildConfigurations = ( 548BBBBBBBBBBBBBBBBBBBBBBCCC /* Debug */, 549CCCCCCCCCCCCCCCCCCCCCCDDD /* Release */, 550); 551defaultConfigurationIsVisible = 0; 552defaultConfigurationName = Release; 553}; 554/* End XCConfigurationList section */ 555}; 556rootObject = 7777777777777777777777AA /* Project object */; 557} 558EOF 559 560# 2. Copy XCFramework to test project 561echo "Copying XCFramework to test project..." 562cp -R " ${ XCFRAMEWORK_PATH } " " ${ TEMP_DIR } / ${ APP_NAME } /" 563 564# 3. Build and archive the app 565echo "Building and archiving test app..." 566cd " ${ TEMP_DIR } / ${ APP_NAME } " 567 568# Create a simple xcscheme file to avoid xcodebuild scheme issues 569mkdir -p " ${ APP_NAME } .xcodeproj/xcshareddata/xcschemes" 570cat > " ${ APP_NAME } .xcodeproj/xcshareddata/xcschemes/ ${ APP_NAME } .xcscheme" <<EOF 571<?xml version="1.0" encoding="UTF-8"?> 572<Scheme 573LastUpgradeVersion = "1510" 574version = "1.3"> 575<BuildAction 576parallelizeBuildables = "YES" 577buildImplicitDependencies = "YES"> 578<BuildActionEntries> 579<BuildActionEntry 580buildForTesting = "YES" 581buildForRunning = "YES" 582buildForProfiling = "YES" 583buildForArchiving = "YES" 584buildForAnalyzing = "YES"> 585<BuildableReference 586BuildableIdentifier = "primary" 587BlueprintIdentifier = "3333333333333333333333AA" 588BuildableName = " ${ APP_NAME } .app" 589BlueprintName = " ${ APP_NAME } " 590ReferencedContainer = "container: ${ APP_NAME } .xcodeproj"> 591</BuildableReference> 592</BuildActionEntry> 593</BuildActionEntries> 594</BuildAction> 595<TestAction 596buildConfiguration = "Debug" 597selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" 598selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" 599shouldUseLaunchSchemeArgsEnv = "YES"> 600<Testables> 601</Testables> 602</TestAction> 603<LaunchAction 604buildConfiguration = "Debug" 605selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" 606selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" 607launchStyle = "0" 608useCustomWorkingDirectory = "NO" 609ignoresPersistentStateOnLaunch = "NO" 610debugDocumentVersioning = "YES" 611debugServiceExtension = "internal" 612allowLocationSimulation = "YES"> 613<BuildableProductRunnable 614runnableDebuggingMode = "0"> 615<BuildableReference 616BuildableIdentifier = "primary" 617BlueprintIdentifier = "3333333333333333333333AA" 618BuildableName = " ${ APP_NAME } .app" 619BlueprintName = " ${ APP_NAME } " 620ReferencedContainer = "container: ${ APP_NAME } .xcodeproj"> 621</BuildableReference> 622</BuildableProductRunnable> 623</LaunchAction> 624<ProfileAction 625buildConfiguration = "Release" 626shouldUseLaunchSchemeArgsEnv = "YES" 627savedToolIdentifier = "" 628useCustomWorkingDirectory = "NO" 629debugDocumentVersioning = "YES"> 630<BuildableProductRunnable 631runnableDebuggingMode = "0"> 632<BuildableReference 633BuildableIdentifier = "primary" 634BlueprintIdentifier = "3333333333333333333333AA" 635BuildableName = " ${ APP_NAME } .app" 636BlueprintName = " ${ APP_NAME } " 637ReferencedContainer = "container: ${ APP_NAME } .xcodeproj"> 638</BuildableReference> 639</BuildableProductRunnable> 640</ProfileAction> 641<AnalyzeAction 642buildConfiguration = "Debug"> 643</AnalyzeAction> 644<ArchiveAction 645buildConfiguration = "Release" 646revealArchiveInOrganizer = "YES"> 647</ArchiveAction> 648</Scheme> 649EOF 650 651# Now use xcodebuild with an explicitly defined product name for visionOS 652xcodebuild -project " ${ APP_NAME } .xcodeproj" -scheme " ${ APP_NAME } " -sdk xros-configuration Release archive-archivePath " ${ ARCHIVE_PATH } " CODE_SIGN_IDENTITY="-" CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO PRODUCT_NAME=" ${ APP_NAME } " SWIFT_OPTIMIZATION_LEVEL="-Onone" -quiet 653 654# 4. Create IPA from archive 655echo "Creating IPA from archive..." 656mkdir -p " ${ TEMP_DIR } /Payload" 657cp -R " ${ ARCHIVE_PATH } /Products/Applications/ ${ APP_NAME } .app" " ${ TEMP_DIR } /Payload/" 658 659# Check and log app structure before zipping 660echo "App structure:" 661ls -la " ${ TEMP_DIR } /Payload/ ${ APP_NAME } .app/" 662echo "Frameworks:" 663ls -la " ${ TEMP_DIR } /Payload/ ${ APP_NAME } .app/Frameworks/" 2 > /dev/null ||echo "No Frameworks directory found" 664 665cd " ${ TEMP_DIR } " 666zip -r " ${ IPA_PATH } " Payload 667 668# Check embedded provisioning profile 669echo "Checking provisioning profile (if any)..." 670PROVISIONING_PROFILE =$( find " ${ ARCHIVE_PATH } /Products/Applications/ ${ APP_NAME } .app" -name "embedded.mobileprovision" 2 > /dev/null) 671if [ -n" $ PROVISIONING_PROFILE " ];then 672echo "Found embedded provisioning profile:" 673security cms-D -i " $ PROVISIONING_PROFILE " ||echo "Unable to decode provisioning profile" 674else 675echo "No embedded provisioning profile found (expected for ad-hoc builds)" 676fi 677 678# 5. Validate the IPA 679echo "Validating IPA..." 680VALIDATION_OUTPUT =" ${ VALIDATION_DIR } /validation_output.txt" 681 682# Check if authentication credentials are provided 683AUTH_ARGS ="" 684if [ -n" $ APPLE_ID " ]&& [ -n" $ APPLE_PASSWORD " ];then 685echo "Using Apple ID authentication for validation..." 686AUTH_ARGS ="--username \" $ APPLE_ID \" --password \" $ APPLE_PASSWORD \"" 687else 688echo "No authentication credentials provided. Will perform basic validation." 689echo "To use your personal developer account, you can run the script with:" 690echo " APPLE_ID='your.email@example.com' APPLE_PASSWORD='your-app-specific-password' ./validate-visionos.sh" 691echo "Note: You need to create an app-specific password at https://appleid.apple.com/account/manage" 692fi 693 694# Run validation with detailed output 695echo "Running validation with altool..." 696if [ -n" $ AUTH_ARGS " ];then 697# Use eval to properly handle the quoted arguments 698eval "xcrun altool --validate-app -f \" ${ IPA_PATH } \" --type visionos --output-format xml $ AUTH_ARGS " 2 >&1| tee " ${ VALIDATION_OUTPUT } " 699else 700xcrun altool--validate-app -f " ${ IPA_PATH } " --type visionos--output-format xml2 >&1| tee " ${ VALIDATION_OUTPUT } " 701fi 702VALIDATION_RESULT =$ ? 703 704# Final validation result 705FINAL_VALIDATION_RESULT =0 706 707# Check if validation failed because the app isn't in App Store Connect 708if grep -q "No suitable application records were found" " ${ VALIDATION_OUTPUT } " ;then 709echo "⚠️ App Store Connect Warning: The app bundle identifier is not found in App Store Connect" 710echo "This is expected for apps that haven't been registered in App Store Connect yet." 711echo "This doesn't indicate a problem with the build or framework." 712 713# Perform alternative validation 714echo "Performing alternative validation checks..." 715 716# Check if IPA was created successfully 717if [ -f" ${ IPA_PATH } " ]&& [ -s" ${ IPA_PATH } " ];then 718echo "✅ IPA file created successfully" 719else 720echo "❌ IPA file not created or empty" 721FINAL_VALIDATION_RESULT =1 722fi 723 724# Check if app binary exists and is executable 725if [ -f" ${ TEMP_DIR } /Payload/ ${ APP_NAME } .app/ ${ APP_NAME } " ]&& [ -x" ${ TEMP_DIR } /Payload/ ${ APP_NAME } .app/ ${ APP_NAME } " ];then 726echo "✅ App binary exists and is executable" 727else 728echo "❌ App binary missing or not executable" 729FINAL_VALIDATION_RESULT =1 730fi 731 732# Check if framework was properly embedded 733if [ -d" ${ TEMP_DIR } /Payload/ ${ APP_NAME } .app/Frameworks/llama.framework" ];then 734echo "✅ llama.framework properly embedded" 735else 736echo "❌ llama.framework not properly embedded" 737FINAL_VALIDATION_RESULT =1 738fi 739 740# Check if framework binary exists 741if [ -f" ${ TEMP_DIR } /Payload/ ${ APP_NAME } .app/Frameworks/llama.framework/llama" ];then 742echo "✅ Framework binary exists" 743 744# Further validate framework by checking architecture 745ARCHS =$( lipo -info " ${ TEMP_DIR } /Payload/ ${ APP_NAME } .app/Frameworks/llama.framework/llama" 2 > /dev/null | grep -o "arm64\\|x86_64" | tr '\n' ' ' ) 746if [ -n" $ ARCHS " ];then 747echo "✅ Framework architecture(s): $ ARCHS " 748else 749echo "⚠️ Could not determine framework architecture" 750fi 751else 752echo "❌ Framework binary missing" 753FINAL_VALIDATION_RESULT =1 754fi 755 756if [$ FINAL_VALIDATION_RESULT -eq 0 ];then 757echo "✅ Alternative validation PASSED: App built successfully with embedded framework" 758else 759echo "❌ Alternative validation FAILED: Issues found with the app or framework" 760fi 761elif grep -q "You must specify authentication credentials" " ${ VALIDATION_OUTPUT } " && [ -z" $ AUTH_ARGS " ];then 762echo "✅ visionOS Validation PASSED: IPA successfully validated" 763echo "Results saved to ${ VALIDATION_OUTPUT } " 764else 765echo "❌ visionOS Validation FAILED: IPA validation found issues" 766echo "See validation output at ${ VALIDATION_OUTPUT } " 767echo "" 768echo "==== VALIDATION ERRORS ====" 769 770# Try to extract specific errors from the output 771if grep -q "Error" " ${ VALIDATION_OUTPUT } " ;then 772grep -A 5"Error" " ${ VALIDATION_OUTPUT } " 773else 774# If no specific error found, show the whole log 775cat " ${ VALIDATION_OUTPUT } " 776fi 777 778# Additional debugging: check IPA contents 779echo "" 780echo "==== IPA CONTENTS ====" 781mkdir -p " ${ TEMP_DIR } /ipa_contents" 782unzip -q " ${ IPA_PATH } " -d " ${ TEMP_DIR } /ipa_contents" 783ls -la " ${ TEMP_DIR } /ipa_contents/Payload/ ${ APP_NAME } .app/" 784 785# Check for code signing issues 786echo "" 787echo "==== CODE SIGNING INFO ====" 788codesign -vv -d " ${ TEMP_DIR } /ipa_contents/Payload/ ${ APP_NAME } .app" 2 >&1 ||echo "Code signing verification failed" 789 790# Check embedded frameworks 791echo "" 792echo "==== FRAMEWORK INFO ====" 793ls -la " ${ TEMP_DIR } /ipa_contents/Payload/ ${ APP_NAME } .app/Frameworks/" 2 > /dev/null ||echo "No Frameworks directory found" 794fi 795 796# Don't clean up on error to allow inspection 797if [$ FINAL_VALIDATION_RESULT -ne 0 ];then 798echo "" 799echo "Temporary files kept for inspection at: ${ TEMP_DIR } " 800echo "===== visionOS Validation Process Failed =====" 801exit 1 802fi 803 804# Clean up temporary files but keep build artifacts 805if [$ FINAL_VALIDATION_RESULT -eq 0 ];then 806echo "Cleaning up temporary files..." 807#rm -rf "${TEMP_DIR}" 808fi 809 810echo "===== visionOS Validation Process Completed =====" 811exit $ FINAL_VALIDATION_RESULT