Problems when using Swift Package Manager
“Library Not Found” error when you launch the app on your device
The error occurs because Xcode cannot sign the libraries that SPM provides. There is a task to fix in the SPM project, but at the moment it is not solved.
To resolve this problem, follow this sequence of steps:
At the build stage of your app, add a step to copy files.
For Destination select Frameworks.
Add a step to run the script.
Add the script. The script will sign the libraries that SPM provides.
find "${CODESIGNING_FOLDER_PATH}" -name '*.framework' -print0 | while read -d $'\0' framework do codesign --force --deep --sign "${EXPANDED_CODE_SIGN_IDENTITY}" --preserve-metadata=identifier,entitlements --timestamp=none "${framework}" done
Error installing library on the device
During library installation, the error specified below may occur (example log). To solve the problem, follow the steps in Library Not Found error when launching the app on the device.
Example log
Details
Unable to install "Your App"
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402620395
--
A valid provisioning profile for this executable was not found.
Domain: com.apple.dt.MobileDeviceErrorDomain
Code: -402620395
User Info: {
DVTRadarComponentKey = 487925;
MobileDeviceErrorCode = "(0xE8008015)";
"com.apple.dtdevicekit.stacktrace" = (
0 DTDeviceKitBase 0x00000001212d493f DTDKCreateNSErrorFromAMDErrorCode + 220
1 DTDeviceKitBase 0x0000000121313124 __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 155
2 DVTFoundation 0x000000010576db33 DVTInvokeWithStrongOwnership + 71
3 DTDeviceKitBase 0x0000000121312e65 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1440
4 IDEiOSSupportCore 0x0000000121183d28 __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.292 + 3513
5 DVTFoundation 0x000000010589c29a __DVT_CALLING_CLIENT_BLOCK__ + 7
6 DVTFoundation 0x000000010589debc __DVTDispatchAsync_block_invoke + 1191
7 libdispatch.dylib 0x00007fff73c476c4 _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x00007fff73c48658 _dispatch_client_callout + 8
9 libdispatch.dylib 0x00007fff73c4dc44 _dispatch_lane_serial_drain + 597
10 libdispatch.dylib 0x00007fff73c4e5d6 _dispatch_lane_invoke + 363
11 libdispatch.dylib 0x00007fff73c57c09 _dispatch_workloop_worker_thread + 596
12 libsystem_pthread.dylib 0x00007fff73ea2a3d _pthread_wqthread + 290
13 libsystem_pthread.dylib 0x00007fff73ea1b77 start_wqthread + 15
);
}
--
System Information
macOS Version 10.15.7 (Build 19H15)
Xcode 12.1 (17222)