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
Set BUILD_LIBRARY_FOR_DISTRIBUTION when the user target has it set #9232
Comments
@juanjonol want to make a PR for it? |
@juanjonol can you provide a bit more information under what conditions should |
@dnkoutso So if your target is a library with that flag set, then the pods should be installed that way. Otherwise you’ll get Another use case to think of: you have binary pod vendoring an .xcframework. Its (Swift) dependencies should be installed with the flag set to |
First, sorry for taking this long to respond.
What @tamastimar has said is correct:
The simplest way I can think of solving this is just looking up if I hope this makes sense. I don't see this covered in #9334, but I haven't looked it closely.
I didn't have time to do it, but if @amorde confirms that this is not covered in #9334 I'll look into it this week. |
#9334 doesn't cover this, that was only for supporting vendored XCFrameworks. This sounds like a reasonable change. To confirm, this is for the case where CocoaPods is being used to pull in dependencies for a framework or static library, correct? target 'MyFramework' do
...
end |
Yes I want to know the answer to this too and that is what I mean in my original question. I want us to be explicit on when this logic should run, for what type of targets etc. |
I've run through #9334 and I can't see that Should I open another issue for the case of dependencies of vendored XCFrameworks? |
Sorry for not being clear enough. This is to pull dependencies for a framework, but that can be done when the target is the framework itself or when the target is an app that embeds that framework. For example, given a framework with this podfile: target 'MyXCFramework' do
pod 'MyXCFrameworkDependency'
end That But also, if an application uses target 'MyApp' do
pod 'MyXCFramework'
end Because Finally, if an app has target 'MyApp' do
pod 'MyXCFrameworkDependency'
end Although |
Yep, propagating this from the user target to its dependencies sounds reasonable to me. One thing that's a bit confusing here is the mention of XCFramework targets - Xcode doesn't support .xcframeworks as a product type as far as I'm aware. So this is really for framework targets right? Regarding the mention of dependencies of the xcframework itself, there's no way for CocoaPods to know what dependencies are used by the vendored xcframework vs. the pod itself. For example, let's say I have target 'FrameworkXYZ' do
# FrameworkXYZ has `BUILD_LIBRARY_FOR_DISTRIBUTION` set to 'YES',
# so we will apply that to BananaLib as well
pod 'BananaLib'
end Shipping this inside of a pod might look like this: Pod::Spec.new do |s|
s.name = 'AwesomeLib'
s.source_files = 'Source/**/*.swift'
# ...
s.vendored_framework 'FrameworkXYZ.xcframework'
# Should CocoaPods set `BUILD_LIBRARY_FOR_DISTRIBUTION=YES` to 'BananaLib'?
s.dependency 'BananaLib'
end CocoaPods doesn't know if Totally possible I'm misunderstanding something here so please correct me if that's the case |
If a vendored XCFramework is present, would automatic application have any drawbacks ? Why does it matter if |
That's right, Xcode doesn't generate XCFrameworks directly, they must be created with
That's correct too.
I think you're understanding this correctly. This is why I think that, if
That's a good question. Maybe even |
@amorde After trying Besides that it integrates the XCFramework nicely. 👍 Thanks for your work! |
Not in the way that BUILD_LIBRARY_FOR_DISTRIBUTION is for. Swift Library Evolution makes it so that you can link an application against one version of a Swift library, then upgrade the library to a newer version without rebuilding the application. This is very important for system libraries, but it's not really applicable to cocoapods. Enabling BUILD_LIBRARY_FOR_DISTRIBUTION by default would just make everything a bit slower for no clear benefit, and it changes how the swift/obj-c runtime integration works. |
Yes, this is why I'd like to avoid applying that setting by default. I think we could do something like propagate it to dependencies if its in the podspec: s.pod_target_xcconfig = {
# this could theoretically apply to any `s.dependency` as well
'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES'
} However, it might make more sense to build out Podspec DSL for this. In the meantime pod consumers can use a |
Starting to think that it seems kinda hard to converge on simple concrete cases in which this will always apply therefore I am inclined to just let that be managed by post install hooks. The most concrete case is to do what we did for What do folks think? |
Would it work if the flag comes from a Podspec? I.e., spec.user_target_xcconfig = { 'BUILD_LIBRARY_FOR_DISTRIBUTION' => 'YES' } |
Thank you for the clarification. This is important for vendored frameworks too, but I agree this shouldn't be enabled by default.
I agree. Like
This would work too. |
Could anyone help me with this? At first So how I could set |
Have you solved the problem? Seems like you should use post_install hook in |
@Alex-Anyvision nope. Currently I use post_install hook as you mentioned but this is not best choice because |
…le to set BUILD_LIBRARY_FOR_DISTRIBUTION=yes for dependencies to prevent crash (cocoapods does not seem to support this automatically as of version 1.11.3 (see CocoaPods/CocoaPods#9232 and more))
Report
When using a project that has the
BUILD_LIBRARY_FOR_DISTRIBUTION
set toYES
, the Pods included should have this setting applied too, to avoid the warnings"Module '<pod_name>' was not compiled with library evolution support; using it means binary compatibility for '<project>' can't be guaranteed.
.This is the same that was done for the
APPLICATION_EXTENSION_API_ONLY
Build Setting in #4321.Related to #9148, as the
BUILD_LIBRARY_FOR_DISTRIBUTION
setting is needed for XCFrameworks.What did you do?
BUILD_LIBRARY_FOR_DISTRIBUTION
toYES
.pod install
to install any pod.What did you expect to happen?
The pods should be installed with the
BUILD_LIBRARY_FOR_DISTRIBUTION
set toYES
.What happened instead?
The pods are installed with the default value of
BUILD_LIBRARY_FOR_DISTRIBUTION
(NO
) and a warning is generated for every pod.Workaround
Use a
post_install
hook to setBUILD_LIBRARY_FOR_DISTRIBUTION
toYES
in all pods.The text was updated successfully, but these errors were encountered: