Swiftpack.co - Package - tuist/XcodeProj

XcodeProj

All Contributors

Swift Package Manager Release Code Coverage Slack License

XcodeProj is a library written in Swift for parsing and working with Xcode projects. It's heavily inspired by CocoaPods XcodeProj and xcode.


Projects Using XcodeProj

Project Repository
Tuist github.com/tuist/tuist
Sourcery github.com/krzysztofzablocki/Sourcery
ProjLint github.com/JamitLabs/ProjLint
XcodeGen github.com/yonaskolb/XcodeGen
xspm gitlab.com/Pyroh/xspm

If you are also leveraging XcodeProj in your project, feel free to open a PR to include it in the list above.

Installation

Swift Package Manager

Add the dependency in your Package.swift file:

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

Carthage

Only macOS

# Cartfile
github "tuist/xcodeproj" ~> 7.11.

CocoaPods

pod 'xcodeproj', '~> 7.18.0

Scripting

Using swift-sh you can automate project-tasks using scripts, for example we can make a script that keeps a project’s version key in sync with the current git tag that represents the project’s version:

#!/usr/bin/swift sh
import Foundation
import XcodeProj  // @tuist ~> 7.11.
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)

You could then store this in your repository, for example at scripts/set-project-version and then run it:

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

Future adaption could easily include determining the version and bumping it automatically. If so, we recommend using a library that provides a Version object.

Documentation 📝

Want to start using XcodeProj? Start by digging into our documentation which will help you get familiar with the API and get to know more about the Xcode projects structure.

References 📚

Contributing

  1. Git clone the repository git@github.com:tuist/xcodeproj.git.
  2. Generate xcodeproj with swift package generate-xcodeproj.
  3. Open XcodeProj.xcodeproj.

License

XcodeProj is released under the MIT license. See LICENSE for details.

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Github

link
Stars: 1281

Dependencies

Releases

7.18.0 - Penguin -

7.18.0 - Penguin

Added

  • Support for building and running on Linux. #585 by @elliottwilliams. Tested for compatibility with Swift 5.3 on Ubuntu 18.04. XcodeProj requires FoundationXML / libxml2, which is part of the standard Swift Linux toolchain but not necessarily available in all environments.

7.17.0 - Tempelhof -

Added

7.16.0 - Cieza -

Added

  • Set the right module_name in the .podspec. #578 by @dflems

7.15.0 - Marea -

Fixed

Added

7.14.0 -

Fixed

Added

7.13.0 -

Added

7.12.0 -

Added

7.11.1 -

Added

7.11.0 -

Changed

Added

Fixed

7.8.0 -

Added

Fixed

7.10.0 -

Changed

7.9.0 -

Changed

Fixed

7.7.0 -

Fixed

7.6.0 -

Changed

Fixed

Added

7.5.0 -

Fixed

7.4.0 -

Changed

7.3.0 -

Changed

7.2.2 -

Fixed

7.2.1 -

7.2.0 -

Added

Fixed

7.1.0 -

Added

7.0.1 -

Changed

Added

Fixed

7.0.0 -

Changed

Added

Fixed

Removed

6.7.0 -

Changed

Added

6.6.0 -

Fixed

Added

Changed

6.5.0 -

Changed

Added

6.4.0 -

Added

6.3.0 -

Added

Fixed

6.2.0 -

Added

Changed

6.1.0 -

Added

Changed

Fixed