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

Enables support for distributing Lottie as a binary library #1173

Closed
wants to merge 1 commit into from
Closed

Enables support for distributing Lottie as a binary library #1173

wants to merge 1 commit into from

Conversation

devioustree
Copy link

This fixes #1081.

Solution

To allow frameworks to be used by multiple Swift version, we need to set:

BUILD_LIBRARY_FOR_DISTRIBUTION = YES

This isn't necessary for a Swift package (since they are build from source), but it's useful for Carthage or other means of distributing binary frameworks.

Testing

I built Lottie.framework in Xcode 11.3.1. Then in Xcode 11.4 I created a test project and linked to the generated project. It built and linked successfully.

This fixes #1081.

**Solution**

To allow frameworks to be used by multiple Swift version, we need to set:

```
BUILD_LIBRARY_FOR_DISTRIBUTION = YES
```

This isn't necessary for a Swift package (since they are build from source),
but it's useful for Carthage or other means of distributing binary frameworks.

**Testing**

I built `Lottie.framework` in Xcode 11.3.1. Then in Xcode 11.4 I created a
test project and linked to the generated project. It built and linked
successfully.
@Cyberbeni
Copy link
Contributor

I think you just need to run carthage bootstrap in your build phase and it will rebuild the library if it was built with a different Swift version. At least when downloading the prebuilt binary, Swift version is checked to be compatible: https://github.com/Carthage/Carthage#swift-binary-framework-download-compatibility
If that doesn't work, then it's a Carthage issue.

@Cyberbeni
Copy link
Contributor

This was also discussed in the CocoaPods repo: CocoaPods/CocoaPods#9232 (comment)

@devioustree
Copy link
Author

Rebuilding is a workaround, but it would be nice to enable this since the Swift toolchain now supports it.

@Cyberbeni
Copy link
Contributor

Read the discussion I linked.

@devioustree
Copy link
Author

Is your concern that the performance would be degraded?

@Cyberbeni
Copy link
Contributor

That is one of the concerns. 3.x is already bad enough to warrant people opening issues and using 2.x.
But the point is still that BUILD_LIBRARY_FOR_DISTRIBUTION is meant for libraries that are distributed separately from apps. Carthage just provides a better version of DerivedData, so Xcode gets confused by the amount of code less often.

Seeing that this repository doesn't provide prebuilt binaries (that can still be used with the same Xcode version that they were built with, even without this flag), this could also introduce differences between the same version on different machines even if they are using the same Xcode version currently. Sure, that doesn't happen with every Xcode release but trust me, it's not fun to go crazy about a mysterious bug.

@calda
Copy link
Member

calda commented Feb 1, 2022

This imposes a large amount of constraints on the public API of a framework, so I don't think we should enable it for Lottie.

From "Library Evolution in Swift":

Library evolution support is turned off by default. Frameworks that are always built and distributed together, such as Swift Package Manager packages or binary frameworks that are internal to your app, should not be built with library evolution support.

Library evolution support should only be used when a framework is going to be built and updated separately from its clients.

@calda calda closed this Feb 1, 2022
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

Successfully merging this pull request may close these issues.

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler
3 participants