From 2da517825b1ef17d8276c6c70786ed45c3cf50c9 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sat, 25 Jan 2025 09:07:18 -0800 Subject: [PATCH 1/2] feat: plugin nativescript.config support with SPMPackage inclusion --- lib/definitions/ios.d.ts | 5 +++++ lib/services/ios-project-service.ts | 30 ++++++++++++++++++++++++++++- lib/services/ios/spm-service.ts | 7 +++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/lib/definitions/ios.d.ts b/lib/definitions/ios.d.ts index 248b25b7b4..f2ad0c647b 100644 --- a/lib/definitions/ios.d.ts +++ b/lib/definitions/ios.d.ts @@ -42,7 +42,12 @@ declare global { } interface ISPMService { + pluginSpmPackages: IosSPMPackageDefinition[]; applySPMPackages(platformData: IPlatformData, projectData: IProjectData); + getSPMPackages( + projectData: IProjectData, + platform: string + ): IosSPMPackageDefinition[]; } interface IXcodebuildArgsService { diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index 63ffa26703..e4f1d10520 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -32,6 +32,7 @@ import { IIOSWatchAppService, IIOSNativeTargetService, IValidatePlatformOutput, + IProjectConfigService, } from "../definitions/project"; import { IBuildData } from "../definitions/build"; @@ -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); } @@ -1175,6 +1177,32 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ ); } + for (const plugin of pluginsData) { + const pluginPlatformsFolderPath = plugin.pluginPlatformsFolderPath( + IOSProjectService.IOS_PLATFORM_NAME + ); + const pluginConfigPath = path.join( + pluginPlatformsFolderPath, + constants.CONFIG_FILE_NAME_TS + ); + if (this.$fs.exists(pluginConfigPath)) { + const config = this.$projectConfigService.readConfig(pluginConfigPath); + + const pluginSpmPackages = _.get( + config, + `${platformData.platformNameLowerCase}.SPMPackages`, + [] + ); + if (pluginSpmPackages.length) { + if (!this.$spmService.pluginSpmPackages) { + this.$spmService.pluginSpmPackages = []; + } + + this.$spmService.pluginSpmPackages.push(...pluginSpmPackages); + } + } + } + await this.$spmService.applySPMPackages(platformData, projectData); } diff --git a/lib/services/ios/spm-service.ts b/lib/services/ios/spm-service.ts index 9965549ce4..c3314d222f 100644 --- a/lib/services/ios/spm-service.ts +++ b/lib/services/ios/spm-service.ts @@ -8,6 +8,8 @@ import { IPlatformData } from "../../definitions/platform"; import path = require("path"); export class SPMService implements ISPMService { + public pluginSpmPackages: IosSPMPackageDefinition[]; + constructor( private $logger: ILogger, private $projectConfigService: IProjectConfigService, @@ -42,6 +44,11 @@ export class SPMService implements ISPMService { platformData.platformNameLowerCase ); + if (this.pluginSpmPackages?.length) { + // include swift packages from plugin configs + spmPackages.push(...this.pluginSpmPackages); + } + if (!spmPackages.length) { this.$logger.trace("SPM: no SPM packages to apply."); return; From f9904d1b309bdae5c1f934c833ff8ab72a71d3f6 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Sat, 25 Jan 2025 10:14:49 -0800 Subject: [PATCH 2/2] chore: cleanup --- lib/definitions/ios.d.ts | 7 +++++-- lib/services/ios-project-service.ts | 25 +++++++++++-------------- lib/services/ios/spm-service.ts | 9 ++++----- 3 files changed, 20 insertions(+), 21 deletions(-) diff --git a/lib/definitions/ios.d.ts b/lib/definitions/ios.d.ts index f2ad0c647b..7b83af2bc6 100644 --- a/lib/definitions/ios.d.ts +++ b/lib/definitions/ios.d.ts @@ -42,8 +42,11 @@ declare global { } interface ISPMService { - pluginSpmPackages: IosSPMPackageDefinition[]; - applySPMPackages(platformData: IPlatformData, projectData: IProjectData); + applySPMPackages( + platformData: IPlatformData, + projectData: IProjectData, + pluginSpmPackages?: IosSPMPackageDefinition[] + ); getSPMPackages( projectData: IProjectData, platform: string diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index e4f1d10520..3f5c1bc214 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -1177,33 +1177,30 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ ); } + const pluginSpmPackages = []; for (const plugin of pluginsData) { - const pluginPlatformsFolderPath = plugin.pluginPlatformsFolderPath( - IOSProjectService.IOS_PLATFORM_NAME - ); const pluginConfigPath = path.join( - pluginPlatformsFolderPath, + plugin.fullPath, constants.CONFIG_FILE_NAME_TS ); if (this.$fs.exists(pluginConfigPath)) { - const config = this.$projectConfigService.readConfig(pluginConfigPath); - - const pluginSpmPackages = _.get( + const config = this.$projectConfigService.readConfig(plugin.fullPath); + const packages = _.get( config, `${platformData.platformNameLowerCase}.SPMPackages`, [] ); - if (pluginSpmPackages.length) { - if (!this.$spmService.pluginSpmPackages) { - this.$spmService.pluginSpmPackages = []; - } - - this.$spmService.pluginSpmPackages.push(...pluginSpmPackages); + if (packages.length) { + pluginSpmPackages.push(...packages); } } } - await this.$spmService.applySPMPackages(platformData, projectData); + await this.$spmService.applySPMPackages( + platformData, + projectData, + pluginSpmPackages + ); } public beforePrepareAllPlugins( diff --git a/lib/services/ios/spm-service.ts b/lib/services/ios/spm-service.ts index c3314d222f..6f19203934 100644 --- a/lib/services/ios/spm-service.ts +++ b/lib/services/ios/spm-service.ts @@ -8,8 +8,6 @@ import { IPlatformData } from "../../definitions/platform"; import path = require("path"); export class SPMService implements ISPMService { - public pluginSpmPackages: IosSPMPackageDefinition[]; - constructor( private $logger: ILogger, private $projectConfigService: IProjectConfigService, @@ -36,7 +34,8 @@ export class SPMService implements ISPMService { public async applySPMPackages( platformData: IPlatformData, - projectData: IProjectData + projectData: IProjectData, + pluginSpmPackages?: IosSPMPackageDefinition[] ) { try { const spmPackages = this.getSPMPackages( @@ -44,9 +43,9 @@ export class SPMService implements ISPMService { platformData.platformNameLowerCase ); - if (this.pluginSpmPackages?.length) { + if (pluginSpmPackages?.length) { // include swift packages from plugin configs - spmPackages.push(...this.pluginSpmPackages); + spmPackages.push(...pluginSpmPackages); } if (!spmPackages.length) { 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