Skip to content

Commit b2bad0c

Browse files
authored
feat: plugins can now define their own nativescript.config for SPMPackage inclusion (#5826)
1 parent 9eac531 commit b2bad0c

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

lib/definitions/ios.d.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,15 @@ declare global {
4242
}
4343

4444
interface ISPMService {
45-
applySPMPackages(platformData: IPlatformData, projectData: IProjectData);
45+
applySPMPackages(
46+
platformData: IPlatformData,
47+
projectData: IProjectData,
48+
pluginSpmPackages?: IosSPMPackageDefinition[]
49+
);
50+
getSPMPackages(
51+
projectData: IProjectData,
52+
platform: string
53+
): IosSPMPackageDefinition[];
4654
}
4755

4856
interface IXcodebuildArgsService {

lib/services/ios-project-service.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ import {
3232
IIOSWatchAppService,
3333
IIOSNativeTargetService,
3434
IValidatePlatformOutput,
35+
IProjectConfigService,
3536
} from "../definitions/project";
3637

3738
import { IBuildData } from "../definitions/build";
@@ -121,7 +122,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
121122
private $sysInfo: ISysInfo,
122123
private $tempService: ITempService,
123124
private $spmService: ISPMService,
124-
private $mobileHelper: Mobile.IMobileHelper
125+
private $mobileHelper: Mobile.IMobileHelper,
126+
private $projectConfigService: IProjectConfigService
125127
) {
126128
super($fs, $projectDataService);
127129
}
@@ -1175,7 +1177,30 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ
11751177
);
11761178
}
11771179

1178-
await this.$spmService.applySPMPackages(platformData, projectData);
1180+
const pluginSpmPackages = [];
1181+
for (const plugin of pluginsData) {
1182+
const pluginConfigPath = path.join(
1183+
plugin.fullPath,
1184+
constants.CONFIG_FILE_NAME_TS
1185+
);
1186+
if (this.$fs.exists(pluginConfigPath)) {
1187+
const config = this.$projectConfigService.readConfig(plugin.fullPath);
1188+
const packages = _.get(
1189+
config,
1190+
`${platformData.platformNameLowerCase}.SPMPackages`,
1191+
[]
1192+
);
1193+
if (packages.length) {
1194+
pluginSpmPackages.push(...packages);
1195+
}
1196+
}
1197+
}
1198+
1199+
await this.$spmService.applySPMPackages(
1200+
platformData,
1201+
projectData,
1202+
pluginSpmPackages
1203+
);
11791204
}
11801205

11811206
public beforePrepareAllPlugins(

lib/services/ios/spm-service.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,20 @@ export class SPMService implements ISPMService {
3434

3535
public async applySPMPackages(
3636
platformData: IPlatformData,
37-
projectData: IProjectData
37+
projectData: IProjectData,
38+
pluginSpmPackages?: IosSPMPackageDefinition[]
3839
) {
3940
try {
4041
const spmPackages = this.getSPMPackages(
4142
projectData,
4243
platformData.platformNameLowerCase
4344
);
4445

46+
if (pluginSpmPackages?.length) {
47+
// include swift packages from plugin configs
48+
spmPackages.push(...pluginSpmPackages);
49+
}
50+
4551
if (!spmPackages.length) {
4652
this.$logger.trace("SPM: no SPM packages to apply.");
4753
return;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy