Giter Site home page Giter Site logo

yulingtianxia / pbxprojhelper Goto Github PK

View Code? Open in Web Editor NEW
484.0 18.0 56.0 1.87 MB

A macOS tool help you handling project.pbxproj files. Written in Swift 5!

License: GNU General Public License v3.0

Swift 100.00%
pbxproj json-configuration xcode macos tools swift

pbxprojhelper's Introduction

Language Build Status GitHub release Twitter Follow

pbxprojHelper

pbxprojHelper is a GUI tool developed with Cocoa and Swift 5 for parsing and changing Xcode projects configuration. You can also use pbxproj as a command line tool in terminal.

Main Window

Languages

中文

Articles

pbxprojHelper--Xcode工程文件助手

Let's Talk About project.pbxproj

Installing pbxprojHelper

GitHub

You can clone the source code of pbxprojHelper, then compile and run it by Xcode.

You can also download pbxprojHelper.app and pbxproj tool with its latest Releases on GitHub.

App Store

Mac App Store link: (Only pbxprojHelper.app)

https://itunes.apple.com/cn/app/pbxprojhelper/id1160801848

Add .Package(url: "https://github.com/yulingtianxia/pbxprojHelper.git", majorVersion: 1) to dependencies in your Package.swift.

Quickstart

Use pbxprojHelper (Native Cocoa UI App)

  1. Choose your project file by clicking "Select" button. Both .xcodeproj and .pbxproj file extensions are supported. The path of project file you selected will be displayed on the text field. The outline view shows data of project file.
  2. Choose configuration file by clicking "Choose JSON File". Configuration file contains changes you want to make to your project. You can create a configuration file with json format, or generate it using "JSON Configuration Generator" tool provided by pbxprojHelper. The outline view will refresh data after you choose a json file.
  3. Clicking "Apply" button will write changes made by json configuration to project file you selected.
  4. "Revert" button does a reverse operation of "Apply" button.

Use pbxproj (Command Line Tool)

You should move pbxproj to /usr/local/bin/, so you can execute pbxproj command conveniently in terminal.

Here is the Usage:

Usage: pbxproj [command_option] file
Command options are (-convert is the default):
-compare modified_file -o path          compare modified property list file with property list file and generate a json result at the given path
-apply json_file                        apply a json file on property list file
-revert                                 a json file on property list file
-recover                                recover a property list file from latest change
-convert                                rewrite a property list file in xml format

Outline View

The outline view shows entire data of project.pbxproj file. You can expand an item if it's type is collection(dictionary or array). For example, the value for key objects is an dictionary which contains 34 key-value pairs. You can expand objects to view its content. For key-value pairs of dictionary, the 1st/2nd column means "Key"/"Value". If the value is a collection(not String or Number.ect), the 2nd column shows a description of the collection; For elements of array, the 1st column means "Element", but the 2nd column contains nothing.

You can copy the text in outline view by just a click on the text. If you want to copy the whole keypath from root node, double click it.

Filter

You can filt the content of outline view by typing a string in the "Filter" Text Field. It's not case sensitive.

Project File Path

There is a pull-down menu which shows five latest used file paths when you click the path of your project file. So you can choose your project files in common use quickly.

JSON Configuration File

Configuration Rules

The configuration file contains a list of rules. Here is an example of configuration:

{
  "insert" : {
    "objects.A45A665D1D98286400DBED04.children" : [
      "a",
      "b",
      "c"
    ],
    "classes" : {
      "xixihaha": 5,
      "aaaaa" : "养小鱼"
    }
  },
  "remove" : {
    "objects.A45A666D1D98286400DBED04.buildSettings" : [
      "ALWAYS_SEARCH_USER_PATHS"
    ]
  },
  "modify" : {
    "archiveVersion" : "2"
  }
}

The root object must be a dictionary with 3 key-value pairs. You can "insert", "remove" and "modify" values through their key paths in project.pbxproj file.

There are two series of configuration rules in the newest configuration file: "forward" and "backward". They respectively corresponded to "Apply" and "Revert" Functions.

Insert

The example above inserts 3 elements("a","b","c") into the children array. Note that the keypath "objects.A45A665D1D98286400DBED04.children" must be valid. The value of "children" should be an array and the value of "classes" should be a dictionary. In a word, the type of incremental data should be same with original data in project.pbxproj file.

Remove

The example above removes a key-value pair whose key equals "ALWAYS_SEARCH_USER_PATHS" from a dictionary named buildSettings. The value of keypath should always be an array. This array contains keys/elements you want to removed from dictionary/array.

Modify

Modify the value of keypath, so easy.

Configuration Generator

Programmer is lazy. I can't stand wasting my time on writing json files, so I create the powerful tool called "JSON Configuration Generator":

JSON Configuration Generator Window

There are two ways to open the "Generator" window:

  1. Menu -> Window -> JSON Configuration Generator
  2. Key Equivament: ⇧⌘0

You can use it in an oversimplified and crude way. Just select two project files and json save path, then click the "Generate" button, and you will get a json file containing changes between modified and original project file.

Conversely, you can use this json file when you want to apply these changes to certain project file again. Please take care of this json file.

Backups

Each time you click "Apply" button on main window, pbxprojHelper will use original or last modified project file to create backup file with "backup" extension in "Documents" folder of sandbox first, and then apply changes on project file.

"Revert" button uses these backups to revert project file to the latest version.

Encoding

When generating project.pbxproj file with xml format, chinese characters will be translated to Unicode mathematical symbols. For example, "杨萧玉" in OpenStep style file will be converted to <string>&#26472;&#33831;&#29577;</string> in XML style. This is because Xcode will encode XML content(regarded as ASCII encoding) into Unicode again when convert XML project file to OpenStep project file.

LICENSE

These works are available under the GNU General Public License. See the LICENSE file for more info.

pbxprojhelper's People

Contributors

marcsteven avatar valeriyvan avatar yulingtianxia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pbxprojhelper's Issues

Compatibility issue for macOS 10.11

Could you please update the project deployment target as 10.11 as minimal version if possible? Some cocoa developers are still there, Thanks!

能批量添加文件到工程中不

这几天也在研究这个文件,有个需求,需要将1w个代码拖到工程中,如果传统的直接拖到xcode,直接崩溃了,所以用了楼主的这个app,似乎没找到有相关添加文件的功能

请问命令行是怎么用的呢?

我是把pbxproj文件夹拷到了usr/bin/目录下 并且修改了权限
然后运行/usr/local/bin/pbxproj/main.swift caocaoSwift.xcodeproj/project.pbxproj -apply /Users/heew/Desktop/xprojhelp/JsonConfiguration.json
报错如下
/usr/local/bin/pbxproj/main.swift:38:13: error: cannot find 'PropertyListHandler' in scope
PropertyListHandler.generateJSON(filePath: output, withModifiedProject: URL(fileURLWithPath: modifiedFile), originalProject: URL(fileURLWithPath: originalFile))
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:47:33: error: cannot find 'PropertyListHandler' in scope
if let jsonObject = PropertyListHandler.parseJSON(fileURL: URL(fileURLWithPath: jsonFile)) as? [String: Any],
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:48:37: error: cannot find 'PropertyListHandler' in scope
let projectObject = PropertyListHandler.parseProject(fileURL: URL(fileURLWithPath: projectFile)) {
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:49:44: error: cannot find 'PropertyListHandler' in scope
let appliedProjectObject = PropertyListHandler.apply(json: jsonObject, onProjectData: projectObject)
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:50:17: error: cannot find 'PropertyListHandler' in scope
PropertyListHandler.generateProject(fileURL: URL(fileURLWithPath: projectFile), withPropertyList: appliedProjectObject)
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:60:33: error: cannot find 'PropertyListHandler' in scope
if let jsonObject = PropertyListHandler.parseJSON(fileURL: URL(fileURLWithPath: jsonFile)) as? [String: Any],
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:61:37: error: cannot find 'PropertyListHandler' in scope
let projectObject = PropertyListHandler.parseProject(fileURL: URL(fileURLWithPath: projectFile)) {
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:62:44: error: cannot find 'PropertyListHandler' in scope
let appliedProjectObject = PropertyListHandler.apply(json: jsonObject, onProjectData: projectObject, forward: false)
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:63:17: error: cannot find 'PropertyListHandler' in scope
PropertyListHandler.generateProject(fileURL: URL(fileURLWithPath: projectFile), withPropertyList: appliedProjectObject)
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:72:16: error: cannot find 'PropertyListHandler' in scope
if PropertyListHandler.recoverProject(fileURL: URL(fileURLWithPath: projectFile)) {
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:82:36: error: cannot find 'PropertyListHandler' in scope
if let projectObject = PropertyListHandler.parseProject(fileURL: URL(fileURLWithPath: projectFile)) {
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:83:17: error: cannot find 'PropertyListHandler' in scope
PropertyListHandler.generateProject(fileURL: URL(fileURLWithPath: projectFile), withPropertyList: projectObject)
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:89:36: error: cannot find 'PropertyListHandler' in scope
if let projectObject = PropertyListHandler.parseProject(fileURL: URL(fileURLWithPath: projectFile)) {
^~~~~~~~~~~~~~~~~~~
/usr/local/bin/pbxproj/main.swift:90:17: error: cannot find 'PropertyListHandler' in scope
PropertyListHandler.generateProject(fileURL: URL(fileURLWithPath: projectFile), withPropertyList: projectObject)
^~~~~~~~~~~~~~~~~~~

修改后,打不开工程文件了

修改后打不开工程了,修改后文件格式变成了XML的,不是OpenStep古老的格式,是不是高版本Xcode不支持XML的. pbxproj文件了。当前Xcode版本为:Version 13.4.1 (13F100)

报错提示The project at 'DemoTest/DemoTest.xcodeproj' cannot be opened because it is in a future Xcode project file format. Adjust the project format using a compatible version of Xcode to allow it to be opened by this version of Xcode.

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.