From f6cf96e7768db2343aeae6328f767fa4e2f09d19 Mon Sep 17 00:00:00 2001 From: Nuno Azevedo Date: Fri, 13 May 2022 12:33:08 +0100 Subject: [PATCH 1/4] fix: podfile generation when app name has apostrophes References https://outsystemsrd.atlassian.net/browse/RNMT-5302 References https://outsystemsrd.atlassian.net/browse/RNMT-6172 --- lib/Podfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Podfile.js b/lib/Podfile.js index fd7bf8db9..fe628b74a 100644 --- a/lib/Podfile.js +++ b/lib/Podfile.js @@ -75,7 +75,7 @@ Podfile.prototype.__parseForDeclarations = function (text) { // getting lines between "platform :ios, '11.0'"" and "target 'HelloCordova'" do const declarationsPreRE = /platform :ios,\s+'[^']+'/; - const declarationsPostRE = /target\s+'[^']+'\s+do/; + const declarationsPostRE = /target\s+'.+'\s+do/; const declarationRE = /^\s*[^#]/; return arr.reduce((acc, line) => { From 781d3f7a84506c23c98cc9fb84a10dda094b2b2d Mon Sep 17 00:00:00 2001 From: Nuno Azevedo Date: Wed, 20 Jul 2022 14:52:38 +0100 Subject: [PATCH 2/4] feat: add preference to disable MacOS target References https://outsystemsrd.atlassian.net/browse/RNMT-5719 References https://outsystemsrd.atlassian.net/browse/RNMT-6172 --- lib/prepare.js | 18 +++++++- tests/spec/unit/fixtures/test-config-3.xml | 1 + tests/spec/unit/prepare.spec.js | 51 ++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/lib/prepare.js b/lib/prepare.js index 722fc6415..2d40bd3ac 100644 --- a/lib/prepare.js +++ b/lib/prepare.js @@ -305,6 +305,9 @@ function handleBuildSettings (platformConfig, locations, infoPlist) { const deploymentTarget = platformConfig.getPreference('deployment-target', 'ios'); const swiftVersion = platformConfig.getPreference('SwiftVersion', 'ios'); + const supportMac = platformConfig.getPreference('SupportMac', 'ios'); + const disableMacTarget = supportMac !== undefined && supportMac.toString().toLowerCase() === 'false'; + let project; try { @@ -317,7 +320,7 @@ function handleBuildSettings (platformConfig, locations, infoPlist) { // no build settings provided and we don't need to update build settings for launch storyboards, // then we don't need to parse and update .pbxproj file - if (origPkg === pkg && !targetDevice && !deploymentTarget && !swiftVersion) { + if (origPkg === pkg && !targetDevice && !deploymentTarget && !swiftVersion && !disableMacTarget) { return Promise.resolve(); } @@ -341,6 +344,19 @@ function handleBuildSettings (platformConfig, locations, infoPlist) { project.xcode.updateBuildProperty('SWIFT_VERSION', swiftVersion); } + if (disableMacTarget) { + events.emit('verbose', 'Disable MacOS target.'); + // This whole conundrum is required in order to only change the settings of the PBXNativeTarget and not the PBXProject + Object.values(project.xcode.pbxNativeTargetSection()) + .filter((item) => item.isa === 'PBXNativeTarget' && item.name) + .forEach((item) => { + const target = item.name.replace(/^['"]*|['"]*$/g, ''); // Remove leading and trailing quotes + project.xcode.updateBuildProperty('SUPPORTED_PLATFORMS', '"iphoneos iphonesimulator"', undefined, target); + project.xcode.updateBuildProperty('SUPPORTS_MACCATALYST', 'NO', undefined, target); + project.xcode.updateBuildProperty('SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD', 'NO', undefined, target); + }); + } + project.write(); // If we have a Podfile, we want to update the deployment target there too diff --git a/tests/spec/unit/fixtures/test-config-3.xml b/tests/spec/unit/fixtures/test-config-3.xml index fda80c6e0..e646f68b3 100644 --- a/tests/spec/unit/fixtures/test-config-3.xml +++ b/tests/spec/unit/fixtures/test-config-3.xml @@ -14,6 +14,7 @@ + diff --git a/tests/spec/unit/prepare.spec.js b/tests/spec/unit/prepare.spec.js index 769a3afac..3894a5ae4 100644 --- a/tests/spec/unit/prepare.spec.js +++ b/tests/spec/unit/prepare.spec.js @@ -649,6 +649,57 @@ describe('prepare', () => { }); }); + it('should support Mac apps by default', () => { + cfg2.name = () => 'SampleApp'; // new config does *not* have a name change + writeFileSyncSpy.and.callThrough(); + return updateProject(cfg2, p.locations).then(() => { + const proj = new XcodeProject(p.locations.pbxproj); /* eslint new-cap : 0 */ + proj.parseSync(); + const supportedPlatforms = proj.getBuildProperty('SUPPORTED_PLATFORMS'); + expect(supportedPlatforms).toBeUndefined(); + const supportsMacCatalyst = proj.getBuildProperty('SUPPORTS_MACCATALYST'); + expect(supportsMacCatalyst).toEqual('YES'); + const supportsMacIPhoneIPad = proj.getBuildProperty('SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD'); + expect(supportsMacIPhoneIPad).toBeUndefined(); + }); + }); + + it('should support Mac apps if SupportMac preference is set to true', () => { + cfg3.name = () => 'SampleApp'; // new config does *not* have a name change + const pref = cfg3.doc.findall('platform[@name=\'ios\']/preference') + .filter(elem => elem.attrib.name.toLowerCase() === 'supportmac')[0]; + pref.attrib.value = 'true'; + writeFileSyncSpy.and.callThrough(); + return updateProject(cfg3, p.locations).then(() => { + const proj = new XcodeProject(p.locations.pbxproj); /* eslint new-cap : 0 */ + proj.parseSync(); + const supportedPlatforms = proj.getBuildProperty('SUPPORTED_PLATFORMS'); + expect(supportedPlatforms).toBeUndefined(); + const supportsMacCatalyst = proj.getBuildProperty('SUPPORTS_MACCATALYST'); + expect(supportsMacCatalyst).toEqual('YES'); + const supportsMacIPhoneIPad = proj.getBuildProperty('SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD'); + expect(supportsMacIPhoneIPad).toBeUndefined(); + }); + }); + + it('should not support Mac apps if SupportMac preference is set to false', () => { + cfg3.name = () => 'SampleApp'; // new config does *not* have a name change + const pref = cfg3.doc.findall('platform[@name=\'ios\']/preference') + .filter(elem => elem.attrib.name.toLowerCase() === 'supportmac')[0]; + pref.attrib.value = 'false'; + writeFileSyncSpy.and.callThrough(); + return updateProject(cfg3, p.locations).then(() => { + const proj = new XcodeProject(p.locations.pbxproj); /* eslint new-cap : 0 */ + proj.parseSync(); + const supportedPlatforms = proj.getBuildProperty('SUPPORTED_PLATFORMS'); + expect(supportedPlatforms).toEqual('"iphoneos iphonesimulator"'); + const supportsMacCatalyst = proj.getBuildProperty('SUPPORTS_MACCATALYST'); + expect(supportsMacCatalyst).toEqual('NO'); + const supportsMacIPhoneIPad = proj.getBuildProperty('SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD'); + expect(supportsMacIPhoneIPad).toEqual('NO'); + }); + }); + it('Test#002 : should write out the app id to info plist as CFBundleIdentifier', () => { const orig = cfg.getAttribute; cfg.getAttribute = function (name) { From a4f4f5331cd2790d79775ce6e50d605d8a1343ab Mon Sep 17 00:00:00 2001 From: Nuno Azevedo Date: Wed, 26 Jul 2023 15:43:14 +0100 Subject: [PATCH 3/4] ci: update CI for OutSystems requirements References https://outsystemsrd.atlassian.net/browse/RNMT-6172 --- .github/workflows/ci.yml | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8821d3fa..84fd8e78b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,20 +48,13 @@ jobs: env: CI: true - - uses: codecov/codecov-action@v4 - if: success() - with: - name: ${{ runner.os }} node.js ${{ matrix.node-version }} (darwin) - token: ${{ secrets.CORDOVA_CODECOV_TOKEN }} - fail_ci_if_error: false - non-darwin: name: NodeJS ${{ matrix.node-version }} on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: node-version: [16.x, 18.x, 20.x] - os: [ubuntu-latest, windows-latest] + os: [ubuntu-latest] steps: - uses: actions/checkout@v4 @@ -83,10 +76,3 @@ jobs: npm run unit-tests env: CI: true - - - uses: codecov/codecov-action@v4 - if: success() - with: - name: ${{ runner.os }} node.js ${{ matrix.node-version }} (non-darwin) - token: ${{ secrets.CORDOVA_CODECOV_TOKEN }} - fail_ci_if_error: false From 25baff43b16b39927dbfe61e4f043f46ca76b440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Destro?= Date: Tue, 24 Oct 2023 15:33:22 +0100 Subject: [PATCH 4/4] fix: revert orientation changes This commit brings back a method that was removed in version 7.0.0 of cordova-ios (77b4689) Removing this causes crashes in the barcode plug-in and possibly in customer applications. So, to avoid a breaking change we decided to keep it. --- CordovaLib/Classes/Public/CDVAppDelegate.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CordovaLib/Classes/Public/CDVAppDelegate.m b/CordovaLib/Classes/Public/CDVAppDelegate.m index a77fd2b4d..ce3b9a78e 100644 --- a/CordovaLib/Classes/Public/CDVAppDelegate.m +++ b/CordovaLib/Classes/Public/CDVAppDelegate.m @@ -87,4 +87,11 @@ - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDiction return YES; } +- (UIInterfaceOrientationMask)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window +{ + // iPhone doesn't support upside down by default, while the iPad does. Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected). + NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown); + return supportedInterfaceOrientations; +} + @end