Swiftpack.co - Package - tuist/xcodeproj

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.

This project is a fork and evolution from xcproj


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 |

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: "6.5.0")),
        ],
    targets: [
        .target(
            name: "myproject",
            dependencies: ["xcodeproj"]),
        ]
)

Carthage

Only macOS

# Cartfile
github "tuist/xcodeproj" ~> 6.5.0

CocoaPods

pod 'xcodeproj', '~> 6.5.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 ~> 6.5
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.

Usage

You can check out the documentation on the following link. The documentation is automatically generated in every release by using Jazzy from Realm.

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!

Github

link
Stars: 879
Help us keep the lights on

Dependencies

Releases

6.5.0 - Feb 2, 2019

Changed

  • Make Xcode.Supported.xcschemeFormatVersion public https://github.com/tuist/xcodeproj/pull/361 by @yonaskolb.

Added

  • Fix remote target dependency https://github.com/tuist/xcodeproj/pull/362 by @mxcl.

6.4.0 - Jan 6, 2019

Added

  • Added projReferenceFormat to PBXOutputSettings to allow changing the output format of generated references. withPrefixAndSuffix will give the legacy behaviour xcode will generate 32 character references as XCode does. https://github.com/tuist/xcodeproj/pull/345 by @samskiter.
  • Danger https://github.com/tuist/xcodeproj/pull/357 by @pepibumur.
  • Support for WorkspaceSettings https://github.com/tuist/xcodeproj/pull/359 by @pepibumur.

6.3.0 - Oct 18, 2018

Added

  • Added parallelizable and randomExecutionOrdering attributes to XCScheme.TestableReference https://github.com/tuist/xcodeproj/pull/340 by @alvarhansen.

Fixed

  • Fixed possible generated UUID conflicts https://github.com/tuist/xcodeproj/pull/342 by @yonaskolb.
  • Fixed not working PBXFileElement.fullPath(sourceRoot:) method https://github.com/tuist/xcodeproj/pull/343 by @Vyeczorny.

6.2.0 - Oct 12, 2018

Added

  • Carthage and CocoaPods support https://github.com/tuist/xcodeproj/pull/339 by @pepibumur.

Changed

  • Improved writing performance https://github.com/tuist/xcodeproj/pull/336 https://github.com/tuist/xcodeproj/pull/337 https://github.com/tuist/xcodeproj/pull/338 by @yonaskolb.
  • Replaced Swift Package Manager dependency with PathKit https://github.com/tuist/xcodeproj/pull/334 by @yonaskolb.

6.1.0 - Oct 10, 2018

Added

  • Added ability to pass in a PBXObject into the PBXProject.targetAttributes dictionary, which will be encoded into its UUID. Can be used for TestTargetID https://github.com/tuist/xcodeproj/pull/333 by @yonaskolb.

Changed

  • Changed XCScheme.BuildableReference init to make blueprint a PBXObject and added a setBlueprint(:) function https://github.com/tuist/xcodeproj/pull/320 by @yonaskolb.
  • Bump AEXML version to 4.3.3 https://github.com/tuist/xcodeproj/pull/310 by @pepibumur.
  • Improves performance of object references https://github.com/tuist/xcodeproj/pull/332 by @yonaskolb.
  • Prefix reference with object type acronym. eg. PBXFileReference becomes FR_XXXXXXXXXXXXXXXXX https://github.com/tuist/xcodeproj/pull/332 by @yonaskolb.
  • Add TEMP prefix to temporary unfixed reference values https://github.com/tuist/xcodeproj/pull/332 by @yonaskolb.

Fixed

  • Fixed written order of scheme attributes in Swift 4.2 https://github.com/tuist/xcodeproj/pull/325 and https://github.com/tuist/xcodeproj/pull/331 by @yonaskolb and @drekka