SDWebImage / SDWebImageSwiftUI

SwiftUI Image loading and Animation framework powered by SDWebImage
https://sdwebimage.github.io/SDWebImageSwiftUI
MIT License
2.1k stars 216 forks source link

Compiler error with swift 5.8 #259

Closed jackywpy closed 1 year ago

jackywpy commented 1 year ago

I have a compiler error when using xCode 14.3, swift 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)):

failed to verify module interface of 'SDWebImageSwiftUI' due to the errors above; the textual interface may be broken by project issues or a compiler bug.

截屏2023-04-06 11 07 20

thanks

dreampiggy commented 1 year ago

What build system did you use ? For example, when use SwiftPM and integrated Xcode support, you may need to add both SDWebImage and SDWebImageSwiftUI into Link Library and Frameworks of project build phase.

Willicious-k commented 1 year ago

@dreampiggy

encountered same issue here.

I used CocoaPods + Static setting like this.

build using Xcode 14.3

Podfile

platform :ios, '14.0'

target 'some-target-name' do
  # use_frameworks!

  pod 'SDWebImage', '5.12.1', :modular_headers => true
  pod 'SDWebImageSwiftUI', '2.2.2'

end
CveniEs commented 1 year ago

I also have same issue here,how to solve it. build using Xcode 14.3

higekick commented 1 year ago

same here !

dreampiggy commented 1 year ago

Will fix in later. These months have no time in iOS development, focus on LLVM/Swift toolchain.

Niccari commented 1 year ago

(Workaround, CocoaPods + Xcode 14.3)

Setting Project: Pods > Targets: SDWebImageSwiftUI > Build Settings > Build Libraries for Distribution to "No" and I was able to build the app.

dreampiggy commented 1 year ago

Is this the same issue as #261 ? See comments there

dreampiggy commented 1 year ago

@niccari Oh. You're using CocoaPods with Library Evolution on. The SPM does not enable Library Evolution, maybe this cause problem.

And, what cause CocoaPods use Library Evolution on ? I try that :modular_headers => true it does not enable this by default.

image

dreampiggy commented 1 year ago

@Willicious-k @higekick @Niccari Seems because of that Static Lib + Library Evolution YES cause the issue

Compile Failed (SDWebImage modular_headers => true)

image

Compile Succeed (SDWebImage use_frameworks => dynamic)

image

dreampiggy commented 1 year ago

Can you use the Static Framework integration to test ?

use_frameworks! :linkage => :static

image

Niccari commented 1 year ago

Seems because of that Static Lib + Library Evolution YES cause the issue

Agreed, I'm using Static Framework(not setting use_frameworks!) and Library Evolution YES in the project.

in Pods/Pods.xcodeproj/project.pbxproj, there was no "BUILD_LIBRARY_FOR_DISTRIBUTION" key and somehow "YES" used as defaults in the SDWebImageSwiftUI only so I'll investigate why it happens.

Checked below situations.

Niccari commented 1 year ago

@dreampiggy

And, what cause CocoaPods use Library Evolution on ? I try that :modular_headers => true it does not enable this by default.

In SDWebImageSwiftUI.podspec, it seems that swift interface needs to be generated and BUILD_LIBRARY_FOR_DISTRIBUTION is set to "yes". https://github.com/SDWebImage/SDWebImageSwiftUI/commit/056cc697131cc71946cd0b4bf25628e4cc43d25a

dreampiggy commented 1 year ago

Thanks! @Niccari

Seems that Podspec hack for BUILD_LIBRARY_FOR_DISTRIBUTION should be removed. I doubt what issue cause me to add this at that time (Xcode 12, 2 years agao....)

But seems this is the correcy way to go, since whether or not to enable Library Evolution is controlled by user who integrate, not the lib author