iOS26中ALAssetsLibrary 编译报错问题

mac os 系统版本:26.0 (25A354) Xcode版本:Version 26.0 (17A324)

项目编译报错

`SwiftExplicitDependencyCompileModuleFromInterface arm64 /Users/zhz/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/AssetsLibrary-HTIJ05N58KN3.swiftmodule

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk/usr/lib/swift/AssetsLibrary.swiftmodule/arm64e-apple-ios.swiftinterface:10:25: error: 'ALAssetsLibrary' is unavailable in iOS: Use PHPhotoLibrary from the Photos framework instead 8 | public import _StringProcessing 9 | public import _SwiftConcurrencyShims 10 | extension AssetsLibrary.ALAssetsLibrary { | `- error: 'ALAssetsLibrary' is unavailable in iOS: Use PHPhotoLibrary from the Photos framework instead 11 | #if compiler(>=5.3) && $NonescapableTypes 12 | @available(iOS, introduced: 9.0, deprecated: 9.0, obsoleted: 26.0)

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk/System/Library/Frameworks/AssetsLibrary.framework/Headers/ALAssetsLibrary.h:80:12: note: 'ALAssetsLibrary' was obsoleted in iOS 26.0 78 | 79 | OS_EXPORT AL_DEPRECATED(4, "Use PHPhotoLibrary from the Photos framework instead") 80 | @interface ALAssetsLibrary : NSObject { | `- note: 'ALAssetsLibrary' was obsoleted in iOS 26.0 81 | @package 82 | id _internal;

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS26.0.sdk/usr/lib/swift/AssetsLibrary.swiftmodule/arm64e-apple-ios.swiftinterface:1:1: error: failed to build module 'AssetsLibrary'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.17.14 clang-1700.3.17.1)', while this compiler is 'Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)'). Please select a toolchain which matches the SDK.

Answered by DTS Engineer in 858502022

Sadly, I can’t read Chinese, so I’m answering based on a machine translation.

I tried this out here in my office and saw exactly the same problem:

  1. Using Xcode 26.0, I created a new project from the iOS > App template.
  2. In one of the Swift files, I added the line import AssetsLibrary.
  3. The compiler errors with Failed to build module 'AssetsLibrary'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.17.14 clang-1700.3.17.1)', while this compiler is 'Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)'). Please select a toolchain which matches the SDK.

This is obviously a bug and I encourage you to file a report about it. Please post your bug number, just for the record.

Having said that, Assets Library was deprecated in iOS 9 and Xcode 26’s minimum supported deployment target, per the table on this page, is iOS 15. There is literally no way to use Xcode 26 to build an app for an iOS version where Assets Library is a recommended option. Thus, my suggestion is that you move away from this framework entirely.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

移除 Swift文件中的 import AssetsLibrary 就好了

Accepted Answer

Sadly, I can’t read Chinese, so I’m answering based on a machine translation.

I tried this out here in my office and saw exactly the same problem:

  1. Using Xcode 26.0, I created a new project from the iOS > App template.
  2. In one of the Swift files, I added the line import AssetsLibrary.
  3. The compiler errors with Failed to build module 'AssetsLibrary'; this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.17.14 clang-1700.3.17.1)', while this compiler is 'Apple Swift version 6.2 effective-5.10 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)'). Please select a toolchain which matches the SDK.

This is obviously a bug and I encourage you to file a report about it. Please post your bug number, just for the record.

Having said that, Assets Library was deprecated in iOS 9 and Xcode 26’s minimum supported deployment target, per the table on this page, is iOS 15. There is literally no way to use Xcode 26 to build an app for an iOS version where Assets Library is a recommended option. Thus, my suggestion is that you move away from this framework entirely.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

iOS26中ALAssetsLibrary 编译报错问题
 
 
Q