From 2f502e5b06f8063a57a0b314d481c9063f613a18 Mon Sep 17 00:00:00 2001 From: Ignacio Calderon Date: Wed, 10 Apr 2024 10:09:08 +0200 Subject: [PATCH] feat: add support for XCLocalSwiftPackageReference (#346) Co-authored-by: Michal Szelag --- .../pbxsections/XCLocalSwiftPackageReference.py | 14 ++++++++++++++ pbxproj/pbxsections/__init__.py | 1 + .../TestXCLocalSwiftPackageReference.py | 8 ++++++++ 3 files changed, 23 insertions(+) create mode 100644 pbxproj/pbxsections/XCLocalSwiftPackageReference.py create mode 100644 tests/pbxsections/TestXCLocalSwiftPackageReference.py diff --git a/pbxproj/pbxsections/XCLocalSwiftPackageReference.py b/pbxproj/pbxsections/XCLocalSwiftPackageReference.py new file mode 100644 index 0000000..d7cb8b6 --- /dev/null +++ b/pbxproj/pbxsections/XCLocalSwiftPackageReference.py @@ -0,0 +1,14 @@ +from pbxproj import PBXGenericObject + + +class XCLocalSwiftPackageReference(PBXGenericObject): + @classmethod + def create(cls, relative_path): + return cls().parse({ + '_id': cls._generate_id(), + 'isa': cls.__name__, + 'relativePath': relative_path + }) + + def _get_comment(self): + return f'XCLocalSwiftPackageReference "{self.relativePath}"' diff --git a/pbxproj/pbxsections/__init__.py b/pbxproj/pbxsections/__init__.py index 7139ba9..ac16691 100644 --- a/pbxproj/pbxsections/__init__.py +++ b/pbxproj/pbxsections/__init__.py @@ -18,3 +18,4 @@ from pbxproj.pbxsections.PBXGroup import * from pbxproj.pbxsections.XCSwiftPackageProductDependency import * from pbxproj.pbxsections.XCRemoteSwiftPackageReference import * +from pbxproj.pbxsections.XCLocalSwiftPackageReference import * diff --git a/tests/pbxsections/TestXCLocalSwiftPackageReference.py b/tests/pbxsections/TestXCLocalSwiftPackageReference.py new file mode 100644 index 0000000..c9eeb8c --- /dev/null +++ b/tests/pbxsections/TestXCLocalSwiftPackageReference.py @@ -0,0 +1,8 @@ +import unittest +from pbxproj.pbxsections.XCLocalSwiftPackageReference import * + + +class TestXCLocalSwiftPackageReference(unittest.TestCase): + def testGetComment(self): + obj = XCLocalSwiftPackageReference.create('MyPackage') + assert obj._get_comment() == 'XCLocalSwiftPackageReference "MyPackage"'