diff --git a/CHANGELOG.md b/CHANGELOG.md index 6befc29ae3..b7459d2c01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ END_UNRELEASED_TEMPLATE ### New * Added `--@rules_xcodeproj//xcodeproj:separate_index_build_output_base` flag to configure the generator to use a separate output base for index builds: [#3243](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3243) +* Add support for viewing and edit xcmappingmodel files: [#3242](https://github.com/MobileNativeFoundation/rules_xcodeproj/pull/3242) ### Adjusted diff --git a/tools/generators/files_and_groups/src/ElementCreator/CreateGroupChild.swift b/tools/generators/files_and_groups/src/ElementCreator/CreateGroupChild.swift index df4fd0eff3..60e444e413 100644 --- a/tools/generators/files_and_groups/src/ElementCreator/CreateGroupChild.swift +++ b/tools/generators/files_and_groups/src/ElementCreator/CreateGroupChild.swift @@ -105,6 +105,19 @@ extension ElementCreator.CreateGroupChild { ) ) + case "xcmappingmodel": + return .elementAndChildren( + createFile( + name: name, + bazelPath: BazelPath( + parent: parentBazelPath, + path: name + ), + bazelPathType: parentBazelPathType, + transitiveBazelPaths: [] + ) + ) + default: return .elementAndChildren( createGroup( diff --git a/tools/generators/files_and_groups/test/ElementCreator/CreateFileElementTests.swift b/tools/generators/files_and_groups/test/ElementCreator/CreateFileElementTests.swift index 2e6f44fb8f..b60979d2a8 100644 --- a/tools/generators/files_and_groups/test/ElementCreator/CreateFileElementTests.swift +++ b/tools/generators/files_and_groups/test/ElementCreator/CreateFileElementTests.swift @@ -497,4 +497,37 @@ final class CreateFileElementTests: XCTestCase { ) XCTAssertEqual(result.resolvedRepository, stubbedResolvedRepository) } + + func test_element_content_explicitFileType_xcmappingmodel() { + // Arrange + + let name = "Mapping.xcmappingmodel" + let ext = "xcmappingmodel" + let bazelPath = BazelPath("a/bazel/path/Mapping.xcmappingmodel") + let createAttributes = ElementCreator.CreateAttributes.stub( + elementAttributes: ElementAttributes( + sourceTree: .group, name: nil, path: "a_path" + ), + resolvedRepository: nil + ) + + let expectedContent = #""" +{isa = PBXFileReference; explicitFileType = wrapper.xcmappingmodel; path = a_path; sourceTree = ""; } +"""# + + // Act + + let result = ElementCreator.CreateFileElement.defaultCallable( + name: name, + ext: ext, + bazelPath: bazelPath, + bazelPathType: .workspace, + createAttributes: createAttributes, + createIdentifier: ElementCreator.Stubs.createIdentifier + ) + + // Assert + + XCTAssertEqual(result.element.object.content, expectedContent) + } }