Skip to content
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