From f4a295c26bd8de61b86a8ae4aead70c06b878977 Mon Sep 17 00:00:00 2001 From: Erisu Date: Thu, 29 Oct 2026 14:00:25 +0900 Subject: [PATCH] feat: support objcpp source files ('mm' extensions) - Updated mappings 'FILETYPE_BY_EXTENSION', 'GROUP_BY_FILETYPE', and 'ENCODING_BY_FILETYPE' - Added new 'addSourceFile' test cases to confirm PBXFile data for objc, objcpp, and swift source files. --- lib/pbxFile.js | 3 +++ test/addSourceFile.js | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/lib/pbxFile.js b/lib/pbxFile.js index 59dcef9..2ed90be 100644 --- a/lib/pbxFile.js +++ b/lib/pbxFile.js @@ -34,6 +34,7 @@ const FILETYPE_BY_EXTENSION = { framework: 'wrapper.framework', h: 'sourcecode.c.h', m: 'sourcecode.c.objc', + mm: 'sourcecode.cpp.objcpp', markdown: 'text', mdimporter: 'wrapper.cfbundle', octest: 'wrapper.cfbundle', @@ -58,6 +59,7 @@ const GROUP_BY_FILETYPE = { 'embedded.framework': 'Embed Frameworks', 'sourcecode.c.h': 'Resources', 'sourcecode.c.objc': 'Sources', + 'sourcecode.cpp.objcpp': 'Sources', 'sourcecode.swift': 'Sources' }; const PATH_BY_FILETYPE = { @@ -73,6 +75,7 @@ const SOURCETREE_BY_FILETYPE = { const ENCODING_BY_FILETYPE = { 'sourcecode.c.h': 4, 'sourcecode.c.objc': 4, + 'sourcecode.cpp.objcpp': 4, 'sourcecode.swift': 4, text: 4, 'text.plist.xml': 4, diff --git a/test/addSourceFile.js b/test/addSourceFile.js index 409bad0..053fae7 100644 --- a/test/addSourceFile.js +++ b/test/addSourceFile.js @@ -162,4 +162,31 @@ describe('addSourceFile', () => { assert.strictEqual(plugins.children.length, 1); assert.strictEqual(sources.files.length, 3); }); + + it('should add objc source files and return pbxFile', () => { + const newFile = proj.addSourceFile('file.m'); + assert.strictEqual(newFile.constructor, PBXFile); + assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.c.objc'); + assert.strictEqual(newFile.group, 'Sources'); + assert.strictEqual(newFile.defaultEncoding, 4); + assert.strictEqual(newFile.fileEncoding, 4); + }); + + it('should add objc++ source files and return pbxFile', () => { + const newFile = proj.addSourceFile('file.mm'); + assert.strictEqual(newFile.constructor, PBXFile); + assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.cpp.objcpp'); + assert.strictEqual(newFile.group, 'Sources'); + assert.strictEqual(newFile.defaultEncoding, 4); + assert.strictEqual(newFile.fileEncoding, 4); + }); + + it('should add swift source files and return pbxFile', () => { + const newFile = proj.addSourceFile('file.swift'); + assert.strictEqual(newFile.constructor, PBXFile); + assert.strictEqual(newFile.lastKnownFileType, 'sourcecode.swift'); + assert.strictEqual(newFile.group, 'Sources'); + assert.strictEqual(newFile.defaultEncoding, 4); + assert.strictEqual(newFile.fileEncoding, 4); + }); });