Skip to content

feat(ios): multi target support for swift packages #5828

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 11, 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
6 changes: 4 additions & 2 deletions lib/definitions/ios.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,18 @@ declare global {
): Promise<string>;
}

type IosSPMPackage = IosSPMPackageDefinition & { targets?: string[] };

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

interface IXcodebuildArgsService {
Expand Down
2 changes: 1 addition & 1 deletion lib/services/ios-project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1425,7 +1425,7 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ

if (addedExtensionsFromResources || addedExtensionsFromPlugins) {
this.$logger.warn(
"The support for iOS App Extensions is currently in Beta. For more information about the current development state and any known issues, please check the relevant GitHub issue: https://github.com/NativeScript/nativescript-cli/issues/4472"
"Let us know if there are other Extension features you'd like! https://github.com/NativeScript/NativeScript/issues"
);
}
}
Expand Down
11 changes: 9 additions & 2 deletions lib/services/ios/spm-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class SPMService implements ISPMService {
public getSPMPackages(
projectData: IProjectData,
platform: string
): IosSPMPackageDefinition[] {
): IosSPMPackage[] {
const spmPackages = this.$projectConfigService.getValue(
`${platform}.SPMPackages`,
[]
Expand All @@ -35,7 +35,7 @@ export class SPMService implements ISPMService {
public async applySPMPackages(
platformData: IPlatformData,
projectData: IProjectData,
pluginSpmPackages?: IosSPMPackageDefinition[]
pluginSpmPackages?: IosSPMPackage[]
) {
try {
const spmPackages = this.getSPMPackages(
Expand Down Expand Up @@ -76,6 +76,13 @@ export class SPMService implements ISPMService {
}
this.$logger.trace(`SPM: adding package ${pkg.name} to project.`, pkg);
await project.ios.addSPMPackage(projectData.projectName, pkg);

// Add to other Targets if specified (like widgets, etc.)
if (pkg.targets?.length) {
for (const target of pkg.targets) {
await project.ios.addSPMPackage(target, pkg);
}
}
}
await project.commit();

Expand Down