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.


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

Carthage

Only macOS

# Cartfile
github "tuist/xcodeproj" ~> 7.1.0

CocoaPods

pod 'xcodeproj', '~> 7.1.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.1.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)

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!

Github

link
Stars: 1033
Help us keep the lights on

Dependencies

Releases

7.1.0 - Sep 27, 2019

Added

  • Add onlyGenerateCoverageForSpecifiedTargets parameter to TestAction https://github.com/tuist/XcodeProj/pull/473 by @kateinoigakukun
  • Added support for PBXTargetDependency.product https://github.com/tuist/XcodeProj/pull/481 by @yonaskolb
  • Xcode 11 support

7.0.1 - Sep 12, 2019

Changed

  • Update BuildSettingProvider to return LD_RUNPATH_SEARCH_PATHS as Array https://github.com/tuist/xcodeproj/pull/463 by @marciniwanicki
  • Update Project.swift to make it compatible with tuist 0.17.0 https://github.com/tuist/xcodeproj/pull/469 by @marciniwanicki

Added

  • Adding support for adding local Swift packages https://github.com/tuist/XcodeProj/pull/468 by @fortmarek
  • Adding additional lastKnownFileTypes https://github.com/tuist/xcodeproj/pull/458 by @kwridan
  • Adding possibility to create variant group for referencing localized resources https://github.com/tuist/xcodeproj/pull/462 by @timbaev

Fixed

  • Duplication of packages https://github.com/tuist/XcodeProj/pull/470 by @fortmarek

7.0.0 - Jun 25, 2019

Changed

  • Breaking Change the UUID generation logic to generate ids with a length of 24 https://github.com/tuist/xcodeproj/pull/432 by @pepibumur.
  • Breaking Renamed module from xcodeproj to XcodeProj https://github.com/tuist/xcodeproj/pull/398 by @pepibumur.
  • Add override flag to PBXGroup.addFile(at:,sourceTree:,sourceRoot:) https://github.com/tuist/xcodeproj/pull/410 by @mrylmz
  • Rename some internal variables to have a more representative name https://github.com/tuist/xcodeproj/pull/415 by @pepibumur.

Added

  • Breaking Add SWIFT_COMPILATION_MODE and CODE_SIGN_IDENTITY build settings, remove DEBUG flag for Release https://github.com/tuist/xcodeproj/pull/417 @dangthaison91
  • Breaking Added throwing an error in case group path can't be resolved by @damirdavletov
  • Breaking Added remote project support to PBXContainerItemProxy by @damirdavletov
  • Breaking Add support for RemoteRunnable https://github.com/tuist/xcodeproj/pull/400 by @pepibumur.
  • Breaking Swift 5 support https://github.com/tuist/xcodeproj/pull/397 by @pepibumur.
  • Added com.apple.product-type.application.watchapp2-container to PBXProductType. https://github.com/tuist/xcodeproj/pull/441 by @leogdion.
  • Add BatchUpdater to quickly add files to the group https://github.com/tuist/xcodeproj/pull/388 by @CognitiveDisson.
  • WorkspaceSettings.autoCreateSchemes attribute https://github.com/tuist/xcodeproj/pull/399 by @pepibumur
  • Additional Swift 5 fixes: https://github.com/tuist/xcodeproj/pull/402 by @samisuteria
  • Make build phase name public by @llinardos.
  • Can access embed frameworks build phase for a target by @llinardos.
  • Added com.apple.product-type.framework.static to PBXProductType. https://github.com/tuist/xcodeproj/pull/347 by @ileitch.
  • Can add a not existing file to a group https://github.com/tuist/xcodeproj/pull/418 by @llinardos.
  • Support for Swift PM Packages https://github.com/tuist/xcodeproj/pull/439 https://github.com/tuist/xcodeproj/pull/444 by @pepibumur @yonaskolb.
  • LaunchAction.customLaunchCommand attribute https://github.com/tuist/xcodeproj/pull/451 by @pepibumur.
  • XCBuildConfiguration.append method https://github.com/tuist/xcodeproj/pull/450 by @pepibumur.

Fixed

  • Carthage integration https://github.com/tuist/xcodeproj/pull/416 by @pepibumur.
  • Relative path is wrong when referencing file outside of project folder https://github.com/tuist/xcodeproj/issues/423 by @damirdavletov
  • [crash] Fatal error: Duplicate values for key https://github.com/tuist/xcodeproj/issues/426 by @toshi0383
  • Change PBXContainerItemProxy.remoteGlobalID attribute to support object references https://github.com/tuist/xcodeproj/pull/445 by @yonaskolb
  • Dead lock in the PBXObjects.delete method https://github.com/tuist/xcodeproj/pull/449 by @pepibumur

Removed

  • OSLogs https://github.com/tuist/xcodeproj/pull/453 by @pepibumur.

6.7.0 - Mar 31, 2019

Changed

  • Breaking Make PBXBuildPhase.files optional to match Xcode's behavior https://github.com/tuist/xcodeproj/pull/391 by @pepibumur.

Added

  • Add location variable to XCWorkspaceDataElement https://github.com/tuist/xcodeproj/pull/387 by @pepibumur.

6.6.0 - Mar 1, 2019

Fixed

  • Fix adding files to PBXBuildPhase https://github.com/tuist/xcodeproj/pull/380 @danilsmakotin.
  • Improve project encoding performance https://github.com/tuist/xcodeproj/pull/371 by @CognitiveDisson.
  • Project decoding performance issue https://github.com/tuist/xcodeproj/pull/365 by @CognitiveDisson.
  • Fix PBXTarget extension methods https://github.com/tuist/xcodeproj/pull/367 by @danilsmakotin.

Added

  • Added GPUFrameCaptureMode and GPUValidationMode options to LaunchAction https://github.com/tuist/xcodeproj/pull/368 by @schiewe.
  • Add Swiftformat https://github.com/tuist/xcodeproj/pull/375 by @pepibumur.

Changed

  • Breaking Rename GPUFrameCaptureMode cases to start with a lowercase letter https://github.com/tuist/xcodeproj/pull/375 by @pepibumur.
  • Fix linting issues https://github.com/tuist/xcodeproj/pull/375 by @pepibumur.