readAppleSliceCandidates function
Reads the small subset of the XCFramework property list needed for slice selection. XCFramework Info.plists are XML, so keeping this parser local avoids making the build hook depend on a platform-specific plist utility.
Implementation
List<AppleSliceCandidate> readAppleSliceCandidates(File infoPlist) {
final document = _PlistParser(infoPlist.readAsStringSync()).parse();
final libraries = document is Map ? document['AvailableLibraries'] : null;
if (libraries is! List) return const [];
return [
for (final library in libraries.whereType<Map>())
if (library['LibraryIdentifier'] is String &&
library['LibraryPath'] is String &&
library['SupportedPlatform'] is String)
AppleSliceCandidate(
identifier: library['LibraryIdentifier'] as String,
libraryPath: library['LibraryPath'] as String,
platform: library['SupportedPlatform'] as String,
variant: library['SupportedPlatformVariant'] as String?,
architectures: {
for (final architecture
in (library['SupportedArchitectures'] is List
? (library['SupportedArchitectures'] as List)
: const <Object?>[]))
if (architecture is String) architecture,
},
),
];
}