apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.43k stars 151 forks source link

Error : Module 'CCryptoBoringSSL' is not present in definition of ... #244

Open GaultieriOS opened 3 days ago

GaultieriOS commented 3 days ago

New Issue Checklist

I'm using the latest version of Swift Crypto (main branch) I read the Contribution Guidelines I searched for existing GitHub issues Expected behavior

Build to succeed

Actual behavior

Since yesterday evening when I resolve package and build a certain Vapor swift package, those errors pop up:

Building for production...

-'bio_st::ex_data' from module 'CCryptoBoringSSL' is not present in definition of 'struct bio_st' in module 'CNIOBoringSSL' -'bio_st::num_read' from module 'CCryptoBoringSSL' is not present in definition of 'struct bio_st' in module 'CNIOBoringSSL' -'bio_st::num_write' from module 'CCryptoBoringSSL' is not present in definition of 'struct bio_st' in module 'CNIOBoringSSL'

Seems to be related to 3.5.0 release, because I see no issues when forcing 3.4.0 in Package.swift.

Steps to reproduce

Building while using swift-certificate package.

If possible, minimal yet complete reproducer code (or URL to code)

swift package resolve swift package update swift build -c release

Swift Crypto version/commit hash

3.5.0 / https://github.com/apple/swift-crypto/commit/33f65a3cbc52f8c19295723af9cbecc2195484e1

Lukasa commented 3 days ago

cc @simonjbeaumont

What Swift version and OS are you using?

GaultieriOS commented 3 days ago

I'm using Swift 5.1 and the minimum OS for my app is 16.6

Lukasa commented 3 days ago

We dropped support for Swift 5.1 several years ago. Our lowest supported version is now 5.8. Are you sure you’re using 5.1?

Lukasa commented 3 days ago

3.5.0 shouldn’t even be offered to you by SwiftPM on 5.1

simonjbeaumont commented 3 days ago

I just confirmed that I can build a Swift executable package that links both X509 and Vapor from Swift Certificates and Vapor packages, respectively. But this was using a recent Swift, and for macOS.

I'm using Swift 5.1 and the minimum OS for my app is 16.6

In addition to confirming your Swift version, could you also confirm that you are trying to compile for iOS? (that minimum OS doesn't look like a macOS version).

I could then see if I can reproduce the issue.

GaultieriOS commented 3 days ago

When I run this command xcrun swift -version I have this result : Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4) Target: arm64-apple-darwin23.5.0

I confirm that I'm trying to compile for iOS 16.6

simonjbeaumont commented 3 days ago

OK, thank you. So we're dealing with Swift 5.10. We might need some help reproducing this because I've just been able to build an iOS app with the latest Xcode that depends on Vapor and Swift Certificates.

I'll keep trying, but do you have a minimal reproducer package? And could you provide the output of xcodebuild -version?

simonjbeaumont commented 3 days ago

I have also tried setting the iOS Deployment Target to iOS 16.6 and am still able to build, see the app in previews, and run the app in the simulator. Can you advise what you're using for your build destination?

GaultieriOS commented 3 days ago

Here is the output of xcodebuild -version : Xcode 15.4 Build version 15F31d

GaultieriOS commented 3 days ago

I'm trying to build directly to an iPhone 13, my app can't be run in the simulator

simonjbeaumont commented 3 days ago

Thank you. I have that version of Xcode with the iOS SDK downloaded but don't see iPhone 13 as a destination. I can compile fine for all the iPhone destinations I have available and for the generic "Any iOS Device".

EDIT: I'm trying to download an older simulator now.

GaultieriOS commented 3 days ago

I tried to compile with "Any iOS Device" but I have the same issue. Here is a screenshot if it can help :

Capture d’écran 2024-07-01 à 15 50 55
simonjbeaumont commented 3 days ago

I'm afraid I cannot reproduce this issue, despite trying pretty hard. I have a local SwiftUI-based iOS app which is importing all of X509, Vapor, Crypto, _CryptoExtras, and `CryptoBoringWrapper; and have the SwiftUI rendering results of calls through to BoringSSL backed functions, e.g.


import SwiftUI
import Vapor
import X509
import Crypto
import _CryptoExtras
import CryptoBoringWrapper

struct ContentView: SwiftUI.View {
    var body: some SwiftUI.View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
                .foregroundStyle(.tint)
            Text("Hello, world!")
            Text(try! CryptoBoringWrapper.ArbitraryPrecisionInteger(hexString: "42").debugDescription)
            Text(Vapor.Environment.development.name)
            Text(X509.BasicConstraints.notCertificateAuthority.description)
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

I can build and run this fine for the following destinations:

At this stage, I think it's worth checking if you can compile the above basic thing to rule out a misconfigured Xcode.

If you can then we'll need to start digging deeper into your usage of these libraries. E.g. are you using Swift Crypto directly, or just a transitive dependency of some API surface of Certificates or Vapor?

simonjbeaumont commented 3 days ago

And, one more thing, I assume you've tried doing a full-clean build: Quit Xcode, deleting the contents of ~/Library/Developer/Xcode/DerivedData, removing anything in /path/to/your/project/.swiftpm/xcode that isn't part of your userstate, relaunch?

GaultieriOS commented 2 days ago

Thank you for your help, I tried to quit Xcode and deleting the DerivedData but it still not working.

I'm not using Swift Crypto directly, I have it as a dependency of Swift Certificates

GaultieriOS commented 2 days ago

I tried to create a new project with just the Swift Certificates package and it compile just fine, I'll try digging in my project to find where the issue is.

simonjbeaumont commented 1 day ago

@GaultieriOS we just shipped https://github.com/apple/swift-crypto/releases/tag/3.5.2 which reverts to using a much more conservative approach in our imports, which I expect will resolve your issue. Specifically, it should bring back 3.4.0-like behaviour.

GaultieriOS commented 18 hours ago

I just tested it, indeed it works just fine like it was with the 3.4.0, thank you for your help