Giter VIP home page Giter VIP logo

xcodeproj's Introduction

xcodeproj

xcodeproj is a utility for interacting with Xcode's xcodeproj bundle format.

It expects some level of understanding of the internals of the pbxproj format and schemes. Note that this tool only reads projects. It does not write out any changes. If you are looking for more advanced functionality like this, I recommend looking at the Ruby gem of the same name (which is unaffiliated in anyway).

To learn more about the format, you can look at any of these locations:

Getting Started

Loading a project is very simple:

project = xcodeproj.XcodeProject("/path/to/project.xcodeproj")

From here you can explore the project in different ways:

# Get all targets
for target in project.targets:
    print(target.name)

# Print from the root level, 2 levels deep (.project is a property on the root 
# project as other properties such as .schemes are also available)
for item1 in project.project.main_group.children:
    print(item1)
    if not isinstance(item1, xcodeproj.PBXGroup):
        continue

    for item2 in item1.children:
        print("\t", item2)

# Check that all files referenced in the project exist on disk
for item in project.fetch_type(xcodeproj.PBXFileReference).values():
    assert os.path.exists(item.absolute_path())

# You can access the raw objects map directly:
obj = project.objects["key here"]

# For any object you have, you can access its key/identifier via the 
# `.object_key` property
key = obj.object_key

Note: This library is "lazy". Many things aren't calculated until they are used. This time will be inconsequential on smaller projects, but on larger ones, it can save quite a bit of time due to not parsing the entire project on load. These properties are usually stored though so that subsequent accesses are instant.

Note on Scheme Support

There's no DTD for xcscheme files, so the implementation has been guessed. There will definitely be holes that still need to be patched in it though. Please open an issue if you find any, along with a sample xcscheme file.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.

xcodeproj's People

Contributors

aaroncrespo avatar afrazcodes avatar dalemyers avatar dependabot[bot] avatar guojiubo avatar jingshizheng avatar luras-oil avatar microsoftopensource avatar nickromano avatar

Stargazers

 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

xcodeproj's Issues

Not properly deserializing SPM driven frameworks.

Version 0.10.0
Xcode 12.3

When parsing a xcode project that has a SPM driven dependency in it, the deserialization seems to choke when attempt to process a key that doesn't appear in the project file.

/* Begin PBXBuildFile section */
                3A299BE92490325100D0C6DC /* Apollo in Frameworks */ = {isa = PBXBuildFile; productRef = 3A299BE82490325100D0C6DC /* Apollo */; };
/* End PBXFileReference section */
...
/* Begin PBXFrameworksBuildPhase section */
                535F64F8719D1B74E1B03FFA /* Frameworks */ = {
                        isa = PBXFrameworksBuildPhase;
                        buildActionMask = 2147483647;
                        files = (
                                3A299BE92490325100D0C6DC /* Apollo in Frameworks */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
/* End PBXFrameworksBuildPhase section */
...
/* Begin PBXNativeTarget section */
                E71219D5524EC51B7CC4EF58 /* ExternalDependencies */ = {
                        isa = PBXNativeTarget;
                        buildConfigurationList = 35BA45D7C1EE5F4923383BE5 /* Build configuration list for PBXNativeTarget "ExternalDependencies" */;
                        buildPhases = (
                                1FBD9495F511CE13568F49D5 /* Headers */,
                                C324682C94CD3E4AF7606380 /* Sources */,
                                535F64F8719D1B74E1B03FFA /* Frameworks */,
                        );
                        buildRules = (
                        );
                        dependencies = (
                        );
                        name = ExternalDependencies;
                        packageProductDependencies = (
                                3A299BE82490325100D0C6DC /* Apollo */,
                        );
                        productName = ExternalDependencies;
                        productReference = 22E34CDF41A592529EDBB3F6 /* ExternalDependencies.framework */;
                        productType = "com.apple.product-type.framework";
                };
/* End PBXNativeTarget section */
...
/* Begin XCSwiftPackageProductDependency section */
                3A299BE82490325100D0C6DC /* Apollo */ = {
                        isa = XCSwiftPackageProductDependency;
                        package = 3A299BE72490325100D0C6DC /* XCRemoteSwiftPackageReference "glass-apollo" */;
                        productName = Apollo;
                };
/* End XCSwiftPackageProductDependency section */
...
/* Begin XCSwiftPackageProductDependency section */
                3A299BE82490325100D0C6DC /* Apollo */ = {
                        isa = XCSwiftPackageProductDependency;
                        package = 3A299BE72490325100D0C6DC /* XCRemoteSwiftPackageReference "glass-apollo" */;
                        productName = Apollo;
                };
/* End XCSwiftPackageProductDependency section */

The key in error here is "file_ref_id". The processing properly parses the "object_key" prior to this.

deserialize.exceptions.DeserializeException: Unexpected missing value for: typing.Dict[str, xcodeproj.pbxobject.PBXObject].3A299BE92490325100D0C6DC.file_ref_id

error

when i use : xcodeproj.XcodeProject("/Users/xxx/Desktop/Iphone/xxx.xcodeproj")

it prints:

raise DeserializeException(
deserialize.exceptions.DeserializeException: Cannot deserialize '<class 'str'>' to '<enum 'PBXProductType'>' for 'typing.Dict[str, xcodeproj.pbxobject.PBXObject].09E3D8931DD42DD600E1E053.product_type

how to solve it ,thanks!

Custom Build Rules cause crash

When I use xcodeproj.XcodeProject(xcodeproj_path, ignore_deserialization_errors=True)

it prints:

raise DeserializeException(
deserialize.exceptions.DeserializeException: Unexpected missing value for: Dict.46EB2E000A1620.input_files

raise DeserializeException(
deserialize.exceptions.DeserializeException: Cannot deserialize '<class 'str'>' to '<class 'bool'>' for 'Dict.46EB2E000A1620.is_editable'

46EB2E000A1620 is a Custom Build Rules, like this:

image
image

how to solve it ,thanks!

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.