Giter Site home page Giter Site logo

mod-pbxproj's Introduction

This module can read, modify, and write a .pbxproj file from an Xcode 4 project. The file is usually called project.pbxproj and can be found inside the .xcodeproj bundle.

Basic Usage:

from mod_pbxproj import XcodeProject
project = XcodeProject.Load('/path/to/.pbxproj')

You now have a project object that has a bunch of methods for manipulating it. By default files added to the project are also added to the appropriate build phase, as long as the file's type can be determined.

This will add a file in the root of a project. NOTE: everything goes better if you supply absolute paths.

project.add_file('/path/to/file.name')

This will return a group object that you can add files/folders under

new_group = project.get_or_create_group('new group')

This will add other.file to the project as a child of 'new group'

project.add_file('/path/to/other.file', parent=new_group)

If you want to add a framework or library that is found in the SDK, supply a relative path and set the tree argument to 'SDKROOT'

project.add_file('System/Libray/UIKit.framework', tree='SDKROOT')
project.add_file('usr/lib/libz.dylib', tree='SDKROOT')

This will recursively create groups and add the directory's contents to the project. You can optionally turn off the recursion.

project.add_folder('/path/to/folder')

You can supply an array of regular expressions for files you want to skip. This won't add any pdfs or mdown files found as it recurses.

project.add_folder('/path/to/folder', excludes=["^.*\.mdown$", "^.*\.pdf$"])

If a modification you are trying to apply have already been applied to the project then it will be skipped. This means that before saving the project you should check the modified flag to make sure changes have occured.

if project.modified:
    project.project_name = 'ProjectX' # sets the project name used in the save file comments, "Project" by default.
    project.backup()
    project.save() # will save by default using the new xcode 3.2 format
    project.save(old_format=True) # will force to save the project in plist XML format (NOT RECOMMENDED)

The backup method saves a copy of the project file in its current state on disk. This can be very useful if a modification leaves the project file unreadable.

p.s. NO WARRANTIES

mod-pbxproj's People

Contributors

aparajita avatar chren avatar jensayton avatar kronenthaler avatar nabeshin avatar sptramer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.