@@ -215,6 +215,9 @@ export function scanDependencies(
215215 return result ;
216216}
217217
218+ const PODSPEC_NAME_REGEX =
219+ / ( P o d : : S p e c \. n e w \s + d o \s + \| (?< specref > .* ) \| ) .* ( \k<specref > \. n a m e \s + = \s + (?< quote > [ " ' ] ) (?< specname > [ a - z A - Z 0 - 9 _ \- @ ] + ) \k<quote > ) / ;
220+
218221/**
219222 * Generates LicensePlist-compatible metadata for NPM dependencies as a YAML string.
220223 *
@@ -243,9 +246,48 @@ export function generateLicensePlistNPMOutput(licenses: AggregatedLicensesMappin
243246 } as LicensePlistPayload ;
244247 } ) ;
245248
249+ const excludedEntries = Object . values ( licenses ) . reduce < Array < { name : string } > > ( ( acc , license ) => {
250+ const packageName = license . name ;
251+ const localPackageJsonPath = PackageUtils . getPackageJsonPath ( packageName ) ;
252+
253+ if ( ! localPackageJsonPath ) {
254+ return acc ;
255+ }
256+
257+ const podspecFiles = glob . sync ( '**.podspec' , {
258+ cwd : path . dirname ( localPackageJsonPath ) ,
259+ absolute : true ,
260+ nocase : true ,
261+ nodir : true ,
262+ ignore : '**/{__tests__,__fixtures__,__mocks__}/**' ,
263+ } ) ;
264+
265+ if ( ! podspecFiles ) {
266+ return acc ;
267+ }
268+
269+ const podspecEntries = podspecFiles . map ( ( podspecFile ) => {
270+ const podspecContent = fs . readFileSync ( podspecFile , { encoding : 'utf-8' } ) ;
271+ const podspecContentShrinked = podspecContent . replace ( / \n / g, ' ' ) ;
272+ const { specname } = PODSPEC_NAME_REGEX . exec ( podspecContentShrinked ) ?. groups ?? { } ;
273+
274+ return { name : specname ?? packageName } ;
275+ } ) ;
276+
277+ return [ ...acc , ...podspecEntries ] ;
278+ } , [ ] ) ;
279+
246280 const yamlDoc = {
247281 ...( Object . keys ( renames ) . length > 0 && { rename : renames } ) ,
248282 manual : licenseEntries ,
283+ /**
284+ * Adding excludes to prevent duplicates - NPM packages with iOS Podspecs are already
285+ * manually included in the `licenseEntries`. However License Plist is automatically including all
286+ * the entries detected via Pods-<project-name>-acknowledgements.plist, which also
287+ * includes the NPM package with iOS Podspecs - let's filter them out,
288+ * so that only the manual NPM entries are displayed
289+ */
290+ exclude : excludedEntries ,
249291 } ;
250292
251293 const yamlContent = [
0 commit comments