firebase / firebase-ios-sdk

Firebase SDK for Apple App Development
https://firebase.google.com
Apache License 2.0
5.55k stars 1.45k forks source link

Building SwiftProtobuf with BUILD_LIBRARY_FOR_DISTRIBUTION=YES is not supported #8200

Open acecilia opened 3 years ago

acecilia commented 3 years ago

[REQUIRED] Step 1: Describe your environment

[REQUIRED] Step 2: Describe the problem

Swift Protobuf does not support itself being built in library evolution mode, so it cannot be present in the public ABI of any framework that is built in library evolution mode. That means it can only ever be imported @_implementationOnly, and its types can never be public.

I have other third parties in my app that depend on SwiftProtobuf (grpc), so when using FirebaseMLModelDownloader I am building my own SwiftProtobuf xcframework using Carthage, and that uses BUILD_LIBRARY_FOR_DISTRIBUTION=NO. When doing that, multiple link errors show up (Undefined symbols). See the following issue for an extensive description of the problem: https://github.com/apple/swift-protobuf/issues/1101

Steps to reproduce:

See: https://github.com/apple/swift-protobuf/issues/1101#issuecomment-855076010

google-oss-bot commented 3 years ago

I found a few problems with this issue:

paulb777 commented 3 years ago

@acecilia Thanks for the report and sharing the thorough investigation.

We'll have to investigate if there are any alternatives for the FirebaseMLModelDownloader binary distributions.

In the meantime, is it possible for you to integrate FirebaseMLModelDownloader via a source distribution? CocoaPods, Swift Package Manager, or the source itself?

acecilia commented 3 years ago

@paulb777 Thanks for the response! šŸ™Œ I sadly cant integrate source and need a prebuilt binary, but I have a couple alternatives in mind:

acecilia commented 3 years ago

@paulb777 there is another problem:

This could be solved by distributing SwiftProtobuf.xcframework using a dedicated zip

paulb777 commented 3 years ago

@acecilia Would you explain more about your workflow? My understanding is after installing with Carthage, there is still an integration step into an Xcode project in which you would choose which SwiftProtobuf.xcframework to integrate.

acecilia commented 3 years ago

@paulb777 Mmm Maybe I am missing something but: aren't both my SwiftProtobuf.xcframework and Firebase SwiftProtobuf.xcframework installed in the same path Carthage/Build/SwiftProtobuf.xcframework?

So one would overwrite the other when Carthage installs them

paulb777 commented 3 years ago

I understand now. The other SwiftProtobuf is also installed from Carthage. Thanks.

ncooke3 commented 1 year ago

Hi @acecilia ,

I'm investigating this issue and I followed your post in apple/swift-protobuf#1101. I'm trying to reproduce the following error:

āŒ Undefined symbols for architecture x86_64
āŒ   "method descriptor for SwiftProtobuf.Message.init() -> A", referenced from:
...

But haven't figured out how to do so given your sample project... do you have any suggestions?

acecilia commented 1 year ago

Hey @ncooke3 šŸ‘‹ I just run make static_swift_protobuf in Xcode 13.2.1 in an intel mac and can reproduce the issues, as explained. Could you give more details of your setup?

paulb777 commented 1 year ago

According to https://github.com/apple/swift-protobuf/issues/1101, there are solutions using @_implementationOnly import and module aliasing with Swift 5.7