XcodeProj

All Contributors

Swift Package Manager Release Code Coverage License

XcodeProj 是一个用 Swift 编写的库,用于解析和处理 Xcode 项目。它深受 CocoaPods XcodeProjxcode 的启发。


使用 XcodeProj 的项目

项目 仓库
ProjLint github.com/JamitLabs/ProjLint
rules_xcodeproj github.com/buildbuddy-io/rules_xcodeproj
Rugby github.com/swiftyfinch/Rugby
Sourcery github.com/krzysztofzablocki/Sourcery
Tuist github.com/tuist/tuist
XcodeGen github.com/yonaskolb/XcodeGen
xspm gitlab.com/Pyroh/xspm

如果您也在您的项目中使用 XcodeProj,请随时开启 PR 将其包含在上面的列表中。

安装

Swift Package Manager

在您的 Package.swift 文件中添加依赖项

let package = Package(
    name: "myproject",
    dependencies: [
        .package(url: "https://github.com/tuist/XcodeProj.git", .upToNextMajor(from: "8.9.0")),
    ],
    targets: [
        .target(
            name: "myproject",
            dependencies: ["XcodeProj"]),
        ]
)

Carthage

仅 macOS

# Cartfile
github "tuist/xcodeproj" ~> 8.8.0

CocoaPods

pod 'xcodeproj', '~> 8.8.0

脚本

使用 swift-sh,您可以使用脚本自动化项目任务,例如,我们可以创建一个脚本,使项目的版本密钥与代表项目版本的当前 git 标签保持同步

#!/usr/bin/swift sh
import Foundation
import SwiftXcodeProj  // @stackotter ~> 8.8.0
import PathKit

guard CommandLine.arguments.count == 3 else {
    let arg0 = Path(CommandLine.arguments[0]).lastComponent
    fputs("usage: \(arg0) <project> <new-version>\n", stderr)
    exit(1)
}

let projectPath = Path(CommandLine.arguments[1])
let newVersion = CommandLine.arguments[2]
let xcodeproj = try XcodeProj(path: projectPath)
let key = "CURRENT_PROJECT_VERSION"

for conf in xcodeproj.pbxproj.buildConfigurations where conf.buildSettings[key] != nil {
    conf.buildSettings[key] = newVersion
}

try xcodeproj.write(path: projectPath)

然后您可以将其存储在您的仓库中,例如在 scripts/set-project-version,然后运行它

$ scripts/set-project-version ./App.xcodeproj 1.2.3
$ git add App.xcodeproj
$ git commit -m "Bump version"
$ git tag 1.2.3

未来的调整可以轻松地包括确定版本并自动递增版本号。如果是这样,我们建议使用提供 Version 对象的库。

文档 📝

想要开始使用 XcodeProj 吗?首先深入研究我们的文档,这将帮助您熟悉 API 并更多地了解 Xcode 项目的结构。

参考资料 📚

贡献

  1. Git 克隆仓库 git@github.com:tuist/xcodeproj.git
  2. 使用 Xcode 打开 Package.swift

许可证

XcodeProj 在 MIT 许可证下发布。有关详细信息,请参阅 LICENSE

贡献者 ✨

感谢这些出色的人们 (请参阅表情符号键)

Joseph Colicchio
Joseph Colicchio

🤔
deatondg
deatondg

🤔
Dan Fleming
Dan Fleming

💻
Sascha Schwabbauer
Sascha Schwabbauer

🤔
Marcin Iwanicki
Marcin Iwanicki

🚧
Adam Khazi
Adam Khazi

🚧
Elliott Williams
Elliott Williams

💻
Muukii
Muukii

🖋
Yuya Oka
Yuya Oka

💻
Keith Smiley
Keith Smiley

🖋
Ian Leitch
Ian Leitch

💻
Daniil Subbotin
Daniil Subbotin

💻
Florentin Bekier
Florentin Bekier

💻
Vadim Smal
Vadim Smal

🐛
freddi(Yuki Aki)
freddi(Yuki Aki)

💻
Kristopher Jackson
Kristopher Jackson

💻
Jake Prickett
Jake Prickett

💻
Jake Adams
Jake Adams

💻
matsuji
matsuji

💻
Bogdan Belogurov
Bogdan Belogurov

💻
Chuck Grindel
Chuck Grindel

💻
Michael McGuire
Michael McGuire

💻
C-凡
C-凡

💻
Maxwell Elliott
Maxwell Elliott

💻
Brentley Jones
Brentley Jones

💻
Teameh
Teameh

💻
Johannes Ebeling
Johannes Ebeling

💻
baegteun
baegteun

📖
Alex Kovács
Alex Kovács

📖

本项目遵循 all-contributors 规范。欢迎任何形式的贡献!