Failed to verify code signature on iOS

Hi there,

We are building our project to iOS platform which generates XCode project.
Later, whenever I open XCode project and tries to build and run it for MacOS platform it works fine, however if I connect my iOS device and tries to build and run on it, I got the next error during app installation:

Unable to Install “myApp”
Domain: IXUserPresentableErrorDomain
Code: 14
Recovery Suggestion: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.IzAOnY/extracted/myApp : 0xe8008017 (A signed resource has been added, modified, or deleted.)

Please verify whether your app is signed properly with `codesign -v --verbose=4 <app>`. If this issue persists, please attach an IPA of your app when sending a report to Apple.
User Info: {
    DVTErrorCreationDateKey = "2024-12-04 15:09:31 +0000";
    IDERunOperationFailingWorker = IDEInstallCoreDeviceWorker;
}
--
Failed to install the app on the device.
Domain: com.apple.dt.CoreDeviceError
Code: 3002
User Info: {
    NSURL = "file:///Users/User/Library/Developer/Xcode/DerivedData/Unity-iPhone-glqvacnzmhaoergfjdzitsswyvlh/Build/Products/Debug-iphoneos/myApp";
}
--
Unable to Install “myApp”
Domain: IXUserPresentableErrorDomain
Code: 14
Failure Reason: This app cannot be installed because its integrity could not be verified.
Recovery Suggestion: Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.IzAOnY/extracted/myApp : 0xe8008017 (A signed resource has been added, modified, or deleted.)
--
Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.IzAOnY/extracted/myApp : 0xe8008017 (A signed resource has been added, modified, or deleted.)
Domain: MIInstallerErrorDomain
Code: 13
User Info: {
    FunctionName = "+[MICodeSigningVerifier _validateSignatureAndCopyInfoForURL:withOptions:error:]";
    LegacyErrorString = ApplicationVerificationFailed;
    LibMISErrorNumber = "-402620393";
    SourceFileLine = 79;
}
--

Event Metadata: com.apple.dt.IDERunOperationWorkerFinished : {
    "device_identifier" = "00008140-001E283400A2201C";
    "device_isCoreDevice" = 1;
    "device_model" = "iPhone17,1";
    "device_osBuild" = "18.1.1 (22B91)";
    "device_platform" = "com.apple.platform.iphoneos";
    "device_thinningType" = "iPhone17,1";
    "dvt_coredevice_version" = "397.24";
    "dvt_coresimulator_version" = "987.2";
    "dvt_mobiledevice_version" = "1759.40.2";
    "launchSession_schemeCommand" = Run;
    "launchSession_state" = 1;
    "launchSession_targetArch" = arm64;
    "operation_duration_ms" = 65761;
    "operation_errorCode" = 14;
    "operation_errorDomain" = IXUserPresentableErrorDomain;
    "operation_errorWorker" = IDEInstallCoreDeviceWorker;
    "operation_name" = IDERunOperationWorkerGroup;
    "param_debugger_attachToExtensions" = 0;
    "param_debugger_attachToXPC" = 0;
    "param_debugger_type" = 3;
    "param_destination_isProxy" = 0;
    "param_destination_platform" = "com.apple.platform.iphoneos";
    "param_diag_113575882_enable" = 0;
    "param_diag_MainThreadChecker_stopOnIssue" = 0;
    "param_diag_MallocStackLogging_enableDuringAttach" = 0;
    "param_diag_MallocStackLogging_enableForXPC" = 1;
    "param_diag_allowLocationSimulation" = 1;
    "param_diag_checker_tpc_enable" = 0;
    "param_diag_gpu_frameCapture_enable" = 1;
    "param_diag_gpu_shaderValidation_enable" = 0;
    "param_diag_gpu_validation_enable" = 0;
    "param_diag_guardMalloc_enable" = 0;
    "param_diag_memoryGraphOnResourceException" = 0;
    "param_diag_mtc_enable" = 1;
    "param_diag_queueDebugging_enable" = 0;
    "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_enable" = 0;
    "param_diag_sanitizer_ubsan_stopOnIssue" = 0;
    "param_diag_showNonLocalizedStrings" = 0;
    "param_diag_viewDebugging_enabled" = 1;
    "param_diag_viewDebugging_insertDylibOnLaunch" = 1;
    "param_install_style" = 2;
    "param_launcher_UID" = 2;
    "param_launcher_allowDeviceSensorReplayData" = 0;
    "param_launcher_kind" = 0;
    "param_launcher_style" = 99;
    "param_launcher_substyle" = 0;
    "param_runnable_appExtensionHostRunMode" = 0;
    "param_runnable_productType" = "com.apple.product-type.application";
    "param_structuredConsoleMode" = 1;
    "param_testing_launchedForTesting" = 0;
    "param_testing_suppressSimulatorApp" = 0;
    "param_testing_usingCLI" = 0;
    "sdk_canonicalName" = "iphoneos18.1";
    "sdk_osVersion" = "18.1";
    "sdk_variant" = iphoneos;
}
--


System Information

macOS Version 15.1 (Build 24B83)
Xcode 16.1 (23503) (Build 16B40)
Timestamp: 2024-12-04T16:09:31+01:00

We are using Enterprise Provisioning Profiles and Certificates which are intended for development and distribution.
One more interesting thing, if I turn off Build Addressables on Player Build in Addressables Assset Setting it starts to build and run on device without any problems

Do you have in mind what can cause the issue?

It looks like something was modified after the app was already signed. I couldn’t reproduce this issue myself on an Addressables example project. You can check if you don’t have any “Run Script” phases for Unity-iPhone and UnityFramework targets that could be modifying something.
Also try doing a “Clean Build Folder” before building and see if the following build succeeds

If you are still facing this issue, would be best if you reported a bug and attach a project where it reproduces or describe steps to reproduce on a new project

HI, we have RunScript, but it is standart one which is coming from Apple Unity Plug-in

#  Apple Unity Plug-in Sign & Embed libraries shell script
#  Copyright © 2024 Apple, Inc. All rights reserved.
#  This script is added to the generated Xcode project by the Apple.Core plug-in.
#  Please see AppleBuild.cs in the Apple.Core plug-in for more information.
echo "Debug Apple Unity Plug-in Embed libraries shell script: enhanced output"
echo "***********************************************************************"
dstFrameworkFolder="$BUILT_PRODUCTS_DIR/$FRAMEWORKS_FOLDER_PATH"
dstBundleFolder="$BUILT_PRODUCTS_DIR/$PLUGINS_FOLDER_PATH"
echo "Embed framework destination folder: $dstFrameworkFolder"
echo "Embed bundle destination folder: $dstBundleFolder"
APPLE_PLUGIN_LIBRARY_ROOT="$PROJECT_DIR/ApplePluginLibraries"
if [ -d $APPLE_PLUGIN_LIBRARY_ROOT ]; then
    echo "Found Apple plug-in native library root: $APPLE_PLUGIN_LIBRARY_ROOT"
    echo "Iterating through contents."
    for folder in "$APPLE_PLUGIN_LIBRARY_ROOT"/*; do
        if [ -d "$folder" ]; then
            echo "  Discovered potential plug-in library folder: $folder"
            echo "  Iterating through contents."
            for item in "$folder"/*; do
                echo "    Found item: $item"
                echo "    Checking to see if it's a .framework, if so will embed in destination folder."
                if [[ $item = *'.dSYM' ]]; then
                    echo "    Debug symbol (.dSYM) file found. Continuing."
                    continue
                elif [[ $item = *'.framework' ]]; then
                    filename=$(basename $item)
                    echo "    Embedding Apple plug-in framework $filename"
                    echo "      Source: $item"
                    echo "      Destination: $dstFrameworkFolder/$filename"
                    if [ ! -z "$EXPANDED_CODE_SIGN_IDENTITY" ]; then
                        echo "      Code signing identity: $EXPANDED_CODE_SIGN_IDENTITY"
                        codesign --force --sign $EXPANDED_CODE_SIGN_IDENTITY --timestamp\=none --generate-entitlement-der $item
                    fi
                    ditto $item "$dstFrameworkFolder/$filename"
                    break
                elif [[ $item = *'.bundle' ]]; then
                    filename=$(basename $item)
                    echo "    Embedding Apple plug-in bundle $filename"
                    echo "      Source: $item"
                    echo "      Destination: $dstBundleFolder/$filename"
                    if [ ! -z "$EXPANDED_CODE_SIGN_IDENTITY" ]; then
                        echo "      Code signing identity: $EXPANDED_CODE_SIGN_IDENTITY"
                        codesign --force --sign $EXPANDED_CODE_SIGN_IDENTITY --timestamp\=none --generate-entitlement-der $item
                    fi
                    ditto $item "$dstBundleFolder/$filename"
                    break
                fi
            done
        fi
    done
    echo "Completed search of libraries in the Apple native plug-in folder root."
    echo "If this processing completed with missing or unexpected libraries, please check the following:"
    echo " - Ensure your Unity project only includes the Apple Unity Plug-ins that are necessary for your project."
    echo " - Examine Unity console output for build errors."
    echo " - Check the output of the build script (build.py) if you used the script to build and pack the Apple Unity Plug-ins."
    echo " - If you built the native libraries with Xcode or xcodebuild, please ensure that the libraries compiled successfully and were copied into the correct plug-in folders."
else
    echo "No Apple plug-in library path found at $APPLE_PLUGIN_LIBRARY_ROOT"
    echo "Please check the Unity Editor build output and/or logs for issues and errors."
    exit 1
fi

The script does mess with code signing manually, so it’s not out of the question that it’s the culprit. It does copy its bundles and frameworks directly to the products directory which is very incriminating in this case.
However, since changing Adddressables setting fixes this, it’s still unclear how the script and addressable could influence each other.

I suggest checking the diff between the successful build (which changed Addressable setting) and the failed build to see what is actually changed

That script is generated automatically from the Apple Unity Plug-in: GitHub - apple/unityplugins