From 2919a87ee4b2037c87ad7a5748704e78a98462fc Mon Sep 17 00:00:00 2001 From: Bohdan Pidluzhnyy Date: Tue, 13 Sep 2022 15:40:26 +0300 Subject: [PATCH 1/4] Update capacitor-plugin-bbd-base for Cordova SDK 11.0 release --- README.md | 4 +- package.json | 2 +- scripts/hooks/bbdCapacitorCleanup.js | 7 ++- scripts/hooks/bbdCapacitorInstall.js | 16 +++-- scripts/hooks/helper.js | 62 +++++++++++++++++-- scripts/hooks/ios/BlackBerryDynamics.podspec | 2 +- scripts/hooks/ios/setDynamicsPodspec.js | 8 +-- scripts/hooks/ios/update_deployment_target.rb | 26 ++++++++ 8 files changed, 105 insertions(+), 22 deletions(-) create mode 100644 scripts/hooks/ios/update_deployment_target.rb diff --git a/README.md b/README.md index 4f78fdc..e0ee3ff 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Dynamics SDK for iOS and Android are installed as part of the `capacitor-plugin- The integration uses the iOS "Dynamic Framework" version of BlackBerry Dynamics as the static library is no longer supported. There are a few options to integrate BlackBerry Dynamics SDK for iOS. #### Using latest released version - default -By default, `capacitor-plugin-bbd-base` plugin will integrate **latest** available BlackBerry Dynamics SDK for iOS using following podspec: `https://software.download.blackberry.com/repository/framework/dynamics/ios/10.2.0.83/BlackBerryDynamics-10.2.0.83.podspec`. +By default, `capacitor-plugin-bbd-base` plugin will integrate **latest** available BlackBerry Dynamics SDK for iOS using following podspec: `https://software.download.blackberry.com/repository/framework/dynamics/ios/11.0.0.116/BlackBerryDynamics-11.0.0.116.podspec`. > NOTE: If one of the below integration methods was used there is an option to reset **default** configuration by running following command: `$ npx set-dynamics-podspec --default` `$ ionic cap build ios` @@ -43,7 +43,7 @@ By default, `capacitor-plugin-bbd-base` plugin will integrate **latest** availab There is possibility to integrate other released build of BlackBerry Dynamics SDK for iOS. Following command should be run: ``` -$ npx set-dynamics-podspec --url "https://software.download.blackberry.com/repository/framework/dynamics/ios/10.1.0.36/BlackBerryDynamics-10.1.0.36.podspec" +$ npx set-dynamics-podspec --url "https://software.download.blackberry.com/repository/framework/dynamics/ios/10.2.0.83/BlackBerryDynamics-10.2.0.83.podspec" $ ionic cap build ios ``` #### Using locally downloaded version diff --git a/package.json b/package.json index 2cc225e..200adda 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "capacitor-plugin-bbd-base", "version": "1.0.0", - "dynamicsPodSpec":"https://software.download.blackberry.com/repository/framework/dynamics/ios/10.2.0.83/BlackBerryDynamics-10.2.0.83.podspec", + "dynamicsPodSpec":"https://software.download.blackberry.com/repository/framework/dynamics/ios/11.0.0.116/BlackBerryDynamics-11.0.0.116.podspec", "description": "BlackBerry Dynamics Capacitor Base plugin.", "license": "SEE LICENSE IN LICENSE", "homepage": "https://community.blackberry.com", diff --git a/scripts/hooks/bbdCapacitorCleanup.js b/scripts/hooks/bbdCapacitorCleanup.js index af32583..d69592d 100755 --- a/scripts/hooks/bbdCapacitorCleanup.js +++ b/scripts/hooks/bbdCapacitorCleanup.js @@ -14,8 +14,8 @@ * limitations under the License. */ -(function () { - const { checkAndExitOrContinueOnUninstall, replaceAndSave } = require('./helper'); + (function () { + const { checkAndExitOrContinueOnUninstall, replaceAndSave, removeAssertDeploymentTarget } = require('./helper'); // We should run this script only if we uninstall capacitor-plugin-bbd-base plugin. // In other circumstances like 'npm i' or 'yarn' or 'npm uninstall' or 'npm i ' we should exit. @@ -152,7 +152,7 @@ ] ]); replaceAndSave(capacitorPodFilePath, [ - [`platform :ios, '14.0'`, `platform :ios, '12.0'`], + [`platform :ios, '14.0'`, `platform :ios, '13.0'`], [/pod 'BlackBerryDynamics', (:podspec|:path) => '(.+)'/, ''] ]); replaceAndSave(capacitorPodSpecFile, [ @@ -164,6 +164,7 @@ replaceAndSave(capacitorCLIPodsSpecPath, [ [`s.dependency 'BlackBerryDynamics'`, ''] ]); + removeAssertDeploymentTarget(capacitorPodFilePath); } catch (error) { console.log(error); } diff --git a/scripts/hooks/bbdCapacitorInstall.js b/scripts/hooks/bbdCapacitorInstall.js index 7482a95..3c093d0 100755 --- a/scripts/hooks/bbdCapacitorInstall.js +++ b/scripts/hooks/bbdCapacitorInstall.js @@ -14,8 +14,13 @@ * limitations under the License. */ -(function () { - const { checkAndExitOrContinueOnInstall, patchCAPBridgeViewController, replaceAndSave } = require('./helper'); + (function () { + const { + checkAndExitOrContinueOnInstall, + patchCAPBridgeViewController, + replaceAndSave, + addAssertDeploymentTarget + } = require('./helper'); // We should run this script only if we install capacitor-plugin-bbd-base plugin. // In other circumstances like 'npm i' or 'yarn' or 'npm uninstall' or 'npm i ' we should exit. @@ -64,8 +69,7 @@ capacitorPodFile = path.join(projectRoot, 'ios', 'App', 'Podfile'), BlackBerryDependencyPhrase = `s.dependency 'BlackBerryDynamics'`, SwiftVersionPhrase = `s.swift_version = '5.1'`, - addYourPodsHerePhrase = '# Add your Pods here', - platformVersion = version => `platform :ios, '${version}'`; + addYourPodsHerePhrase = '# Add your Pods here'; if (!fse.existsSync(cordovaPluginsPodsSpecPath)) { console.log('File not found at path: ', cordovaPluginsPodsSpecPath); @@ -94,13 +98,15 @@ const podsSpecPhrase = `pod 'BlackBerryDynamics', :podspec => '${dynamicsPodSpec}'`; replaceAndSave(capacitorPodFile, [ - [platformVersion('12.0'), platformVersion('14.0')], + [/platform :ios, \'([\d\.\d]+)\'/, "platform :ios, '14.0'"], [ addYourPodsHerePhrase, `${addYourPodsHerePhrase}\n\t${podsSpecPhrase}` ] ]); + addAssertDeploymentTarget(capacitorPodFile); + // add dependency to Capacitor pod file const capacitorPodSpecFile = path.join(projectRoot, 'node_modules', '@capacitor', 'ios', 'Capacitor.podspec'); replaceAndSave(capacitorPodSpecFile, [ diff --git a/scripts/hooks/helper.js b/scripts/hooks/helper.js index 0df7aba..429ce0e 100644 --- a/scripts/hooks/helper.js +++ b/scripts/hooks/helper.js @@ -41,8 +41,6 @@ const linkerFlags = { }; const podsPhrases = { - BlackBerryDynamics: "pod 'BlackBerryDynamics', :podspec => " + - "'https://software.download.blackberry.com/repository/framework/dynamics/ios/10.2.0.83/BlackBerryDynamics-10.2.0.83.podspec'", BlackBerryLauncher: "pod 'BlackBerryLauncher', :path => '../../node_modules/cordova-plugin-bbd-launcher'", }; @@ -136,14 +134,17 @@ exports.updateLauncher = () => { const podFilePath = path.join(projectRoot, 'ios', 'App', 'Podfile'); if ('cordova-plugin-bbd-launcher' in packageJson.dependencies) { - let fileContext = fs.readFileSync(podFilePath); - if (fileContext.includes(podsPhrases.BlackBerryLauncher)) + let fileContext = fs.readFileSync(podFilePath).toString(); + if (fileContext.includes(podsPhrases.BlackBerryLauncher)) { return; + } + + podsPhrases.BlackBerryDynamics = getBlackBerryDynamicsPodPhrase(fileContext); replaceAndSave(podFilePath, [ [ podsPhrases.BlackBerryDynamics, - `${podsPhrases.BlackBerryDynamics}\n\t${podsPhrases.BlackBerryLauncher}` + addAfter(podsPhrases.BlackBerryDynamics, podsPhrases.BlackBerryLauncher) ] ]); } else { @@ -169,13 +170,53 @@ exports.cleanUpCAPBridgeViewController = () => { ]); } +const targetVersion = '14.0'; +const requireHelperPhrase = "require_relative '../../node_modules/" + + "capacitor-plugin-bbd-base/scripts/hooks/ios/update_deployment_target.rb'" + + "\n"; +const postInstallPhrase = [ + `post_install do |installer|`, + ` project = Xcodeproj::Project.open('App.xcodeproj')`, + ` update_deployment_target project, ${targetVersion}`, + ` project.save`, + ``, + ` update_deployment_target installer.pods_project, ${targetVersion}`, + `end` +].join("\n"); +const assertDeploymentTargetReplacePhrase = [ + `post_install do |installer|`, + ` assertDeploymentTarget(installer)`, + `end` +].join("\n"); + +exports.addAssertDeploymentTarget = (capacitorPodFile) => { + let podFileContent = fse.readFileSync( + capacitorPodFile, + { encoding: "utf-8" } + ).toString(); + + if (podFileContent.includes("assertDeploymentTarget(installer)")) { + podFileContent = podFileContent.replace(assertDeploymentTargetReplacePhrase, ""); + } + + podFileContent = requireHelperPhrase + podFileContent + postInstallPhrase; + fse.writeFileSync(capacitorPodFile, podFileContent); +} + +exports.removeAssertDeploymentTarget = (capacitorPodFile) => { + replaceAndSave(capacitorPodFile, [ + [requireHelperPhrase, ""], + [postInstallPhrase, assertDeploymentTargetReplacePhrase] + ]); +} + function replaceAndSave(filePath, collection) { if (!fs.existsSync(filePath)) { throw new Error(`File not exists at path ${filePath}`) } const encoding = { encoding: 'utf8' }; - let fileContext = fs.readFileSync(filePath, encoding); + let fileContext = fs.readFileSync(filePath, encoding).toString(); for (const [search, replace] of collection) { fileContext = fileContext.replace(search, replace); @@ -202,4 +243,13 @@ function addLinkerForBuildType(buildType, linker) { } } +function getBlackBerryDynamicsPodPhrase(context) { + const [match] = context.match(/pod 'BlackBerryDynamics', (:podspec|:path) => '(.+)'/); + return match; +} + +function addAfter(phrase, newPhrase) { + return `${phrase}\n\t${newPhrase}` +} + exports.replaceAndSave = replaceAndSave; diff --git a/scripts/hooks/ios/BlackBerryDynamics.podspec b/scripts/hooks/ios/BlackBerryDynamics.podspec index 0019ab6..9cbf365 100644 --- a/scripts/hooks/ios/BlackBerryDynamics.podspec +++ b/scripts/hooks/ios/BlackBerryDynamics.podspec @@ -24,7 +24,7 @@ Pod::Spec.new do |spec| spec.description = <<-DESC Framework for building secure enterprise applications managed by BlackBerry Unified Endpoint Management (UEM). DESC - spec.platform = :ios, '13.0' + spec.platform = :ios, '14.0' spec.source = { :git => "", :tag => "#{spec.version}" } spec.requires_arc = true spec.swift_version = '5.0' diff --git a/scripts/hooks/ios/setDynamicsPodspec.js b/scripts/hooks/ios/setDynamicsPodspec.js index efdde76..0a8c1ce 100755 --- a/scripts/hooks/ios/setDynamicsPodspec.js +++ b/scripts/hooks/ios/setDynamicsPodspec.js @@ -23,7 +23,7 @@ const { dynamicsPodSpec } = require(path.join(bbdBasePath, 'package.json')); const pattern = /pod 'BlackBerryDynamics', (:podspec|:path) => '(.+)'/; - const parce = (arg, options = { value: null }) => { + const parse = (arg, options = { value: null }) => { const argument = { index: null, value: null @@ -46,9 +46,9 @@ } const pod = { - path: parce('--path'), - url: parce('--url'), - default: parce('--default', { value: true }) + path: parse('--path'), + url: parse('--url'), + default: parse('--default', { value: true }) } let spec; diff --git a/scripts/hooks/ios/update_deployment_target.rb b/scripts/hooks/ios/update_deployment_target.rb new file mode 100644 index 0000000..4d9cc93 --- /dev/null +++ b/scripts/hooks/ios/update_deployment_target.rb @@ -0,0 +1,26 @@ +# +# Copyright (c) 2022 BlackBerry Limited. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +def update_deployment_target(project, version) + project.targets.each do |target| + target.build_configurations.each do |config| + deployment_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f + if deployment_target < version && deployment_target != 0.0 + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "#{version}" + end + end + end +end From 7c26fcc6120c155ddcebdca7940c5a07b7af5c9a Mon Sep 17 00:00:00 2001 From: Taras Omelchuk Date: Wed, 19 Oct 2022 15:00:25 +0300 Subject: [PATCH 2/4] Updated Dynamics SDK for iOS and Dynamics SDK for Android versions for 11 release --- README.md | 2 +- package.json | 2 +- scripts/gradle/bbd.gradle | 6 +++--- scripts/hooks/helper.js | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 524206d..6fc6db9 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ Dynamics SDK for iOS and Android are installed as part of the `capacitor-plugin- The integration uses the iOS "Dynamic Framework" version of BlackBerry Dynamics as the static library is no longer supported. There are a few options to integrate BlackBerry Dynamics SDK for iOS. #### Using latest released version - default -By default, `capacitor-plugin-bbd-base` plugin will integrate **latest** available BlackBerry Dynamics SDK for iOS using following podspec: `https://software.download.blackberry.com/repository/framework/dynamics/ios/10.2.0.83/BlackBerryDynamics-10.2.0.83.podspec`. +By default, `capacitor-plugin-bbd-base` plugin will integrate **latest** available BlackBerry Dynamics SDK for iOS using following podspec: `https://software.download.blackberry.com/repository/framework/dynamics/ios/11.0.1.137/BlackBerryDynamics-11.0.1.137.podspec`. > NOTE: If one of the below integration methods was used there is an option to reset **default** configuration by running following command: `$ npx set-dynamics-podspec --default` `$ ionic cap build ios` diff --git a/package.json b/package.json index 2cc225e..a16a5c5 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "capacitor-plugin-bbd-base", "version": "1.0.0", - "dynamicsPodSpec":"https://software.download.blackberry.com/repository/framework/dynamics/ios/10.2.0.83/BlackBerryDynamics-10.2.0.83.podspec", + "dynamicsPodSpec":"https://software.download.blackberry.com/repository/framework/dynamics/ios/11.0.1.137/BlackBerryDynamics-11.0.1.137.podspec", "description": "BlackBerry Dynamics Capacitor Base plugin.", "license": "SEE LICENSE IN LICENSE", "homepage": "https://community.blackberry.com", diff --git a/scripts/gradle/bbd.gradle b/scripts/gradle/bbd.gradle index dbd69ec..22f704d 100755 --- a/scripts/gradle/bbd.gradle +++ b/scripts/gradle/bbd.gradle @@ -40,9 +40,9 @@ allprojects { } dependencies { - implementation 'com.blackberry.blackberrydynamics:android_handheld_platform:10.2.0.79' - implementation 'com.blackberry.blackberrydynamics:android_handheld_backup_support:10.2.0.79' - implementation 'com.blackberry.blackberrydynamics:android_webview:10.2.0.79' + implementation 'com.blackberry.blackberrydynamics:android_handheld_platform:11.0.1.140' + implementation 'com.blackberry.blackberrydynamics:android_handheld_backup_support:11.0.1.140' + implementation 'com.blackberry.blackberrydynamics:android_webview:11.0.1.140' implementation 'androidx.legacy:legacy-support-v4:1.0.0' diff --git a/scripts/hooks/helper.js b/scripts/hooks/helper.js index 46c55fe..30ba995 100644 --- a/scripts/hooks/helper.js +++ b/scripts/hooks/helper.js @@ -42,7 +42,7 @@ const linkerFlags = { const podsPhrases = { BlackBerryDynamics: "pod 'BlackBerryDynamics', :podspec => " + - "'https://software.download.blackberry.com/repository/framework/dynamics/ios/10.2.0.83/BlackBerryDynamics-10.2.0.83.podspec'", + "'https://software.download.blackberry.com/repository/framework/dynamics/ios/11.0.1.137/BlackBerryDynamics-11.0.1.137.podspec'", BlackBerryLauncher: "pod 'BlackBerryLauncher', :path => '../../node_modules/cordova-plugin-bbd-launcher'", }; From b5e5d6609228942aaa1d06c0d64d5da3b444607c Mon Sep 17 00:00:00 2001 From: Bohdan Pidluzhnyy Date: Tue, 13 Sep 2022 15:40:26 +0300 Subject: [PATCH 3/4] Update capacitor-plugin-bbd-base for Cordova SDK 11.0 release --- README.md | 2 +- scripts/hooks/bbdCapacitorCleanup.js | 12 +++- scripts/hooks/bbdCapacitorInstall.js | 16 +++-- scripts/hooks/helper.js | 60 +++++++++++++++++-- scripts/hooks/ios/BlackBerryDynamics.podspec | 2 +- scripts/hooks/ios/setDynamicsPodspec.js | 8 +-- scripts/hooks/ios/update_deployment_target.rb | 26 ++++++++ 7 files changed, 108 insertions(+), 18 deletions(-) create mode 100644 scripts/hooks/ios/update_deployment_target.rb diff --git a/README.md b/README.md index 6fc6db9..ec7f9ff 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ By default, `capacitor-plugin-bbd-base` plugin will integrate **latest** availab There is possibility to integrate other released build of BlackBerry Dynamics SDK for iOS. Following command should be run: ``` -$ npx set-dynamics-podspec --url "https://software.download.blackberry.com/repository/framework/dynamics/ios/10.1.0.36/BlackBerryDynamics-10.1.0.36.podspec" +$ npx set-dynamics-podspec --url "https://software.download.blackberry.com/repository/framework/dynamics/ios/10.2.0.83/BlackBerryDynamics-10.2.0.83.podspec" $ ionic cap build ios ``` #### Using locally downloaded version diff --git a/scripts/hooks/bbdCapacitorCleanup.js b/scripts/hooks/bbdCapacitorCleanup.js index b649749..1f74261 100755 --- a/scripts/hooks/bbdCapacitorCleanup.js +++ b/scripts/hooks/bbdCapacitorCleanup.js @@ -14,8 +14,13 @@ * limitations under the License. */ -(function () { - const { checkAndExitOrContinueOnUninstall, replaceAndSave, readBundleIdFromCapacitorConfig } = require('./helper'); + (function () { + const { + checkAndExitOrContinueOnUninstall, + replaceAndSave, + removeAssertDeploymentTarget, + readBundleIdFromCapacitorConfig + } = require('./helper'); // We should run this script only if we uninstall capacitor-plugin-bbd-base plugin. // In other circumstances like 'npm i' or 'yarn' or 'npm uninstall' or 'npm i ' we should exit. @@ -151,7 +156,7 @@ ] ]); replaceAndSave(capacitorPodFilePath, [ - [`platform :ios, '14.0'`, `platform :ios, '12.0'`], + [`platform :ios, '14.0'`, `platform :ios, '13.0'`], [/pod 'BlackBerryDynamics', (:podspec|:path) => '(.+)'/, ''] ]); replaceAndSave(capacitorPodSpecFile, [ @@ -163,6 +168,7 @@ replaceAndSave(capacitorCLIPodsSpecPath, [ [`s.dependency 'BlackBerryDynamics'`, ''] ]); + removeAssertDeploymentTarget(capacitorPodFilePath); } catch (error) { console.log(error); } diff --git a/scripts/hooks/bbdCapacitorInstall.js b/scripts/hooks/bbdCapacitorInstall.js index 7482a95..3c093d0 100755 --- a/scripts/hooks/bbdCapacitorInstall.js +++ b/scripts/hooks/bbdCapacitorInstall.js @@ -14,8 +14,13 @@ * limitations under the License. */ -(function () { - const { checkAndExitOrContinueOnInstall, patchCAPBridgeViewController, replaceAndSave } = require('./helper'); + (function () { + const { + checkAndExitOrContinueOnInstall, + patchCAPBridgeViewController, + replaceAndSave, + addAssertDeploymentTarget + } = require('./helper'); // We should run this script only if we install capacitor-plugin-bbd-base plugin. // In other circumstances like 'npm i' or 'yarn' or 'npm uninstall' or 'npm i ' we should exit. @@ -64,8 +69,7 @@ capacitorPodFile = path.join(projectRoot, 'ios', 'App', 'Podfile'), BlackBerryDependencyPhrase = `s.dependency 'BlackBerryDynamics'`, SwiftVersionPhrase = `s.swift_version = '5.1'`, - addYourPodsHerePhrase = '# Add your Pods here', - platformVersion = version => `platform :ios, '${version}'`; + addYourPodsHerePhrase = '# Add your Pods here'; if (!fse.existsSync(cordovaPluginsPodsSpecPath)) { console.log('File not found at path: ', cordovaPluginsPodsSpecPath); @@ -94,13 +98,15 @@ const podsSpecPhrase = `pod 'BlackBerryDynamics', :podspec => '${dynamicsPodSpec}'`; replaceAndSave(capacitorPodFile, [ - [platformVersion('12.0'), platformVersion('14.0')], + [/platform :ios, \'([\d\.\d]+)\'/, "platform :ios, '14.0'"], [ addYourPodsHerePhrase, `${addYourPodsHerePhrase}\n\t${podsSpecPhrase}` ] ]); + addAssertDeploymentTarget(capacitorPodFile); + // add dependency to Capacitor pod file const capacitorPodSpecFile = path.join(projectRoot, 'node_modules', '@capacitor', 'ios', 'Capacitor.podspec'); replaceAndSave(capacitorPodSpecFile, [ diff --git a/scripts/hooks/helper.js b/scripts/hooks/helper.js index 30ba995..afbefdd 100644 --- a/scripts/hooks/helper.js +++ b/scripts/hooks/helper.js @@ -155,14 +155,17 @@ exports.updateLauncher = () => { const podFilePath = path.join(projectRoot, 'ios', 'App', 'Podfile'); if ('cordova-plugin-bbd-launcher' in packageJson.dependencies) { - let fileContext = fs.readFileSync(podFilePath); - if (fileContext.includes(podsPhrases.BlackBerryLauncher)) + let fileContext = fs.readFileSync(podFilePath).toString(); + if (fileContext.includes(podsPhrases.BlackBerryLauncher)) { return; + } + + podsPhrases.BlackBerryDynamics = getBlackBerryDynamicsPodPhrase(fileContext); replaceAndSave(podFilePath, [ [ podsPhrases.BlackBerryDynamics, - `${podsPhrases.BlackBerryDynamics}\n\t${podsPhrases.BlackBerryLauncher}` + addAfter(podsPhrases.BlackBerryDynamics, podsPhrases.BlackBerryLauncher) ] ]); } else { @@ -188,13 +191,53 @@ exports.cleanUpCAPBridgeViewController = () => { ]); } +const targetVersion = '14.0'; +const requireHelperPhrase = "require_relative '../../node_modules/" + + "capacitor-plugin-bbd-base/scripts/hooks/ios/update_deployment_target.rb'" + + "\n"; +const postInstallPhrase = [ + `post_install do |installer|`, + ` project = Xcodeproj::Project.open('App.xcodeproj')`, + ` update_deployment_target project, ${targetVersion}`, + ` project.save`, + ``, + ` update_deployment_target installer.pods_project, ${targetVersion}`, + `end` +].join("\n"); +const assertDeploymentTargetReplacePhrase = [ + `post_install do |installer|`, + ` assertDeploymentTarget(installer)`, + `end` +].join("\n"); + +exports.addAssertDeploymentTarget = (capacitorPodFile) => { + let podFileContent = fse.readFileSync( + capacitorPodFile, + { encoding: "utf-8" } + ).toString(); + + if (podFileContent.includes("assertDeploymentTarget(installer)")) { + podFileContent = podFileContent.replace(assertDeploymentTargetReplacePhrase, ""); + } + + podFileContent = requireHelperPhrase + podFileContent + postInstallPhrase; + fse.writeFileSync(capacitorPodFile, podFileContent); +} + +exports.removeAssertDeploymentTarget = (capacitorPodFile) => { + replaceAndSave(capacitorPodFile, [ + [requireHelperPhrase, ""], + [postInstallPhrase, assertDeploymentTargetReplacePhrase] + ]); +} + function replaceAndSave(filePath, collection) { if (!fs.existsSync(filePath)) { throw new Error(`File not exists at path ${filePath}`) } const encoding = { encoding: 'utf8' }; - let fileContext = fs.readFileSync(filePath, encoding); + let fileContext = fs.readFileSync(filePath, encoding).toString(); for (const [search, replace] of collection) { fileContext = fileContext.replace(search, replace); @@ -221,4 +264,13 @@ function addLinkerForBuildType(buildType, linker) { } } +function getBlackBerryDynamicsPodPhrase(context) { + const [match] = context.match(/pod 'BlackBerryDynamics', (:podspec|:path) => '(.+)'/); + return match; +} + +function addAfter(phrase, newPhrase) { + return `${phrase}\n\t${newPhrase}` +} + exports.replaceAndSave = replaceAndSave; diff --git a/scripts/hooks/ios/BlackBerryDynamics.podspec b/scripts/hooks/ios/BlackBerryDynamics.podspec index 0019ab6..9cbf365 100644 --- a/scripts/hooks/ios/BlackBerryDynamics.podspec +++ b/scripts/hooks/ios/BlackBerryDynamics.podspec @@ -24,7 +24,7 @@ Pod::Spec.new do |spec| spec.description = <<-DESC Framework for building secure enterprise applications managed by BlackBerry Unified Endpoint Management (UEM). DESC - spec.platform = :ios, '13.0' + spec.platform = :ios, '14.0' spec.source = { :git => "", :tag => "#{spec.version}" } spec.requires_arc = true spec.swift_version = '5.0' diff --git a/scripts/hooks/ios/setDynamicsPodspec.js b/scripts/hooks/ios/setDynamicsPodspec.js index efdde76..0a8c1ce 100755 --- a/scripts/hooks/ios/setDynamicsPodspec.js +++ b/scripts/hooks/ios/setDynamicsPodspec.js @@ -23,7 +23,7 @@ const { dynamicsPodSpec } = require(path.join(bbdBasePath, 'package.json')); const pattern = /pod 'BlackBerryDynamics', (:podspec|:path) => '(.+)'/; - const parce = (arg, options = { value: null }) => { + const parse = (arg, options = { value: null }) => { const argument = { index: null, value: null @@ -46,9 +46,9 @@ } const pod = { - path: parce('--path'), - url: parce('--url'), - default: parce('--default', { value: true }) + path: parse('--path'), + url: parse('--url'), + default: parse('--default', { value: true }) } let spec; diff --git a/scripts/hooks/ios/update_deployment_target.rb b/scripts/hooks/ios/update_deployment_target.rb new file mode 100644 index 0000000..4d9cc93 --- /dev/null +++ b/scripts/hooks/ios/update_deployment_target.rb @@ -0,0 +1,26 @@ +# +# Copyright (c) 2022 BlackBerry Limited. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +def update_deployment_target(project, version) + project.targets.each do |target| + target.build_configurations.each do |config| + deployment_target = config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'].to_f + if deployment_target < version && deployment_target != 0.0 + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = "#{version}" + end + end + end +end From f382d9e0cd177ae7e7574ffd912594af9c077a2a Mon Sep 17 00:00:00 2001 From: Bohdan Pidluzhnyy Date: Thu, 20 Oct 2022 11:57:08 +0300 Subject: [PATCH 4/4] update plugin version --- package.json | 2 +- plugin.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a16a5c5..ae405e1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "capacitor-plugin-bbd-base", - "version": "1.0.0", + "version": "1.1.0", "dynamicsPodSpec":"https://software.download.blackberry.com/repository/framework/dynamics/ios/11.0.1.137/BlackBerryDynamics-11.0.1.137.podspec", "description": "BlackBerry Dynamics Capacitor Base plugin.", "license": "SEE LICENSE IN LICENSE", diff --git a/plugin.xml b/plugin.xml index 7849204..5ab5a42 100644 --- a/plugin.xml +++ b/plugin.xml @@ -25,7 +25,7 @@ + id="capacitor-plugin-bbd-base" version="1.1.0"> BlackBerry Dynamics Capacitor Base plugin This is Base plugin. It adds all the needed configuration to enable using