From 29af27ddbe1526cf7af31a6f269bc1917038eb81 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Fri, 30 Oct 2026 21:24:35 +0100 Subject: [PATCH 1/9] fix: don't pass the CLI's own options to package managers ensureAllDependenciesAreInstalled passes path, frameworkPath, disableNpmInstall and ignoreScripts as install options, and getFlagsString turned them into flags. npm 12 fails on unknown flags, so ns commands that install with --path, like ns debug --path app --force, stopped with EUNKNOWNCONFIG. --- lib/base-package-manager.ts | 12 ++++++++++++ test/base-package-manager.ts | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 test/base-package-manager.ts diff --git a/lib/base-package-manager.ts b/lib/base-package-manager.ts index 5ee9a96abd..daa7141578 100644 --- a/lib/base-package-manager.ts +++ b/lib/base-package-manager.ts @@ -13,6 +13,14 @@ import { IHostInfo, } from "./common/declarations"; +// Options for the CLI itself. npm 12 fails on flags it doesn't know. +const CLI_ONLY_OPTIONS = [ + "path", + "frameworkPath", + "disableNpmInstall", + "ignoreScripts", +]; + export abstract class BasePackageManager implements INodePackageManager { public abstract install( packageName: string, @@ -136,6 +144,10 @@ export abstract class BasePackageManager implements INodePackageManager { protected getFlagsString(config: any, asArray: boolean): any { const array: Array = []; for (const flag in config) { + if (CLI_ONLY_OPTIONS.includes(flag)) { + continue; + } + if ( flag === "global" && this.packageManager !== "yarn" && diff --git a/test/base-package-manager.ts b/test/base-package-manager.ts new file mode 100644 index 0000000000..d94cf1aced --- /dev/null +++ b/test/base-package-manager.ts @@ -0,0 +1,32 @@ +import { assert } from "chai"; +import { BasePackageManager } from "../lib/base-package-manager"; + +class TestPackageManager extends (BasePackageManager) { + constructor() { + super({}, {}, {}, {}, {}, "npm"); + } +} + +describe("BasePackageManager", () => { + const flags = (config: object): string[] => + (new TestPackageManager()).getFlagsString(config, true); + + it("doesn't pass the CLI's own options to the package manager", () => { + assert.deepEqual( + flags({ + path: "apps/app", + frameworkPath: "runtime.tgz", + disableNpmInstall: true, + ignoreScripts: true, + }), + [], + ); + }); + + it("passes the package manager's options on", () => { + assert.deepEqual(flags({ "ignore-scripts": true, "save-dev": true }), [ + "--ignore-scripts", + "--save-dev", + ]); + }); +}); From 64dc3d1b2e1ff3a4e3a5c78518ece3d3e54edae8 Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Fri, 30 Oct 2026 21:30:46 +0100 Subject: [PATCH 2/9] fix(ios): resolve NativeSource paths against the project They were resolved against the working directory, so running from outside the project with --path found no files and left the group empty, and the build failed on the missing types. --- lib/services/ios-project-service.ts | 27 ++++++++---- test/ios-project-service-native-source.ts | 50 +++++++++++++++++++++++ 2 files changed, 69 insertions(+), 8 deletions(-) create mode 100644 test/ios-project-service-native-source.ts diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 7ac6f30c0e..9e596e328f 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -1532,7 +1532,11 @@ export class IOSProjectService projectData: IProjectData, ): Promise { const project = this.createPbxProj(projectData); - const group = await this.getRootGroup(groupName, sourceFolderPath); + const group = await this.getRootGroup( + groupName, + sourceFolderPath, + projectData.projectDir, + ); // pin the sources to the main app target: without an explicit target the // underlying xcode lib picks whichever "Sources" build phase it finds // first, which can be an extension target (e.g. a widget) once one @@ -1597,7 +1601,11 @@ export class IOSProjectService } } - private async getRootGroup(name: string, rootPath: string) { + private async getRootGroup( + name: string, + rootPath: string, + projectRoot: string, + ) { const filePathsArr: string[] = []; const rootGroup: INativeSourceCodeGroup = { name: name, @@ -1606,17 +1614,19 @@ export class IOSProjectService }; if (fastGlob.isDynamicPattern(rootPath)) { - const projectRoot = this.$projectDataService.getProjectData().projectDir; - const filePaths = await fastGlob(rootPath); + // Relative to the project: --path can run the CLI from anywhere. + const filePaths = await fastGlob(rootPath, { cwd: projectRoot }); for (const filePath of filePaths) { const sourceFilePath = path.normalize(path.join(projectRoot, filePath)); filePathsArr.push(sourceFilePath); } } else { - if (this.$fs.exists(rootPath)) { - const stats = this.$fs.getFsStats(rootPath); - if (stats.isDirectory() && !this.$fs.isEmptyDir(rootPath)) { - this.$fs.readDirectory(rootPath).forEach((fileName) => { + const folderPath = path.resolve(projectRoot, rootPath); + rootGroup.path = folderPath; + if (this.$fs.exists(folderPath)) { + const stats = this.$fs.getFsStats(folderPath); + if (stats.isDirectory() && !this.$fs.isEmptyDir(folderPath)) { + this.$fs.readDirectory(folderPath).forEach((fileName) => { const filePath = path.join(rootGroup.path, fileName); filePathsArr.push(filePath); }); @@ -1684,6 +1694,7 @@ export class IOSProjectService const group = await this.getRootGroup( pluginData.name, pluginPlatformsFolderPath, + projectData.projectDir, ); project.removePbxGroup(group.name, group.path); project.removeFromHeaderSearchPaths(group.path); diff --git a/test/ios-project-service-native-source.ts b/test/ios-project-service-native-source.ts new file mode 100644 index 0000000000..fd8d55ee77 --- /dev/null +++ b/test/ios-project-service-native-source.ts @@ -0,0 +1,50 @@ +import { assert } from "chai"; +import * as fs from "fs"; +import * as os from "os"; +import * as path from "path"; +import { FileSystem } from "../lib/common/file-system"; +import { IOSProjectService } from "../lib/services/ios-project-service"; + +describe("iOSProjectService getRootGroup", () => { + let projectDir: string; + let sourcesDir: string; + let cwd: string; + + beforeEach(() => { + const root = fs.mkdtempSync(path.join(os.tmpdir(), "native-source-")); + projectDir = path.join(root, "apps", "app"); + sourcesDir = path.join(root, "libs", "native"); + fs.mkdirSync(projectDir, { recursive: true }); + fs.mkdirSync(sourcesDir, { recursive: true }); + fs.writeFileSync(path.join(sourcesDir, "Source.swift"), ""); + cwd = process.cwd(); + process.chdir(root); + }); + + afterEach(() => { + process.chdir(cwd); + }); + + const getFiles = async (rootPath: string): Promise => { + const { files } = await (IOSProjectService.prototype).getRootGroup.call( + { $fs: new FileSystem({}) }, + "Native", + rootPath, + projectDir, + ); + return files.map((file: string) => fs.realpathSync(file)); + }; + + const expectedSource = () => + fs.realpathSync(path.join(sourcesDir, "Source.swift")); + + it("resolves a glob against the project, not the working directory", async () => { + assert.deepEqual(await getFiles("../../libs/native/*.swift"), [ + expectedSource(), + ]); + }); + + it("resolves a folder against the project, not the working directory", async () => { + assert.deepEqual(await getFiles("../../libs/native"), [expectedSource()]); + }); +}); From 6e007296d9274979bc0b36b7e5ea79e76ba0a4cd Mon Sep 17 00:00:00 2001 From: Igor Randjelovic Date: Fri, 30 Oct 2026 22:03:41 +0100 Subject: [PATCH 3/9] fix(ios): use the folders of a NativeSource glob's headers as search paths The glob itself ended up in HEADER_SEARCH_PATHS, where it matches nothing, relative to the Xcode project rather than the app. Folder paths now use the path resolved against the project for the search path and for the module map check as well. --- lib/services/ios-project-service.ts | 18 +++++++-- test/ios-project-service-native-source.ts | 46 +++++++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 9e596e328f..c1b4b27db8 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -1547,16 +1547,26 @@ export class IOSProjectService filesRelativeToProject: true, target: project.getFirstTarget()?.uuid, }); - project.addToHeaderSearchPaths(group.path); - const headerFiles = this.$fs.exists(sourceFolderPath) + // A glob is no use as a search path, the folders of its headers are. + const headerSearchPaths = fastGlob.isDynamicPattern(sourceFolderPath) + ? _.uniq( + group.files + .filter((file) => path.extname(file) === ".h") + .map((file) => path.dirname(file)), + ) + : [group.path]; + headerSearchPaths.forEach((searchPath) => + project.addToHeaderSearchPaths(searchPath), + ); + const headerFiles = this.$fs.exists(group.path) ? this.$fs.enumerateFilesInDirectorySync( - sourceFolderPath, + group.path, (file, stat) => stat.isDirectory() || path.extname(file) === ".h", ) : []; if ( headerFiles.length > 0 && - !this.$fs.exists(path.join(sourceFolderPath, "module.modulemap")) + !this.$fs.exists(path.join(group.path, "module.modulemap")) ) { this.$logger.warn( `warning: Directory ${sourceFolderPath} with native iOS source code doesn't contain a modulemap file. Metadata for it will not be generated and it will not be accessible from JavaScript. To learn more see https://docs.nativescript.org/guides/ios-source-code`, diff --git a/test/ios-project-service-native-source.ts b/test/ios-project-service-native-source.ts index fd8d55ee77..dd8f692126 100644 --- a/test/ios-project-service-native-source.ts +++ b/test/ios-project-service-native-source.ts @@ -47,4 +47,50 @@ describe("iOSProjectService getRootGroup", () => { it("resolves a folder against the project, not the working directory", async () => { assert.deepEqual(await getFiles("../../libs/native"), [expectedSource()]); }); + + describe("header search paths", () => { + const prepare = async (rootPath: string): Promise => { + const searchPaths: string[] = []; + const proto = IOSProjectService.prototype; + await proto.prepareNativeSourceCode.call( + { + $fs: new FileSystem({}), + $logger: { warn: () => {} }, + getRootGroup: proto.getRootGroup, + savePbxProj: () => {}, + createPbxProj: () => ({ + addPbxGroup: () => {}, + getFirstTarget: () => ({ uuid: "target" }), + addToHeaderSearchPaths: (searchPath: string) => + searchPaths.push(searchPath), + }), + }, + "Native", + rootPath, + { projectDir }, + ); + return searchPaths.map((searchPath) => fs.realpathSync(searchPath)); + }; + + it("uses the folders of the headers a glob matches", async () => { + const nested = path.join(sourcesDir, "nested"); + fs.mkdirSync(nested); + fs.writeFileSync(path.join(nested, "One.h"), ""); + fs.writeFileSync(path.join(nested, "Two.h"), ""); + + assert.deepEqual(await prepare("../../libs/native/**/*.{h,swift}"), [ + fs.realpathSync(nested), + ]); + }); + + it("adds nothing for a glob without headers", async () => { + assert.deepEqual(await prepare("../../libs/native/*.swift"), []); + }); + + it("uses the folder itself, against the project", async () => { + assert.deepEqual(await prepare("../../libs/native"), [ + fs.realpathSync(sourcesDir), + ]); + }); + }); }); From 3d737b20f33e01519e9f1dc0543113259a095e87 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 27 Nov 2026 18:24:09 -0800 Subject: [PATCH 4/9] test: remove the NativeSource tests' temp folders --- test/ios-project-service-native-source.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/ios-project-service-native-source.ts b/test/ios-project-service-native-source.ts index dd8f692126..7b9cc8d99e 100644 --- a/test/ios-project-service-native-source.ts +++ b/test/ios-project-service-native-source.ts @@ -6,12 +6,13 @@ import { FileSystem } from "../lib/common/file-system"; import { IOSProjectService } from "../lib/services/ios-project-service"; describe("iOSProjectService getRootGroup", () => { + let root: string; let projectDir: string; let sourcesDir: string; let cwd: string; beforeEach(() => { - const root = fs.mkdtempSync(path.join(os.tmpdir(), "native-source-")); + root = fs.mkdtempSync(path.join(os.tmpdir(), "native-source-")); projectDir = path.join(root, "apps", "app"); sourcesDir = path.join(root, "libs", "native"); fs.mkdirSync(projectDir, { recursive: true }); @@ -23,6 +24,7 @@ describe("iOSProjectService getRootGroup", () => { afterEach(() => { process.chdir(cwd); + fs.rmSync(root, { recursive: true, force: true }); }); const getFiles = async (rootPath: string): Promise => { From 43270f04973bde746cfa17dd1609954dad8d4831 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 27 Nov 2026 18:25:00 -0800 Subject: [PATCH 5/9] fix(ios): keep the configured NativeSource path as the pbxgroup key nativescript-dev-xcode finds an existing group by the exact (name, path) stored in .ns-build-pbxgroup-data.json. A relative ios.NativeSource folder was stored as written, so passing the resolved absolute path added a second group on the first prepare after upgrading, with every source compiled twice. The configured path stays the key; the files and header search path still use the path resolved against the project. --- lib/services/ios-project-service.ts | 14 ++-- test/ios-project-service-native-source.ts | 83 +++++++++++++++-------- 2 files changed, 63 insertions(+), 34 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index c1b4b27db8..f1a7197a00 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -1537,6 +1537,7 @@ export class IOSProjectService sourceFolderPath, projectData.projectDir, ); + const sourceFolder = path.resolve(projectData.projectDir, sourceFolderPath); // pin the sources to the main app target: without an explicit target the // underlying xcode lib picks whichever "Sources" build phase it finds // first, which can be an extension target (e.g. a widget) once one @@ -1554,19 +1555,19 @@ export class IOSProjectService .filter((file) => path.extname(file) === ".h") .map((file) => path.dirname(file)), ) - : [group.path]; + : [sourceFolder]; headerSearchPaths.forEach((searchPath) => project.addToHeaderSearchPaths(searchPath), ); - const headerFiles = this.$fs.exists(group.path) + const headerFiles = this.$fs.exists(sourceFolder) ? this.$fs.enumerateFilesInDirectorySync( - group.path, + sourceFolder, (file, stat) => stat.isDirectory() || path.extname(file) === ".h", ) : []; if ( headerFiles.length > 0 && - !this.$fs.exists(path.join(group.path, "module.modulemap")) + !this.$fs.exists(path.join(sourceFolder, "module.modulemap")) ) { this.$logger.warn( `warning: Directory ${sourceFolderPath} with native iOS source code doesn't contain a modulemap file. Metadata for it will not be generated and it will not be accessible from JavaScript. To learn more see https://docs.nativescript.org/guides/ios-source-code`, @@ -1620,6 +1621,8 @@ export class IOSProjectService const rootGroup: INativeSourceCodeGroup = { name: name, files: filePathsArr, + // nativescript-dev-xcode looks the group up by this exact string. Keep it + // as configured: resolving it duplicates the group in prepared projects. path: rootPath, }; @@ -1632,12 +1635,11 @@ export class IOSProjectService } } else { const folderPath = path.resolve(projectRoot, rootPath); - rootGroup.path = folderPath; if (this.$fs.exists(folderPath)) { const stats = this.$fs.getFsStats(folderPath); if (stats.isDirectory() && !this.$fs.isEmptyDir(folderPath)) { this.$fs.readDirectory(folderPath).forEach((fileName) => { - const filePath = path.join(rootGroup.path, fileName); + const filePath = path.join(folderPath, fileName); filePathsArr.push(filePath); }); } diff --git a/test/ios-project-service-native-source.ts b/test/ios-project-service-native-source.ts index 7b9cc8d99e..b3c6862fe9 100644 --- a/test/ios-project-service-native-source.ts +++ b/test/ios-project-service-native-source.ts @@ -28,7 +28,8 @@ describe("iOSProjectService getRootGroup", () => { }); const getFiles = async (rootPath: string): Promise => { - const { files } = await (IOSProjectService.prototype).getRootGroup.call( + const proto = IOSProjectService.prototype; + const { files } = await proto.getRootGroup.call( { $fs: new FileSystem({}) }, "Native", rootPath, @@ -50,29 +51,54 @@ describe("iOSProjectService getRootGroup", () => { assert.deepEqual(await getFiles("../../libs/native"), [expectedSource()]); }); - describe("header search paths", () => { - const prepare = async (rootPath: string): Promise => { - const searchPaths: string[] = []; - const proto = IOSProjectService.prototype; - await proto.prepareNativeSourceCode.call( - { - $fs: new FileSystem({}), - $logger: { warn: () => {} }, - getRootGroup: proto.getRootGroup, - savePbxProj: () => {}, - createPbxProj: () => ({ - addPbxGroup: () => {}, - getFirstTarget: () => ({ uuid: "target" }), - addToHeaderSearchPaths: (searchPath: string) => - searchPaths.push(searchPath), - }), - }, - "Native", - rootPath, - { projectDir }, - ); - return searchPaths.map((searchPath) => fs.realpathSync(searchPath)); + const prepare = async (rootPath: string) => { + const groupPaths: string[] = []; + const groupFiles: string[] = []; + const searchPaths: string[] = []; + const proto = IOSProjectService.prototype; + await proto.prepareNativeSourceCode.call( + { + $fs: new FileSystem({}), + $logger: { warn: () => {} }, + getRootGroup: proto.getRootGroup, + savePbxProj: () => {}, + createPbxProj: () => ({ + addPbxGroup: (files: string[], name: string, groupPath: string) => { + groupPaths.push(groupPath); + groupFiles.push(...files); + }, + getFirstTarget: () => ({ uuid: "target" }), + addToHeaderSearchPaths: (searchPath: string) => + searchPaths.push(searchPath), + }), + }, + "Native", + rootPath, + { projectDir }, + ); + return { + groupPaths, + groupFiles: groupFiles.map((file) => fs.realpathSync(file)), + searchPaths: searchPaths.map((searchPath) => fs.realpathSync(searchPath)), }; + }; + + describe("pbxgroup", () => { + [".", path.join("apps", "app")].forEach((workingDir) => { + it(`keeps the configured folder as its key, run from ${workingDir}`, async () => { + process.chdir(path.join(root, workingDir)); + + const { groupPaths, groupFiles } = await prepare("../../libs/native"); + + assert.deepEqual(groupPaths, ["../../libs/native"]); + assert.deepEqual(groupFiles, [expectedSource()]); + }); + }); + }); + + describe("header search paths", () => { + const searchPathsFor = async (rootPath: string) => + (await prepare(rootPath)).searchPaths; it("uses the folders of the headers a glob matches", async () => { const nested = path.join(sourcesDir, "nested"); @@ -80,17 +106,18 @@ describe("iOSProjectService getRootGroup", () => { fs.writeFileSync(path.join(nested, "One.h"), ""); fs.writeFileSync(path.join(nested, "Two.h"), ""); - assert.deepEqual(await prepare("../../libs/native/**/*.{h,swift}"), [ - fs.realpathSync(nested), - ]); + assert.deepEqual( + await searchPathsFor("../../libs/native/**/*.{h,swift}"), + [fs.realpathSync(nested)], + ); }); it("adds nothing for a glob without headers", async () => { - assert.deepEqual(await prepare("../../libs/native/*.swift"), []); + assert.deepEqual(await searchPathsFor("../../libs/native/*.swift"), []); }); it("uses the folder itself, against the project", async () => { - assert.deepEqual(await prepare("../../libs/native"), [ + assert.deepEqual(await searchPathsFor("../../libs/native"), [ fs.realpathSync(sourcesDir), ]); }); From 564f57069a9f88ce27c103c597bcbdf3d7ce86e7 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 27 Nov 2026 18:25:28 -0800 Subject: [PATCH 6/9] fix(ios): don't nest absolute NativeSource glob matches under the project fast-glob returns absolute matches for an absolute pattern, and joining them onto the project folder produced paths like /proj/proj/src/File.swift. Resolving them against the project keeps absolute matches as they are. --- lib/services/ios-project-service.ts | 3 +-- test/ios-project-service-native-source.ts | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index f1a7197a00..aa225213fb 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -1630,8 +1630,7 @@ export class IOSProjectService // Relative to the project: --path can run the CLI from anywhere. const filePaths = await fastGlob(rootPath, { cwd: projectRoot }); for (const filePath of filePaths) { - const sourceFilePath = path.normalize(path.join(projectRoot, filePath)); - filePathsArr.push(sourceFilePath); + filePathsArr.push(path.resolve(projectRoot, filePath)); } } else { const folderPath = path.resolve(projectRoot, rootPath); diff --git a/test/ios-project-service-native-source.ts b/test/ios-project-service-native-source.ts index b3c6862fe9..28dd7928d4 100644 --- a/test/ios-project-service-native-source.ts +++ b/test/ios-project-service-native-source.ts @@ -47,6 +47,12 @@ describe("iOSProjectService getRootGroup", () => { ]); }); + it("keeps an absolute glob as it is", async () => { + assert.deepEqual(await getFiles(path.join(sourcesDir, "*.swift")), [ + expectedSource(), + ]); + }); + it("resolves a folder against the project, not the working directory", async () => { assert.deepEqual(await getFiles("../../libs/native"), [expectedSource()]); }); From c6e10a7541923ab4a11b7a70370be39b20d83039 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 27 Nov 2026 18:26:18 -0800 Subject: [PATCH 7/9] fix(ios): look for a NativeSource glob's module map next to its headers For a glob, the module map check looked inside the pattern itself, which never exists, so headers without a module map went unreported. The check now looks in the header search paths, and the folder of any module.modulemap the glob matches is added to them. --- lib/services/ios-project-service.ts | 48 ++++++++++++++--------- test/ios-project-service-native-source.ts | 44 ++++++++++++++++++++- 2 files changed, 72 insertions(+), 20 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index aa225213fb..bfe62dcee5 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -1537,7 +1537,6 @@ export class IOSProjectService sourceFolderPath, projectData.projectDir, ); - const sourceFolder = path.resolve(projectData.projectDir, sourceFolderPath); // pin the sources to the main app target: without an explicit target the // underlying xcode lib picks whichever "Sources" build phase it finds // first, which can be an extension target (e.g. a widget) once one @@ -1548,27 +1547,38 @@ export class IOSProjectService filesRelativeToProject: true, target: project.getFirstTarget()?.uuid, }); - // A glob is no use as a search path, the folders of its headers are. - const headerSearchPaths = fastGlob.isDynamicPattern(sourceFolderPath) - ? _.uniq( - group.files - .filter((file) => path.extname(file) === ".h") - .map((file) => path.dirname(file)), - ) - : [sourceFolder]; + let headerFiles: string[]; + let headerSearchPaths: string[]; + if (fastGlob.isDynamicPattern(sourceFolderPath)) { + // A glob is no use as a search path, the folders of its headers and + // module maps are. + headerFiles = group.files.filter((file) => path.extname(file) === ".h"); + const moduleMaps = group.files.filter( + (file) => path.basename(file) === "module.modulemap", + ); + headerSearchPaths = _.uniq( + headerFiles.concat(moduleMaps).map((file) => path.dirname(file)), + ); + } else { + const sourceFolder = path.resolve( + projectData.projectDir, + sourceFolderPath, + ); + headerFiles = this.$fs.exists(sourceFolder) + ? this.$fs.enumerateFilesInDirectorySync( + sourceFolder, + (file, stat) => stat.isDirectory() || path.extname(file) === ".h", + ) + : []; + headerSearchPaths = [sourceFolder]; + } headerSearchPaths.forEach((searchPath) => project.addToHeaderSearchPaths(searchPath), ); - const headerFiles = this.$fs.exists(sourceFolder) - ? this.$fs.enumerateFilesInDirectorySync( - sourceFolder, - (file, stat) => stat.isDirectory() || path.extname(file) === ".h", - ) - : []; - if ( - headerFiles.length > 0 && - !this.$fs.exists(path.join(sourceFolder, "module.modulemap")) - ) { + const hasModuleMap = headerSearchPaths.some((searchPath) => + this.$fs.exists(path.join(searchPath, "module.modulemap")), + ); + if (headerFiles.length > 0 && !hasModuleMap) { this.$logger.warn( `warning: Directory ${sourceFolderPath} with native iOS source code doesn't contain a modulemap file. Metadata for it will not be generated and it will not be accessible from JavaScript. To learn more see https://docs.nativescript.org/guides/ios-source-code`, ); diff --git a/test/ios-project-service-native-source.ts b/test/ios-project-service-native-source.ts index 28dd7928d4..c41da8c06e 100644 --- a/test/ios-project-service-native-source.ts +++ b/test/ios-project-service-native-source.ts @@ -61,11 +61,12 @@ describe("iOSProjectService getRootGroup", () => { const groupPaths: string[] = []; const groupFiles: string[] = []; const searchPaths: string[] = []; + const warnings: string[] = []; const proto = IOSProjectService.prototype; await proto.prepareNativeSourceCode.call( { $fs: new FileSystem({}), - $logger: { warn: () => {} }, + $logger: { warn: (message: string) => warnings.push(message) }, getRootGroup: proto.getRootGroup, savePbxProj: () => {}, createPbxProj: () => ({ @@ -86,6 +87,7 @@ describe("iOSProjectService getRootGroup", () => { groupPaths, groupFiles: groupFiles.map((file) => fs.realpathSync(file)), searchPaths: searchPaths.map((searchPath) => fs.realpathSync(searchPath)), + warnings, }; }; @@ -128,4 +130,44 @@ describe("iOSProjectService getRootGroup", () => { ]); }); }); + + describe("module map", () => { + let headers: string; + + beforeEach(() => { + headers = path.join(sourcesDir, "headers"); + fs.mkdirSync(headers); + fs.writeFileSync(path.join(headers, "Header.h"), ""); + }); + + it("warns when the headers a glob matches have no module map", async () => { + const { warnings } = await prepare("../../libs/native/**/*.h"); + + assert.lengthOf(warnings, 1); + }); + + it("finds a module map next to the headers a glob matches", async () => { + fs.writeFileSync(path.join(headers, "module.modulemap"), ""); + + const { warnings } = await prepare("../../libs/native/**/*.h"); + + assert.deepEqual(warnings, []); + }); + + it("adds the folder of a module map a glob matches to the search paths", async () => { + const modules = path.join(sourcesDir, "modules"); + fs.mkdirSync(modules); + fs.writeFileSync(path.join(modules, "module.modulemap"), ""); + + const { searchPaths, warnings } = await prepare( + "../../libs/native/**/*.{h,modulemap}", + ); + + assert.deepEqual(searchPaths, [ + fs.realpathSync(headers), + fs.realpathSync(modules), + ]); + assert.deepEqual(warnings, []); + }); + }); }); From 5c40db1ea0cfa6085d8cd2bb3aec71e96278b101 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 27 Nov 2026 18:27:06 -0800 Subject: [PATCH 8/9] refactor(pnpm): drop option deletes covered by CLI_ONLY_OPTIONS getFlagsString already skips ignoreScripts, path and frameworkPath for every package manager. --- lib/pnpm-package-manager.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/pnpm-package-manager.ts b/lib/pnpm-package-manager.ts index 5970d50c2e..4beb797e05 100644 --- a/lib/pnpm-package-manager.ts +++ b/lib/pnpm-package-manager.ts @@ -44,11 +44,6 @@ export class PnpmPackageManager extends BasePackageManager { if (config.ignoreScripts) { config["ignore-scripts"] = true; } - // CLI-internal options must never reach the command line: pnpm, unlike - // npm, hard-fails on unknown options. - delete config.ignoreScripts; - delete config.path; - delete config.frameworkPath; const packageJsonPath = path.join(pathToSave, "package.json"); const jsonContentBefore = this.$fs.readJson(packageJsonPath); From 89659c5acda904058a4fcf64fd86c441a428f088 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 27 Nov 2026 18:27:06 -0800 Subject: [PATCH 9/9] test: cover --ignore-scripts installs for npm, yarn and bun Also give the test package manager the base constructor's five arguments, so it is really npm rather than an object. --- test/base-package-manager.ts | 44 +++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/test/base-package-manager.ts b/test/base-package-manager.ts index d94cf1aced..5ca9242f5b 100644 --- a/test/base-package-manager.ts +++ b/test/base-package-manager.ts @@ -1,9 +1,15 @@ import { assert } from "chai"; import { BasePackageManager } from "../lib/base-package-manager"; +import { BunPackageManager } from "../lib/bun-package-manager"; +import { IInjector } from "../lib/common/definitions/yok"; +import { Yok } from "../lib/common/yok"; +import { NodePackageManager } from "../lib/node-package-manager"; +import { YarnPackageManager } from "../lib/yarn-package-manager"; +import * as stubs from "./stubs"; class TestPackageManager extends (BasePackageManager) { constructor() { - super({}, {}, {}, {}, {}, "npm"); + super({}, {}, {}, {}, "npm"); } } @@ -29,4 +35,40 @@ describe("BasePackageManager", () => { "--save-dev", ]); }); + + [ + { name: "npm", packageManager: NodePackageManager }, + { name: "yarn", packageManager: YarnPackageManager }, + { name: "bun", packageManager: BunPackageManager }, + ].forEach(({ name, packageManager }) => { + it(`maps ignoreScripts to --ignore-scripts when installing with ${name}`, async () => { + const injector: IInjector = new Yok(); + injector.register("hostInfo", { isWindows: false }); + injector.register("errors", stubs.ErrorsStub); + injector.register("logger", stubs.LoggerStub); + injector.register("childProcess", stubs.ChildProcessStub); + injector.register("httpClient", {}); + injector.register("fs", stubs.FileSystemStub); + injector.register("pacoteService", {}); + injector.register(name, packageManager); + const projectDir = "/some-project"; + + await injector + .resolve(name) + .install(projectDir, projectDir, { + ignoreScripts: true, + path: "apps/app", + frameworkPath: "runtime.tgz", + }); + + const args = + injector.resolve( + "childProcess", + ).lastCommandArgs; + assert.include(args, "--ignore-scripts"); + assert.notInclude(args, "--ignoreScripts"); + assert.notInclude(args, "--path"); + assert.notInclude(args, "--frameworkPath"); + }); + }); });