You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ma...@apache.org on 2026/08/07 09:43:05 UTC

(cordova-ios) branch master updated: fix(spm): keep `CordovaPlugins` deployment target synced across prepares (#1687)

This is an automated email from the ASF dual-hosted git repository.

GitToTheHub pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git


The following commit(s) were added to refs/heads/master by this push:
     new 8e6e86b4 fix(spm): keep `CordovaPlugins` deployment target synced across prepares (#1687)
8e6e86b4 is described below

commit 8e6e86b48d6c6f833b06a4a8f8f1fd157649f80d
Author: Manuel Beck <ma...@outlook.de>
AuthorDate: Fri Aug 7 11:42:59 2026 +0200

    fix(spm): keep `CordovaPlugins` deployment target synced across prepares (#1687)
    
    - The deployment target update logic for `CordovaPlugins` only matched enum-style platform declarations (for example .iOS(.v13)). After the first sync converted the package to string-style declarations (for example .iOS("18.0")), later prepares no longer updated the value.
    - Update SwiftPackage deployment target replacement to support both enum-style and string-style platform declarations for iOS and macCatalyst.
    - Also add a regression test that runs deployment target updates twice and verifies the second value replaces the first.
    - Closes #1683
    
    Generated-By: GPT-5.3-Codex
---
 lib/SwiftPackage.js             |  6 ++++--
 tests/spec/SwiftPackage.spec.js | 13 +++++++++++++
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/lib/SwiftPackage.js b/lib/SwiftPackage.js
index 2373c4fa..4c5468a1 100644
--- a/lib/SwiftPackage.js
+++ b/lib/SwiftPackage.js
@@ -44,8 +44,10 @@ package.targets.first?.dependencies.append(.product(name: "${plugin.id}", packag
         const fd = fs.openSync(this.path, 'r+');
         let packageContent = fs.readFileSync(fd, 'utf8');
 
-        packageContent = packageContent.replace(/\.iOS\(\.v[0-9]+\)/, `.iOS("${target}")`);
-        packageContent = packageContent.replace(/\.macCatalyst\(\.v[0-9]+\)/, `.macCatalyst("${target}")`);
+        // Support both enum-style (e.g. .iOS(.v13)) and string-style
+        // (e.g. .iOS("18.0")) deployment target declarations.
+        packageContent = packageContent.replace(/\.iOS\((?:\.v[0-9]+|"[0-9]+(?:\.[0-9]+)?")\)/, `.iOS("${target}")`);
+        packageContent = packageContent.replace(/\.macCatalyst\((?:\.v[0-9]+|"[0-9]+(?:\.[0-9]+)?")\)/, `.macCatalyst("${target}")`);
 
         fs.ftruncateSync(fd);
         fs.writeSync(fd, packageContent, 0, 'utf8');
diff --git a/tests/spec/SwiftPackage.spec.js b/tests/spec/SwiftPackage.spec.js
index 2c884a76..b8621068 100644
--- a/tests/spec/SwiftPackage.spec.js
+++ b/tests/spec/SwiftPackage.spec.js
@@ -101,6 +101,19 @@ describe('SwiftPackage', () => {
             expect(content).toContain('.iOS("18.4")');
             expect(content).toContain('.macCatalyst("18.4")');
         });
+
+        it('should update deployment target when package already uses string syntax', () => {
+            pkg.updateDeploymentTarget('18.4');
+            pkg.updateDeploymentTarget('19.1');
+
+            const pkgPath = path.join(tmpDir.name, 'packages', 'cordova-ios-plugins', 'Package.swift');
+            const content = fs.readFileSync(pkgPath, 'utf8');
+
+            expect(content).toContain('.iOS("19.1")');
+            expect(content).toContain('.macCatalyst("19.1")');
+            expect(content).not.toContain('.iOS("18.4")');
+            expect(content).not.toContain('.macCatalyst("18.4")');
+        });
     });
 
     describe('addPlugin', () => {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org