/xcodeproj

Swift library for parsing Xcode projects

Primary LanguageSwiftMIT LicenseMIT

Swift Package Manager Twitter: @pepibumur License

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

Motivation 💅

Being able to write command line scripts in Swift to update your Xcode projects configuration. Here you have some examples:

  • Add new Build phases.
  • Update the project Build Settings.
  • Create new Schemes.

Contribute 👨‍👩‍👧

  1. Git clone the repository git@github.com:carambalabs/xcodeproj.git.
  2. Open xcodeproj.xcodeproj

Setup 🦋

Using Swift Package Manager

Add the dependency in your Package.swift file:

let package = Package(
    name: "myproject",
    dependencies: [
        .Package(url: "https://github.com/carambalabs/xcodeproj.git", majorVersion: 0, minor: 0)
    ]
)

Using Marathon

Edit your Marathonfile and specify the dependency in there:

https://github.com/carambalabs/xcodeproj.git

How to 🐒

Read

You can read the Xcode project files as shown in the examples below:

// Read a project
let project = try! XcodeProj(path: "myproject.xcodeproj")
let pbxproj = project.pbxproj
let buildFiles = pbxproj.objects.buildFiles
let buildConfigurations = pbxproj.objects.buildConfigurations

// Read a workspace
let workspace = try! XCWorkspace(path: "myworkspace.workspace")
let projects = workspace.data.references.map { $0.project }

// Read a config file
let xcconfig = try! XCConfig(path: "MyConfig.xcconfig")
let buildDir = xcconfig.buildSettings("CONFIGURATION_BUILD_DIR")

Write

All models above are also writable. After modifying them you can write them back to disk:

pbxproj.write(override: true)
xcconfig.write(override: true)

Documentation 📄

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

References 📚

About

This project is funded and maintained by Caramba. We 💛 open source software!

Check out our other open source projects, read our blog or say 👋 on twitter @carambalabs.

Contribute

Contributions are welcome 🤘 We encourage developers like you to help us improve the projects we've shared with the community. Please see the Contributing Guide and the Code of Conduct.

License

MIT License

Copyright (c) 2017 Caramba

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.