Content-Length: 354993 | pFad | http://github.com/NativeScript/nativescript-cli/pull/5830/files

89 feat(ios): allow collections of NativeSource to be included via nativescript.config by NathanWalker · Pull Request #5830 · NativeScript/nativescript-cli · GitHub
Skip to content

feat(ios): allow collections of NativeSource to be included via nativescript.config #5830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const APK_EXTENSION_NAME = ".apk";
export const AAB_EXTENSION_NAME = ".aab";
export const APKS_EXTENSION_NAME = ".apks";
export const HASHES_FILE_NAME = ".nshashes";
export const TNS_NATIVE_SOURCE_GROUP_NAME = "NSNativeSources";
export const TNS_NATIVE_SOURCE_GROUP_NAME = "AppResourcesSrc";
export const NATIVE_SOURCE_FOLDER = "src";
export const APPLICATION_RESPONSE_TIMEOUT_SECONDS = 60;
export const NATIVE_EXTENSION_FOLDER = "extensions";
Expand Down
52 changes: 40 additions & 12 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import * as projectServiceBaseLib from "./platform-project-service-base";
import { PlistSession, Reporter } from "plist-merge-patch";
import { EOL } from "os";
import * as plist from "plist";
import * as fastGlob from "fast-glob";
import { IOSProvisionService } from "./ios-provision-service";
import { IOSEntitlementsService } from "./ios-entitlements-service";
import { IOSBuildData } from "../data/build-data";
Expand Down Expand Up @@ -817,6 +818,21 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
resourcesNativeCodePath,
projectData
);

const nativeSource = this.$projectConfigService.getValue(
`${this._platformData.platformNameLowerCase}.NativeSource`,
[]
);

if (nativeSource?.length) {
for (const source of nativeSource) {
await this.prepareNativeSourceCode(
source.name,
source.path,
projectData
);
}
}
}

this.$iOSWatchAppService.removeWatchApp({ pbxProjPath });
Expand Down Expand Up @@ -1360,7 +1376,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
projectData: IProjectData
): Promise<void> {
const project = this.createPbxProj(projectData);
const group = this.getRootGroup(groupName, sourceFolderPath);
const group = await this.getRootGroup(groupName, sourceFolderPath);
project.addPbxGroup(group.files, group.name, group.path, null, {
isMain: true,
filesRelativeToProject: true,
Expand Down Expand Up @@ -1430,21 +1446,30 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}
}

private getRootGroup(name: string, rootPath: string) {
private async getRootGroup(name: string, rootPath: string) {
const filePathsArr: string[] = [];
const rootGroup: INativeSourceCodeGroup = {
name: name,
files: filePathsArr,
path: rootPath,
};

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 filePath = path.join(rootGroup.path, fileName);
filePathsArr.push(filePath);
});
if (fastGlob.isDynamicPattern(rootPath)) {
const projectRoot = this.$projectDataService.getProjectData().projectDir;
const filePaths = await fastGlob(rootPath);
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 filePath = path.join(rootGroup.path, fileName);
filePathsArr.push(filePath);
});
}
}
}

Expand Down Expand Up @@ -1499,13 +1524,16 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
}
}

private removeNativeSourceCode(
private async removeNativeSourceCode(
pluginPlatformsFolderPath: string,
pluginData: IPluginData,
projectData: IProjectData
): void {
) {
const project = this.createPbxProj(projectData);
const group = this.getRootGroup(pluginData.name, pluginPlatformsFolderPath);
const group = await this.getRootGroup(
pluginData.name,
pluginPlatformsFolderPath
);
project.removePbxGroup(group.name, group.path);
project.removeFromHeaderSearchPaths(group.path);
this.savePbxProj(project, projectData);
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/NativeScript/nativescript-cli/pull/5830/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy