I want to set a flag in my project so that I can build to devices as well as have XCode cloud properly manage the build number.
Currently when I build my project with ${CI_BUILD_NUMBER} OR ${XCODE_CLOUD_BUILD_NUMBER}
Apple manages to the several long-winded doc sections fail to mention what you actually put in Xcode build field to get Xcode cloud to work in any kind of production-ready way.
Digging around I was able to find the variables in the reference, the XCODE_CLOUD_BUILD_NUMBER work but seems to somehow be completely undocumented: https://developer.apple.com/documentation/xcode/environment-variable-reference
When I build my project using these flag and Xcode cloud the builds work as expected. When I build locally the build number is never set and causes an error that shows up in one of the final steps of installation.
I get the error shown below*.
My question is: how can I use the CI_BUILD_NUMBER or XCODE_CLOUD_BUILD_NUMBER flags while still retaining installation ability locally (without changing the flag each time).
*
`Unable to install "<APPNAME>"
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402653028
User Info: {
DVTErrorCreationDateKey = "2023-04-19 03:21:25 +0000";
IDERunOperationFailingWorker = IDEInstalliPhoneLauncher;
}
--
The bundle’s Info.plist does not contain a CFBundleVersion key or its value is not a string.
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402653028
User Info: {
DVTRadarComponentKey = 261622;
MobileDeviceErrorCode = "(0xE800009C)";
"com.apple.dtdevicekit.stacktrace" = (
0 DTDeviceKitBase 0x000000010b890b1c DTDKCreateNSErrorFromAMDErrorCode + 300
1 DTDeviceKitBase 0x000000010b8c5000 __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 136
2 DVTFoundation 0x0000000102083ac8 DVTInvokeWithStrongOwnership + 76
3 DTDeviceKitBase 0x000000010b8c4d7c -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1208
4 IDEiOSSupportCore 0x000000010ba47ce8 __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.147 + 2340
5 DVTFoundation 0x000000010218e428 __DVT_CALLING_CLIENT_BLOCK__ + 16
6 DVTFoundation 0x000000010218ee94 __DVTDispatchAsync_block_invoke + 152
7 libdispatch.dylib 0x000000018f11d9dc _dispatch_call_block_and_release + 32
8 libdispatch.dylib 0x000000018f11f504 _dispatch_client_callout + 20
9 libdispatch.dylib 0x000000018f126bbc _dispatch_lane_serial_drain + 672
10 libdispatch.dylib 0x000000018f127708 _dispatch_lane_invoke + 384
11 libdispatch.dylib 0x000000018f13234c _dispatch_workloop_worker_thread + 652
12 libsystem_pthread.dylib 0x000000018f2a2100 _pthread_wqthread + 288
13 libsystem_pthread.dylib 0x000000018f2a0e20 start_wqthread + 8
);
}
--
Analytics Event: com.apple.dt.IDERunOperationWorkerFinished : {
"device_model" = "iPhone9,1";
"device_osBuild" = "15.7.3 (19H307)";
"device_platform" = "com.apple.platform.iphoneos";
"launchSession_schemeCommand" = Run;
"launchSession_state" = 1;
"launchSession_targetArch" = arm64;
"operation_duration_ms" = 3650;
"operation_errorCode" = "-402653028";
"operation_errorDomain" = "com.apple.dt.MobileDeviceErrorDomain";
"operation_errorWorker" = IDEInstalliPhoneLauncher;
"operation_name" = IDEiPhoneRunOperationWorkerGroup;
"param_consoleMode" = 0;
"param_debugger_attachToExtensions" = 0;
"param_debugger_attachToXPC" = 1;
"param_debugger_type" = 5;
"param_destination_isProxy" = 0;
"param_destination_platform" = "com.apple.platform.iphoneos";
"param_diag_MainThreadChecker_stopOnIssue" = 0;
"param_diag_MallocStackLogging_enableDuringAttach" = 0;
"param_diag_MallocStackLogging_enableForXPC" = 1;
"param_diag_allowLocationSimulation" = 1;
"param_diag_checker_tpc_enable" = 1;
"param_diag_gpu_frameCapture_enable" = 0;
"param_diag_gpu_shaderValidation_enable" = 0;
"param_diag_gpu_validation_enable" = 0;
"param_diag_memoryGraphOnResourceException" = 0;
"param_diag_queueDebugging_enable" = 1;
"param_diag_runtimeProfile_generate" = 0;
"param_diag_sanitizer_asan_enable" = 0;
"param_diag_sanitizer_tsan_enable" = 0;
"param_diag_sanitizer_tsan_stopOnIssue" = 0;
"param_diag_sanitizer_ubsan_stopOnIssue" = 0;
"param_diag_showNonLocalizedStrings" = 0;
"param_diag_viewDebugging_enabled" = 1;
"param_diag_viewDebugging_insertDylibOnLaunch" = 1;
"param_install_style" = 0;
"param_launcher_UID" = 2;
"param_launcher_allowDeviceSensorReplayData" = 0;
"param_launcher_kind" = 0;
"param_launcher_style" = 0;
"param_launcher_substyle" = 0;
"param_runnable_appExtensionHostRunMode" = 0;
"param_runnable_productType" = "com.apple.product-type.application";
"param_testing_launchedForTesting" = 0;
"param_testing_suppressSimulatorApp" = 0;
"param_testing_usingCLI" = 0;
"sdk_canonicalName" = "iphoneos16.4";
"sdk_osVersion" = "16.4";
"sdk_variant" = iphoneos;
}
--
System Information
macOS Version 13.0.1 (Build 22A400)
Xcode 14.3 (21812) (Build 14E222b)
Timestamp: 2023-04-18T20:21:25-07:00`
Tried setting build number in my iOS project to the following:
- ${CI_BUILD_NUMBER}
- ${XCODE_CLOUD_BUILD_NUMBER}
- ${CI_BUILD_NUMBER:1}
- ${XCODE_CLOUD_BUILD_NUMBER:1}
I expected the flag to default to a value on local builds or at allow a fallback (examples 3 or 4) if the flag wasn't set by Xcode cloud.