xcframework-maker

swift 5.4 platform macOS SPM supported

macOS 实用工具,用于将胖框架转换为与 SPM 兼容的 XCFramework,并支持 arm64-simulator。

📝 描述

make-xcframework 是一个用 Swift 编写的简单命令行实用工具,用于从胖框架文件创建 XCFramework 文件。生成的 XCFramework 文件可以作为依赖项添加到您的 Swift Package 中,使用 .binaryTarget (更多信息请阅读 官方文档)。

可选地,可以将 arm64-simulator 支持包含在生成的 XCFramework 中,以允许在具有 Apple Silicon (M1) 处理器的计算机上进行开发,而无需通过 Rosetta 运行 Xcode。

xcframework-maker Swift Package 包含 make-xcframework,可以从命令行使用,以及 XCFrameworkMaker 库,您可以将其与您的 Swift Package 集成并以编程方式使用。

注意: arm64-to-sim 用于“破解”原生(设备)arm64 架构切片,使其可以在 Apple Silicon 上运行的模拟器中使用。 这是一个实验性功能,并且 可能因多种原因而失败。它经过测试并证明可以与 GoogleInteractiveMediaAds 动态胖框架一起使用,但您的体验可能会有所不同。

🛠 构建

使用 Swift 5.4 在 macOS 上构建实用工具

swift build -c release

您可以复制可执行文件或直接从构建目录运行它

.build/release/make-xcframework

▶️用法

OVERVIEW: Utility for creating XCFramework from legacy fat-framework files.

Use this tool to create XCFramework from legacy fat-framework files. Resulting XCFramework can be
added as a dependency to your Swift Package. Optionally arm64-simulator support can be included in
the resulting XCFramework, so it can be used on M1 Mac without the need to run Xcode through
Rosetta.

USAGE: make-xcframework [-ios <path>] [-tvos <path>] [-arm64sim] -output <path> [-verbose]

OPTIONS:
  -ios <path>             iOS input framework path.
        Provide a path to the iOS fat framework that should be included in the resulting
        XCFramework. Eg "path/to/iOS/Framework.framework"
  -tvos <path>            tvOS input framework path.
        Provide a path to the tvOS fat framework that should be included in the resulting
        XCFramework. Eg "path/to/tvOS/Framework.framework"
  -arm64sim               Add support for arm64 simulator.
        Use device-arm64 architecture slice as a simulator-arm64 architecture slice and include it
        the resulting XCFramework. This makes development possible on M1 Mac without using Rosetta.
  -output <path>          Output directory path.
        Provide a path to a directory where the resulting XCFramework should be created. Eg
        "path/to/output/directory"
  -verbose                Log detailed info to standard output.
        When this flag is provided, detailed information about each performed action is logged to
        standard output.
  -help, -h               Show help information.

示例 - GoogleInteractiveMediaAds

  1. 从 Google 网站下载 GoogleInteractiveMediaAds 胖框架

  2. 解压下载的文件。

  3. 运行 make-xcframework

    make-xcframework \
      -ios path/to/ios/GoogleInteractiveMediaAds.framework \
      -tvos path/to/tvos/GoogleInteractiveMediaAds.framework \
      -arm64sim \
      -output output/path
  4. 生成的 XCFramework 将在提供的输出目录中创建

    output/path/GoogleInteractiveMediaAds.xcframework

☕️ 你喜欢这个项目吗?

Buy Me A Coffee

📄 许可证

版权所有 © 2021 Dariusz Rybicki Darrarski

许可证:MIT