Skip to content

feat: plugin nativescript.config support with SPMPackage inclusion #5826

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
Jan 29, 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
10 changes: 9 additions & 1 deletion lib/definitions/ios.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,15 @@ declare global {
}

interface ISPMService {
applySPMPackages(platformData: IPlatformData, projectData: IProjectData);
applySPMPackages(
platformData: IPlatformData,
projectData: IProjectData,
pluginSpmPackages?: IosSPMPackageDefinition[]
);
getSPMPackages(
projectData: IProjectData,
platform: string
): IosSPMPackageDefinition[];
}

interface IXcodebuildArgsService {
Expand Down
29 changes: 27 additions & 2 deletions lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
IIOSWatchAppService,
IIOSNativeTargetService,
IValidatePlatformOutput,
IProjectConfigService,
} from "../definitions/project";

import { IBuildData } from "../definitions/build";
Expand Down Expand Up @@ -121,7 +122,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
private $sysInfo: ISysInfo,
private $tempService: ITempService,
private $spmService: ISPMService,
private $mobileHelper: Mobile.IMobileHelper
private $mobileHelper: Mobile.IMobileHelper,
private $projectConfigService: IProjectConfigService
) {
super($fs, $projectDataService);
}
Expand Down Expand Up @@ -1175,7 +1177,30 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
);
}

await this.$spmService.applySPMPackages(platformData, projectData);
const pluginSpmPackages = [];
for (const plugin of pluginsData) {
const pluginConfigPath = path.join(
plugin.fullPath,
constants.CONFIG_FILE_NAME_TS
);
if (this.$fs.exists(pluginConfigPath)) {
const config = this.$projectConfigService.readConfig(plugin.fullPath);
const packages = _.get(
config,
`${platformData.platformNameLowerCase}.SPMPackages`,
[]
);
if (packages.length) {
pluginSpmPackages.push(...packages);
}
}
}

await this.$spmService.applySPMPackages(
platformData,
projectData,
pluginSpmPackages
);
}

public beforePrepareAllPlugins(
Expand Down
8 changes: 7 additions & 1 deletion lib/services/ios/spm-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,20 @@ export class SPMService implements ISPMService {

public async applySPMPackages(
platformData: IPlatformData,
projectData: IProjectData
projectData: IProjectData,
pluginSpmPackages?: IosSPMPackageDefinition[]
) {
try {
const spmPackages = this.getSPMPackages(
projectData,
platformData.platformNameLowerCase
);

if (pluginSpmPackages?.length) {
// include swift packages from plugin configs
spmPackages.push(...pluginSpmPackages);
}

if (!spmPackages.length) {
this.$logger.trace("SPM: no SPM packages to apply.");
return;
Expand Down