//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2021-2024 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
import class Basics.InMemoryFileSystem
import SPMBuildCore
import Testing
struct XCFrameworkMetadataTests {
@Test
func parseFramework() throws {
let fileSystem = InMemoryFileSystem(files: [
"/Info.plist": """
AvailableLibraries
LibraryIdentifier
macos-x86_64
LibraryPath
MyFramework.framework
SupportedArchitectures
x86_64
SupportedPlatform
macos
LibraryIdentifier
ios-arm64_x86_64-simulator
LibraryPath
MyFramework.framework
SupportedArchitectures
arm64
x86_64
SupportedPlatform
ios
SupportedPlatformVariant
simulator
CFBundlePackageType
XFWK
XCFrameworkFormatVersion
1.0
""",
])
let metadata = try XCFrameworkMetadata.parse(fileSystem: fileSystem, rootPath: .root)
let expected = XCFrameworkMetadata(
libraries: [
XCFrameworkMetadata.Library(
libraryIdentifier: "macos-x86_64",
libraryPath: "MyFramework.framework",
headersPath: nil,
platform: "macos",
architectures: ["x86_64"],
variant: nil
),
XCFrameworkMetadata.Library(
libraryIdentifier: "ios-arm64_x86_64-simulator",
libraryPath: "MyFramework.framework",
headersPath: nil,
platform: "ios",
architectures: ["arm64", "x86_64"],
variant: "simulator"
),
],
)
#expect(metadata == expected)
}
@Test
func parseLibrary() throws {
let fileSystem = InMemoryFileSystem(files: [
"/Info.plist": """
AvailableLibraries
LibraryIdentifier
macos-x86_64
HeadersPath
Headers
LibraryPath
MyLibrary.a
SupportedArchitectures
x86_64
SupportedPlatform
macos
CFBundlePackageType
XFWK
XCFrameworkFormatVersion
1.0
""",
])
let metadata = try XCFrameworkMetadata.parse(fileSystem: fileSystem, rootPath: .root)
let expected = XCFrameworkMetadata(
libraries: [
XCFrameworkMetadata.Library(
libraryIdentifier: "macos-x86_64",
libraryPath: "MyLibrary.a",
headersPath: "Headers",
platform: "macos",
architectures: ["x86_64"],
variant: nil
),
],
)
#expect(metadata == expected)
}
}