Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-13343] SwiftPM fails to codesign with binaryTarget and embedded frameworks #4515

Open
swift-ci opened this issue Aug 4, 2020 · 12 comments
Labels

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Aug 4, 2020

Previous ID SR-13343
Radar rdar://problem/69235377
Original Reporter opi-smccoole (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 12 beta 3. SwiftPM tools 5.3. Targeting iOS 13.0+. Tested running on iPhone X hardware.

Additional Detail from JIRA
Votes 23
Component/s Package Manager
Labels Bug
Assignee None
Priority Medium

md5: 07486ad30f32f0d0b1aaae388146f44d

Issue Description:

When a SwiftPM dependency utilizing a binaryTarget directive is used in a project that has embedded frameworks or xcframeworks, the project cannot be installed on a device. Doing so results in a code signing error, shown below. Removing either the SwiftPM dependency or the embedded framework will allow the application to be installed and run on a device. Works on a simulator since no code signing is needed there.

{{}}

Details

Unable to install "OpensslTest"

Domain: com.apple.dt.MobileDeviceErrorDomain

Code: -402620388

--

No code signature found.

Domain: com.apple.dt.MobileDeviceErrorDomain

Code: -402620388

User Info: {

DVTRadarComponentKey = 261622;

MobileDeviceErrorCode = "(0xE800801C)";

"com.apple.dtdevicekit.stacktrace" = (

0 DTDeviceKitBase 0x0000000123f0091f DTDKCreateNSErrorFromAMDErrorCode + 220

1 DTDeviceKitBase 0x0000000123f3f104 __90-[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:]_block_invoke + 155

2 DVTFoundation 0x000000010742116f DVTInvokeWithStrongOwnership + 71

3 DTDeviceKitBase 0x0000000123f3ee45 -[DTDKMobileDeviceToken installApplicationBundleAtPath:withOptions:andError:withCallback:] + 1440

4 IDEiOSSupportCore 0x0000000123dafd4c __118-[DVTiOSDevice(DVTiPhoneApplicationInstallation) processAppInstallSet:appUninstallSet:installOptions:completionBlock:]_block_invoke.292 + 3513

5 DVTFoundation 0x000000010754f14b DVT_CALLING_CLIENT_BLOCK + 7

6 DVTFoundation 0x0000000107550d6d __DVTDispatchAsync_block_invoke + 1191

7 libdispatch.dylib 0x00007fff6b2206c4 _dispatch_call_block_and_release + 12

8 libdispatch.dylib 0x00007fff6b221658 _dispatch_client_callout + 8

9 libdispatch.dylib 0x00007fff6b226c44 _dispatch_lane_serial_drain + 597

10 libdispatch.dylib 0x00007fff6b2275d6 _dispatch_lane_invoke + 363

11 libdispatch.dylib 0x00007fff6b230c09 _dispatch_workloop_worker_thread + 596

12 libsystem_pthread.dylib 0x00007fff6b47ba3d _pthread_wqthread + 290

13 libsystem_pthread.dylib 0x00007fff6b47ab77 start_wqthread + 15

);

}

--

System Information

macOS Version 10.15.6 (Build 19G73)

Xcode 12.0 (17189.4)

@swift-ci
Copy link
Contributor Author

Comment by Travis Chapman (JIRA)

This issue is still occurring in Xcode 12 GM.

@typesanitizer
Copy link

@swift-ci create

@swift-ci
Copy link
Contributor Author

Comment by Kyle Browning (JIRA)

This is still happening in Xcode 12.2

@swift-ci
Copy link
Contributor Author

Comment by Travis Chapman (JIRA)

Can confirm, still happening for me on Xcode 12.2 beta

@swift-ci
Copy link
Contributor Author

Comment by Peter Steinberger (JIRA)

For everyone who runs into this, this can be worked around with a script phase and a copy build phase. We wrote up a knowledge base article for our SDK, but it will apply to any binary SDK. Hope it helps! https://pspdfkit.com/guides/ios/current/knowledge-base/library-not-found-swiftpm/

@swift-ci
Copy link
Contributor Author

Comment by Travis Chapman (JIRA)

Thanks steipete (JIRA User). Worked for us.

@swift-ci
Copy link
Contributor Author

swift-ci commented Oct 1, 2020

Comment by Steve McCoole (JIRA)

Thanks steipete (JIRA User), I was able to make the test case work by the addition of the script phase. Adding the copy build phase caused the build to fail with an unexpected duplicate tasks error, so depending on an app's other frameworks/steps it might be necessary to experiment to see if both additions are needed.

@swift-ci
Copy link
Contributor Author

swift-ci commented Oct 2, 2020

Comment by Rolandas Razma (JIRA)

It's bit more complicated than that. I tried to submit to App Store with those workarounds and got bunch of errors.

One of them is that binary framework gets copied to /YourApp.app/Watch/ for some reason (even if watch don't link) - invalid path error - build step to remove it

6 Info.plist errors about missing keys - build step to copy from another framework and change names and identifiers

@swift-ci
Copy link
Contributor Author

swift-ci commented Oct 2, 2020

Comment by Samuel Défago (JIRA)

There is also an issue if a project uses a Swift package which itself declares a binary Swift package as dependency (Project → Source package → Binary package instead of Project → Binary package).

In this specific case Xcode copies the unsigned transitive binary dependencies last, after code signing has been made. The resulting app bundle is therefore incorrectly signed and cannot be run on a device.

I propose a workaround on the Swift forums, but of course it would be great if this use case were properly supported as well.

Thanks for all the work done on SPM, it's really great!

@swift-ci
Copy link
Contributor Author

Comment by Samuel Défago (JIRA)

The issue I was mentioning above seems to be fixed in Xcode 12.2 beta 3. Also see my comment on the Swift forums. Thanks for the fix!

@swift-ci
Copy link
Contributor Author

Comment by Rob Cas (JIRA)

It appears to be still fixed in non-beta versions too: Xcode 12.3 (12C33) works.

@swift-ci
Copy link
Contributor Author

swift-ci commented May 4, 2021

Comment by F H (JIRA)

I have encountered this issue with MapLibre SPM package in Xcode 12.5 RC.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants