xcode-project-format README

The project's README from github.com/apple/xcode-project-format. As one markdown file: README.md.

xcode-project-format

xcode-project-format is a Swift library for reading, writing, and manipulating Xcode's JSON-based project.xcproj format. It models the format as a rich set of value types nested under a single namespace, XCSchema, so consumers get precise, typed access to a project's structure instead of hand-parsing JSON.

The goal is to give the ecosystem a shared, accurate model of the Xcode project format — so tools like generators, linters, verifiers, and validators don't each have to reverse-engineer the format from scratch.

The package also ships xcprojformatter, a small CLI tool built on the library.

Getting started

Requirements

Installation

Add the package as a dependency in your Package.swift:

dependencies: [
    .package(url: "https://github.com/apple/xcode-project-format/", from: "0.1.0")
]

Usage

import XcodeProjectFormat

func listTargets(in projectURL: URL) throws {
    let projectData = try Data(contentsOf: projectURL)
    let project = try XCSchema.Project(jsonRepresentation: projectData)
    for target in project.targets {
        print(target.name)
    }
}

You'll find types for folders, file references, groups, targets, build phases, build rules, and the rest of the Xcode project model within this package.

Documentation

The project documentation is available at Swift Package Index.

To preview it locally:

swift package add-dependency https://github.com/swiftlang/swift-docc-plugin --from 1.5.0
swift package --disable-sandbox preview-documentation

Contributing

We welcome contributions within a defined scope. See CONTRIBUTING.md for what we accept, what's out of scope for now, and how to get started.

Support

License

Licensed under the Apache License 2.0.

xcode-project-format (apple/xcode-project-format)

Searching Database…

这是干什么的?这是 Apple 出品的一个 Swift 库,用于读取、写入和操作 Xcode 基于JSON的 project.xcproj 格式,还附带一个名为 'xcprojformatter' 的小型命令行工具。
它是库还是命令行工具?两者都是。核心是一个库,它把项目格式建模为统一命名空间 'XCSchema' 下的带类型的值类型;这个包还附带 'xcprojformatter',一个基于该库构建的小型命令行工具。
怎么把它加到我的项目里?通过 Swift Package Manager 在你的 Package.swift 中把它添加为依赖。
它需要哪个版本的 Swift 和 macOS?需要 Swift 6.1 或更高版本,以及 macOS 14 或更高版本。
它是给谁用的,App 开发者还是工具开发者?主要面向工具开发者:目标是提供一个共享且准确的 Xcode 项目格式模型,这样生成器、代码检查工具、校验器和验证器就不用各自从零开始逆向解析这个格式。
它只能在 Mac 上用,还是我在 Linux 上也能构建?并非只能用 Mac:官方要求是 macOS 14+,但 README 提到这个库也能在非 Darwin 平台上构建,具体细节见 Package.swift。
XCSchema 模型覆盖了 Xcode 项目的哪些部分?XCSchema 的类型涵盖了文件夹、文件引用、分组、target、构建阶段、构建规则,以及 Xcode 项目模型的其余部分。
为什么用它,而不是自己解析项目文件里的 JSON?你不必手工解析原始 JSON,而是能以精确、带类型的方式访问项目的结构,并且背后有一个共享而准确的格式模型做支撑。
Creator
apple
Size
0.1 MB
Stars
501
Updated
CommitOct 08
Age
1mo
Commits · 90 Days