Skip to content
📝 Read, update and write your Xcode projects
Swift Other
  1. Swift 99.0%
  2. Other 1.0%
Branch: master
Clone or download
pepibumur Merge pull request #477 from tuist/fix-tests
Fix the reference length
Latest commit 368fb87 Sep 17, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Don't run swiftformat May 3, 2019
.github Auto-invite contributors Dec 20, 2018
Assets Remove header Apr 30, 2018
Documentation Replace all pathes Sep 16, 2019
Fixtures Add onlyGenerateCoverageForSpecifiedTargets parameter to TestAction Sep 15, 2019
Sources/XcodeProj Fix the reference length Sep 17, 2019
Templates Fix issue with sourcery May 11, 2018
Tests Avoid warning about cases Sep 16, 2019
XcodeProj_Carthage.xcodeproj Rename Carthage project (tuist) Sep 9, 2019
XcodeProj_Carthage.xcworkspace Rename Carthage project (tuist) Sep 9, 2019
.editorconfig [jazzy] Add documentation Jul 1, 2017
.gitattributes add union merge for CHANGELOG Sep 23, 2018
.gitignore Modify some occurrences Sep 16, 2019
.jazzy.yaml Fix module Sep 16, 2019
.rspec [danger-carthage] Add a Danger plugin to check if the Carthage projec… Dec 13, 2017
.ruby-version Replace swiftlint with swiftformat Feb 27, 2019
.swift-version Add support for Swift 5 Apr 2, 2019
.swiftformat Replace swiftlint with swiftformat Feb 27, 2019
.swiftlint.yml Replace all pathes Sep 16, 2019
CHANGELOG.md Update CHANGELOG.md Sep 15, 2019
CODE_OF_CONDUCT.md Update broken link Mar 1, 2019
Cartfile Fix Carthage project May 2, 2019
Cartfile.resolved Fix Carthage project May 2, 2019
Dangerfile Don't run swiftformat May 3, 2019
Gemfile Bump danger-swiftlint from 0.22.0 to 0.23.0 Jul 30, 2019
Gemfile.lock Bump jazzy from 0.10.0 to 0.11.0 Sep 13, 2019
Info.plist Add Carthage compatibility Oct 12, 2018
LICENSE.md Rename xcproj to xcodeproj Apr 30, 2018
Package.resolved Add support for Swift 5 Apr 2, 2019
Package.swift update package to swift 5 Apr 5, 2019
Project.swift Rename Carthage project (tuist) Sep 9, 2019
README.md 7.0.1 Release (#471) Sep 12, 2019
RELEASE.md 7.0.1 Release (#471) Sep 12, 2019
Rakefile Rename Carthage project (tuist) Sep 9, 2019
sourcery.yml Replace all pathes Sep 16, 2019
xcodeproj.podspec 7.0.1 Release (#471) Sep 12, 2019

README.md

XcodeProj

CircleCI 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 in 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.0.1")),
        ],
    targets: [
        .target(
            name: "myproject",
            dependencies: ["XcodeProj"]),
        ]
)

Carthage

Only macOS

# Cartfile
github "tuist/xcodeproj" ~> 7.0.1

CocoaPods

pod 'xcodeproj', '~> 7.0.1'

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.0.1
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.

FOSSA Status

Open source

Tuist is a proud supporter of the Software Freedom Conservacy

Become a Conservancy Supporter!

You can’t perform that action at this time.