onevcat/Kingfisher

Kingfisher v6 failed to build on Xcode 13 beta and RC

ankitpanchotiya99138 opened this issue · 31 comments

Hello,
Can any one help me I have face issue on Accelerate. I user Latest xcode 13 beta.

Failed to build module 'Accelerate'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5 (swiftlang-1300.0.17.216 clang-1300.0.18.1)', while this compiler is 'Apple Swift version 5.5 (swiftlang-1300.0.19.104 clang-1300.0.18.4)'). Please select a toolchain which matches the SDK.

Screenshot 2021-06-12 at 8 53 54 AM

I believe it is a bug in the beta version of Xcode. Some less-used system frameworks were built with a different compiler and bundled in this version (there are Accelerate, Network and more).

I suggest waiting for the next beta two weeks later.

Ok Thanks for the quick response.

Duplicated with #1736

so just gotta wait for Xcode to fix kk, any day they should have update...

vd-ba commented

Looks like there is similar issue with Xcode 13 Beta 2, albeit with different swift compiler version:

Local setup: ❌ /Users/********/Library/Developer/Xcode/DerivedData/MyApp-drgvolpecatijzcuichjljjshvoi/SourcePackages/checkouts/Kingfisher/Sources/Image/ImageDrawing.swift:27:8: failed to build module 'Accelerate'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.5 (swiftlang-1300.0.20.4 clang-1300.0.21.1)', while this compiler is 'Apple Swift version 5.5 (swiftlang-1300.0.20.104 clang-1300.0.21.1)'). Please select a toolchain which matches the SDK.

This seems only happens for SPM and it requires a minimum target iOS 12 to build successfully. I don't think this is reasonable and it is definitely an issue of the build system (unless Apple officially confirms they want to drop any deploy target below iOS 12)

I updated the package file in the fix/xcode-13 branch. So if you already have a deploy target equal or above iOS 12, you can switch to the master branch now to archive your project. However, I still suggest wait for another beta to see how it can change. (As far as I can say, beta 2 shipped with the same build system as in beta 1, so it is not surprising the same thing happens.)

I will see if we really need to drop any early versions before iOS 12 and decide to merge the fix/xcode-13 to master in the future.

Ref commit: f012224

vd-ba commented

This seems only happens for SPM and it requires a minimum target iOS 12 to build successfully. I don't think this is reasonable and it is definitely an issue of the build system (unless Apple officially confirms they want to drop any deploy target below iOS 12)

I updated the package file in the fix/xcode-13 branch. So if you already have a deploy target equal or above iOS 12, you can switch to the master branch now to archive your project. However, I still suggest wait for another beta to see how it can change. (As far as I can say, beta 2 shipped with the same build system as in beta 1, so it is not surprising the same thing happens.)

I will see if we really need to drop any early versions before iOS 12 and decide to merge the fix/xcode-13 to master in the future.

Ref commit: f012224

Thanks, works fine 👍. Will do for now, hopefull Apple will get it fixed.

This resolved with Beta 3?

This resolved with Beta 3?

NO...

I just tried it and it worked

I can confirm a similar issue is still happening in Xcode 13 beta 3 when archiving a project.

However, it is now complaining about Combine instead of the original Accelerate. It seems that Apple is now building Accelerate with the same compiler, but not Combine yet.

There is some progress and I need to keep looking on it. If at last we cannot have a stable situation, we have to upgrade the deploy target in the SPM from .v10 to .v12 to make compiler happy.

This is marked as a known issue in Xcode 13 beta 5 release note:

Swift libraries may fail to build for iOS targets that use armv7. (74120874)
Workaround: Increase the platform dependency of the package to v12 or later.

So I believe Apple would fix it later in a release version. Let me see...

Is the iOS 10 & 11 developer market big enough to warrant support?

There is no way for now to support it in Kingfisher, since it is an Apple issue. Even though, I guess it is very little meaning to continue support iOS 10 and 11 since they are only 0.5% share in total. But let's see how the next Xcode can work, which is the pre-condition.

截屏2021-08-28 10 52 59

still happening on Xcode 13 GM

running works, archiving outputs this crap:
trying to archive

@rursache No way......... JFC

This is marked as a known issue in Xcode 13 beta 5 release note:

Swift libraries may fail to build for iOS targets that use armv7. (74120874)
Workaround: Increase the platform dependency of the package to v12 or later.

So I believe Apple would fix it later in a release version. Let me see...

At least this known issue is still there in Xcode 13 RC release note today. So I guess it is just an official announcement of "Dropping iOS 11 and below" to us library maintainers. Kingfisher v7 (currently in beta) is already setting its deploy target to iOS 12. If anyone needs it, please check the migration guide.

Xcode 13 it's out now. Will v7 be available soon? I'd prefer to wait a little than having to change back from 7 beta after a few hours

Same problem here with public version of Xcode 13

I am going with some final check and will tag v7 soon.

It is not a thing can be fixed in Kingfisher. See #1802 (comment)

There are basically two choice:

  1. If you do not need to support iOS 11 and below, upgrade to Kingfisher v7 then you can use it with Xcode 13.
  2. Or, if unfortunately you still need to work for iOS 10 or 11, you have to keep using Kingfisher v6 and Xcode 12.x for a while, and pray that Apple will fix it in Xcode 13.1 or later.

Hello, @onevcat
I sincerely appreciate your efforts to cover all issues from Xcode 13.

I looked into the branches, release/version6 and fix/xcode-13, and ended up that those separated branches might not be helpful for someone using v6 with setting up the minimum target to under ios13 and struggling with the Xcode issue.

If you pick fix/xcode-13, you can't resolve the loadImmediately issue.
If you pick release/version6, you are still in trouble with the Xcode 13 issue.

I'd like to suggest you bring back loadImmediately method to the release/version6 if you regard this branch to be used as the latest v6.

Xcode13 public version is also same problem

still happening on Xcode 13 GM

running works, archiving outputs this crap:
trying to archive

my project using Kingfisher by cocoapods and need to support iOS 10, i occurred the some error,
in my project i don't using swiftui, i fix this error in ruby script.
Podfile

platform :ios, '10.0'
use_modular_headers!
inhibit_all_warnings!
...
pre_install do |installer|
    remove_swiftui()
end

def remove_swiftui
  # 解决 xcode13 Release模式下SwiftUI报错问题
  system("rm -rf ./Pods/Kingfisher/Sources/SwiftUI")
  code_file = "./Pods/Kingfisher/Sources/General/KFOptionsSetter.swift"
  code_text = File.read(code_file)
  code_text.gsub!(/#if canImport\(SwiftUI\) \&\& canImport\(Combine\)(.|\n)+#endif/,'')
  system("rm -rf " + code_file)
  aFile = File.new(code_file, 'w+')
  aFile.syswrite(code_text)
  aFile.close()
end

i hope i can help you.

use_modular_headers!

你好,我直接复制粘贴你的东西,我把你的东西放在target '项目名' do ... end ,也解决不了啊???需要怎么弄????

@pangyunxiu
你的描述比较模糊,不清楚你遇到的是否和我一样的问题,我试了下放在target 'xxx' do ... end 里面也是仍然起效的。

still happening on Xcode 13 GM
running works, archiving outputs this crap:
trying to archive

my project using Kingfisher by cocoapods and need to support iOS 10, i occurred the some error, in my project i don't using swiftui, i fix this error in ruby script. Podfile

platform :ios, '10.0'
use_modular_headers!
inhibit_all_warnings!
...
pre_install do |installer|
    remove_swiftui()
end

def remove_swiftui
  # 解决 xcode13 Release模式下SwiftUI报错问题
  system("rm -rf ./Pods/Kingfisher/Sources/SwiftUI")
  code_file = "./Pods/Kingfisher/Sources/General/KFOptionsSetter.swift"
  code_text = File.read(code_file)
  code_text.gsub!(/#if canImport\(SwiftUI\) \&\& canImport\(Combine\)(.|\n)+#endif/,'')
  system("rm -rf " + code_file)
  aFile = File.new(code_file, 'w+')
  aFile.syswrite(code_text)
  aFile.close()
end

i hope i can help you.

确实可以

问题的关键是armv7不支持,而不是iOS 10 系统的问题
所以应该是设置只编译arm64架构即可
毕竟都2021年了,arm64从iphone5s开始,你想支持iPhone5估计也没有用户了。

所以用以下方式可以,解决编译问题,
并支持version 6,xcode 13,iOS 10+,不用删除swiftUI,不用升级iOS target

解决方法1 :参见 pr 1853
#1853

解决方法2 :若不更新podspec ,可本地更新
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if target.name == "Kingfisher"
config.build_settings['EXCLUDED_ARCHS'] = "armv7"
end
end
end
end

若pod工程使用generate_multiple_pod_projects: true 时,获取 target用如下方式
installer_representation.pod_target_subprojects.flat_map { |p| p.targets }.each do |target|

I reproduced a build failure on Xcode 13 RC with Kingfisher 6.1.1, then found that updating Kingfisher to 7.1.1 fixed it.

#if canImport(SwiftUI) && canImport(Combine)
改成
#if canImport(SwiftUI) && canImport(Combine) && (arch(arm64) || arch(x86_64))

太感谢了,苹果真心坑啊,哎