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

Support for XCFrameworks #1715

Closed
LakshmiChidambaranathan opened this issue Sep 12, 2024 · 3 comments
Closed

Support for XCFrameworks #1715

LakshmiChidambaranathan opened this issue Sep 12, 2024 · 3 comments

Comments

@LakshmiChidambaranathan

I am encountering a crash when creating an XCFramework for my SDK, which has SwiftProtobuf as a dependency via CocoaPods. By default, the BUILD_LIBRARIES_FOR_DISTRIBUTION setting is set to No when integrating through CocoaPods, but this needs to be overridden to Yes to properly use the XCFramework. Without this override, the crash occurs. It would be greatly beneficial if SwiftProtobuf could be provided as an XCFramework to avoid this issue.

Kindly find the other details as follows:

  • Developing on Mac OS 14.6.1 (23G93) (Apple M1 Pro)

  • for macOS, version of Xcode Version 15.4 (15F31d)

  • Swift_version - 5.0

  • tag of SwiftProtobuf - 1.26.0

  • Crash - dyld[50182]: Symbol not found: _$s13SwiftProtobuf19_ProtoNameProvidingP17_protobuf_nameMapAA01_dH0VvgZTq
    Referenced from: //Library/Developer/CoreSimulator/Devices/6F58CF1E-7076-43C2-8CD3-75AA7BCA9827/data/Containers/Bundle/Application/6E33CC84-F7C0-4675-B04F-824EA2EB82E5/ProtobufBuildAnalysis.app/Frameworks/ZohoDeskPlatformUIKit.framework/ZohoDeskPlatformUIKit
    Expected in: <2B86F3DE-BBD4-3979-AEA5-8F626BC0BEB4> //Library/Developer/CoreSimulator/Devices/6F58CF1E-7076-43C2-8CD3-75AA7BCA9827/data/Containers/Bundle/Application/6E33CC84-F7C0-4675-B04F-824EA2EB82E5/ProtobufBuildAnalysis.app/Frameworks/SwiftProtobuf.framework/SwiftProtobuf

@Lukasa
Copy link
Contributor

Lukasa commented Sep 12, 2024

Thus far, the Swift Protobuf team have been reluctant to define a stable ABI for Protobuf (see #1101). For now we'd recommend that you use protobuf as a purely internal dependency of your framework (using internal import in Swift 6, or @_implementationOnly earlier). This will allow you to statically link it as you see fit.

@Lukasa Lukasa closed this as completed Sep 12, 2024
@allevato
Copy link
Collaborator

In addition to using internal import or @_implementationOnly, you should also use -module-alias to rename SwiftProtobuf to something else when it's embedded in your framework. That way, if one of your clients is also using SwiftProtobuf, the symbols in their copy and your framework don't collide.

@LakshmiChidambaranathan
Copy link
Author

LakshmiChidambaranathan commented Oct 21, 2024

@allevato , Could you kindly explain how to use -module-alias to rename SwiftProtobuf to something else when it's embedded in my framework. I actually have this case, where one of my client is also using SwiftProtobuf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants