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

Building SwiftProtobuf with BUILD_LIBRARY_FOR_DISTRIBUTION=YES is not supported #8200

Open
acecilia opened this issue Jun 5, 2021 · 10 comments
Assignees
Labels
api: ml Carthage zip Issues related to binary distribution (zip file)

Comments

@acecilia
Copy link

acecilia commented Jun 5, 2021

[REQUIRED] Step 1: Describe your environment

  • Xcode version: 12.3
  • Firebase SDK version: 8.1.0
  • Installation method: Carthage
  • Firebase Component: FirebaseMLModelDownloader

[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: apple/swift-protobuf#1101

Steps to reproduce:

See: apple/swift-protobuf#1101 (comment)

@google-oss-bot
Copy link

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

@acecilia acecilia changed the title SwiftProtobuf does not support building it with BUILD_LIBRARY_FOR_DISTRIBUTION=YES Building SwiftProtobuf with BUILD_LIBRARY_FOR_DISTRIBUTION=YES is not supported Jun 5, 2021
@paulb777
Copy link
Member

paulb777 commented Jun 5, 2021

@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?

@paulb777 paulb777 added api: ml Carthage zip Issues related to binary distribution (zip file) and removed needs-triage labels Jun 5, 2021
@acecilia
Copy link
Author

acecilia commented Jun 5, 2021

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

  • Stop using my own SwiftProtobuf xcframework and instead use yours (which is using the not supported BUILD_LIBRARY_FOR_DISTRIBUTION=YES, but if it builds in my setup I think it is the easiest way)
  • Rebuild myself all the Firebase dependencies using BUILD_LIBRARY_FOR_DISTRIBUTION=NO

@acecilia
Copy link
Author

acecilia commented Jun 7, 2021

@paulb777 there is another problem:

  • FirebaseMLModelDownloader zip contains two xcframeworks: the FirebaseMLModelDownloader and the SwiftProtobuf one
  • If using Carthage for integration, it is impossible to use your own SwiftProtobuf, as in the final Carthage/Build folder its undefined which of the xcframeworks will be used: will your own copy of SwiftProtobuf.xcframework prevail, or will the Firebase SwiftProtobuf.xcframework? Seems like Carthage is not raising an error in this case

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

@paulb777
Copy link
Member

paulb777 commented Jun 7, 2021

@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
Copy link
Author

acecilia commented Jun 7, 2021

@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
Copy link
Member

paulb777 commented Jun 7, 2021

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

@ncooke3
Copy link
Member

ncooke3 commented Oct 8, 2022

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
Copy link
Author

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
Copy link
Member

According to apple/swift-protobuf#1101, there are solutions using @_implementationOnly import and module aliasing with Swift 5.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: ml Carthage zip Issues related to binary distribution (zip file)
Projects
None yet
Development

No branches or pull requests

4 participants