Created
October 22, 2012 03:16
-
-
Save brunogama/3929457 to your computer and use it in GitHub Desktop.
little script to add stuff into the project.pbxproj (A file inside all *.xcodeproj package files)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python -tt | |
# -*- encoding: utf-8 -*- | |
# Xcode.py | |
# @author: Bruno Gama | |
# @email: bgamap at gmail.com | |
# @license: ICS | |
import subprocess | |
import shlex | |
import plistlib | |
import tempfile | |
import os | |
import sys | |
def get_keys(d, search=None, ret=[]): | |
for k, v in sorted(d.items(), key=lambda x: x[0]): | |
if isinstance(v, dict): | |
get_keys(v, search=search, ret=ret) | |
else: | |
if k == search: | |
ret.append(v) | |
return ret | |
def binary_plist_to_xml(pbxproj): | |
raw_plutil = "plutil -convert xml1 -o - \"%s\"" % (pbxproj) | |
p = subprocess.Popen(shlex.split(raw_plutil), stdout=subprocess.PIPE) | |
return p.stdout.read() | |
def write_pbxproj(root_plist, pbxproj): | |
tmp_file = tempfile.NamedTemporaryFile(mode='w+t', delete=False) | |
plistlib.writePlist(root_plist, tmp_file) | |
tmp_file_name = tmp_file.name | |
tmp_file.close() | |
pl_cmd = 'pl -input %s -output %s' % (tmp_file_name, pbxproj) | |
subprocess.call(shlex.split(pl_cmd)) | |
if os.path.exists(tmp_file_name): | |
os.remove(tmp_file_name) | |
def main(): | |
return 0 | |
if __name__ == '__main__': | |
sys.exit(main()) |
sorry for the typos/misspelling
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
usage exemple