From 8650894581f38ad86d1640dd674a9e5f53a96062 Mon Sep 17 00:00:00 2001 From: farfromrefuge Date: Thu, 22 Jun 2023 12:55:44 +0200 Subject: [PATCH] fix(ios): correctly link non dynamic frameworks Right now all frameworks were embedded and sign even though it should only happen with dynamic framework The code was there but the test was non working and thus all frameworks were embedded and signed. This is a better PR than https://github.com/NativeScript/nativescript-cli/pull/5743 where we were supposing the framework name was the name of xcframework file. Now we use the info.plist --- lib/services/ios-project-service.ts | 33 +++++++++++++++-------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/lib/services/ios-project-service.ts b/lib/services/ios-project-service.ts index b34caa3c9e..8dbc24c9f1 100644 --- a/lib/services/ios-project-service.ts +++ b/lib/services/ios-project-service.ts @@ -468,11 +468,8 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ } private async isDynamicFramework(frameworkPath: string): Promise { - const frameworkName = path.basename( - frameworkPath, - path.extname(frameworkPath) - ); - const isDynamicFrameworkBundle = async (bundlePath: string) => { + + const isDynamicFrameworkBundle = async (bundlePath: string, frameworkName: string) => { const frameworkBinaryPath = path.join(bundlePath, frameworkName); const fileResult = ( @@ -488,25 +485,29 @@ export class IOSProjectService extends projectServiceBaseLib.PlatformProjectServ if (path.extname(frameworkPath) === ".xcframework") { let isDynamic = true; - const subDirs = this.$fs - .readDirectory(frameworkPath) - .filter((entry) => - this.$fs.getFsStats(path.join(frameworkPath, entry)).isDirectory() - ); - for (const subDir of subDirs) { + const plistJson = this.$plistParser.parseFileSync(path.join(frameworkPath, 'Info.plist')); + for (const library of plistJson.AvailableLibraries) { const singlePlatformFramework = path.join( - subDir, - frameworkName + ".framework" + frameworkPath, + library.LibraryIdentifier, + library.LibraryPath ); if (this.$fs.exists(singlePlatformFramework)) { - isDynamic = await isDynamicFrameworkBundle(singlePlatformFramework); + const frameworkName = path.basename( + singlePlatformFramework, + path.extname(singlePlatformFramework) + ); + isDynamic = await isDynamicFrameworkBundle(singlePlatformFramework, frameworkName); break; } } - return isDynamic; } else { - return await isDynamicFrameworkBundle(frameworkPath); + const frameworkName = path.basename( + frameworkPath, + path.extname(frameworkPath) + ); + return await isDynamicFrameworkBundle(frameworkPath, frameworkName); } }