Skip to content

Commit 6444a0f

Browse files
fix: incorrect warning is shown when build for iOS
When you do not have iOS native source code in `<path to App_Resources>/iOS/src`, CLI shows warning that there's no modulemap and you'll not be able to use the code through JavaScript. However, there's no code at all. Skip the preparation of native source code in case there's no native sources there.
1 parent 5f10c48 commit 6444a0f

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

lib/services/ios-project-service.ts

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
343343
platformData.normalizedPlatformName,
344344
constants.NATIVE_SOURCE_FOLDER
345345
);
346+
346347
await this.prepareNativeSourceCode(constants.TNS_NATIVE_SOURCE_GROUP_NAME, resourcesNativeCodePath, projectData);
347348
}
348349

@@ -498,9 +499,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
498499
const pluginPlatformsFolderPath = pluginData.pluginPlatformsFolderPath(IOSProjectService.IOS_PLATFORM_NAME);
499500

500501
const sourcePath = path.join(pluginPlatformsFolderPath, "src");
501-
if (this.$fs.exists(pluginPlatformsFolderPath) && this.$fs.exists(sourcePath)) {
502-
await this.prepareNativeSourceCode(pluginData.name, sourcePath, projectData);
503-
}
502+
await this.prepareNativeSourceCode(pluginData.name, sourcePath, projectData);
504503

505504
await this.prepareResources(pluginPlatformsFolderPath, pluginData, projectData);
506505
await this.prepareFrameworks(pluginPlatformsFolderPath, pluginData, projectData);
@@ -644,14 +643,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
644643
}
645644

646645
private async prepareNativeSourceCode(groupName: string, sourceFolderPath: string, projectData: IProjectData): Promise<void> {
647-
const project = this.createPbxProj(projectData);
648-
const group = this.getRootGroup(groupName, sourceFolderPath);
649-
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true, filesRelativeToProject: true });
650-
project.addToHeaderSearchPaths(group.path);
651-
if (!this.$fs.exists(path.join(sourceFolderPath, "module.modulemap"))) {
652-
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`);
646+
if (this.$fs.exists(sourceFolderPath)) {
647+
const project = this.createPbxProj(projectData);
648+
const group = this.getRootGroup(groupName, sourceFolderPath);
649+
project.addPbxGroup(group.files, group.name, group.path, null, { isMain: true, filesRelativeToProject: true });
650+
project.addToHeaderSearchPaths(group.path);
651+
if (!this.$fs.exists(path.join(sourceFolderPath, "module.modulemap"))) {
652+
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`);
653+
}
654+
this.savePbxProj(project, projectData);
653655
}
654-
this.savePbxProj(project, projectData);
655656
}
656657

657658
private async addExtensions(projectData: IProjectData, pluginsData: IPluginData[]): Promise<void> {

0 commit comments

Comments
 (0)