From 6caca9cf208dc97aac211d2573d30e4449e8d0b2 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Mon, 26 Aug 2024 23:00:00 -0700 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=94=A5=20Remove=20obsolete=20versions?= =?UTF-8?q?=20of=20the=20android=20SDK=20components?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is consistent with https://github.com/e-mission/e-mission-docs/issues/1079#issuecomment-2311464032 and may fix the errors in the CI/CD for the android SDK installation script Testing done: with the other changes in this PR, `npx cordova build` succeeded --- setup/android_sdk_packages | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/setup/android_sdk_packages b/setup/android_sdk_packages index a870852f1..27959824c 100644 --- a/setup/android_sdk_packages +++ b/setup/android_sdk_packages @@ -1,17 +1,8 @@ -build-tools;31.0.0 -build-tools;32.0.0 -build-tools;33.0.2 build-tools;34.0.0 emulator extras;google;google_play_services platform-tools -platforms;android-30 -platforms;android-31 -platforms;android-32 -platforms;android-33 platforms;android-34 -system-images;android-22;google_apis;x86_64 -system-images;android-23;google_apis;x86_64 system-images;android-24;google_apis_playstore;x86 system-images;android-25;google_apis_playstore;x86 system-images;android-26;google_apis_playstore;x86 @@ -20,9 +11,6 @@ system-images;android-28;google_apis_playstore;x86_64 system-images;android-29;google_apis_playstore;x86_64 system-images;android-30;google_apis_playstore;x86_64 system-images;android-31;google_apis_playstore;x86_64 -system-images;android-32;google_apis;x86_64 system-images;android-32;google_apis_playstore;x86_64 -system-images;android-33;google_apis;x86_64 system-images;android-33;google_apis_playstore;x86_64 -system-images;android-34;google_apis;x86_64 system-images;android-34;google_apis_playstore;x86_64 From a7539e9d4dcf190af9d256c569530987ccf12c44 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Mon, 26 Aug 2024 23:02:56 -0700 Subject: [PATCH 2/7] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20=20Bump=20up=20to=20th?= =?UTF-8?q?e=20latest=20version=20of=20all=20our=20dependencies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This includes: - cordova-android - cordova-ios - core plugins (inapp-browser) - cordova CLI - nvm, node, npm - cocoapods - gradle This is consistent with https://github.com/e-mission/e-mission-docs/issues/1079#issuecomment-2311569199 to look through the changes in the cordova codebase --- package.cordovabuild.json | 8 ++++---- setup/export_shared_dep_versions.sh | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/package.cordovabuild.json b/package.cordovabuild.json index a2c36e855..ff3812841 100644 --- a/package.cordovabuild.json +++ b/package.cordovabuild.json @@ -30,7 +30,7 @@ "babel-loader": "^9.1.2", "babel-plugin-optional-require": "^0.3.1", "concurrently": "^8.0.1", - "cordova": "^11.1.0", + "cordova": "12.0.0", "css-loader": "^6.7.4", "exports-loader": "^4.0.0", "expose-loader": "^4.1.0", @@ -113,8 +113,8 @@ "chart.js": "^4.3.0", "chartjs-adapter-luxon": "^1.3.1", "chartjs-plugin-annotation": "^3.0.1", - "cordova-android": "12.0.0", - "cordova-ios": "6.2.0", + "cordova-android": "13.0.0", + "cordova-ios": "7.1.1", "cordova-plugin-advanced-http": "3.3.1", "cordova-plugin-androidx-adapter": "1.1.3", "cordova-plugin-app-version": "0.1.14", @@ -128,7 +128,7 @@ "cordova-plugin-em-unifiedlogger": "git+https://github.com/e-mission/cordova-unified-logger.git#v1.3.6", "cordova-plugin-em-usercache": "git+https://github.com/e-mission/cordova-usercache.git#v1.1.9", "cordova-plugin-file": "8.0.0", - "cordova-plugin-inappbrowser": "5.0.0", + "cordova-plugin-inappbrowser": "6.0.0", "cordova-plugin-ionic-keyboard": "2.2.0", "cordova-plugin-ionic-webview": "5.0.0", "cordova-plugin-local-notification-12": "github:e-mission/cordova-plugin-local-notification-12#v0.1.4-fix-android-action", diff --git a/setup/export_shared_dep_versions.sh b/setup/export_shared_dep_versions.sh index ae3a5d58e..0105f95fc 100644 --- a/setup/export_shared_dep_versions.sh +++ b/setup/export_shared_dep_versions.sh @@ -1,13 +1,13 @@ -export NVM_VERSION=0.39.3 -export NODE_VERSION=19.5.0 -export NPM_VERSION=9.3.1 +export NVM_VERSION=0.40.0 +export NODE_VERSION=20.9.0 +export NPM_VERSION=10.8.2 # make sure that this is a stable version from # so that https://github.com/postmodern/ruby-versions # ideally, this would be the same version as the CI # Looks like brew supports only major and minor, not patch version export RUBY_VERSION=3.0 -export COCOAPODS_VERSION=1.12.1 -export GRADLE_VERSION=7.6 +export COCOAPODS_VERSION=1.15.2 +export GRADLE_VERSION=8.10 export OSX_EXP_VERSION=12 export NVM_DIR="$HOME/.nvm" From 399e9e7a4f83ed7d67fbf2e249179fa073cfec68 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Mon, 26 Aug 2024 23:05:40 -0700 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=94=A5=20Remove=20the=20manual=20grad?= =?UTF-8?q?le=20installation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit While investigating the issues with SSL errors, I discovered that cordova doesn't use the system gradle, but configures `build.gradle` so that the correct version of gradle is downloaded and installed on the first run. This means that we don't need to install gradle manually, which in turn, means that we don't need to install sdkman so that we install the pinned version of gradle. Yay for simplifying code and removing dependencies! https://github.com/e-mission/e-mission-docs/issues/1079#issuecomment-2311644633 --- setup/activate_native.sh | 3 --- setup/export_shared_dep_versions.sh | 1 - setup/setup_android_native.sh | 15 --------------- 3 files changed, 19 deletions(-) diff --git a/setup/activate_native.sh b/setup/activate_native.sh index c1014c987..21e8f7566 100644 --- a/setup/activate_native.sh +++ b/setup/activate_native.sh @@ -10,9 +10,6 @@ then echo "ANDROID_HOME and ANDROID_SDK_ROOT not set, android SDK not found" fi -echo "Activating sdkman, and by default, gradle" -source ~/.sdkman/bin/sdkman-init.sh - echo "Ensuring that we use the most recent version of the command line tools" export PATH=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin:$ANDROID_SDK_ROOT/emulator:$PATH diff --git a/setup/export_shared_dep_versions.sh b/setup/export_shared_dep_versions.sh index 0105f95fc..072977560 100644 --- a/setup/export_shared_dep_versions.sh +++ b/setup/export_shared_dep_versions.sh @@ -7,7 +7,6 @@ export NPM_VERSION=10.8.2 # Looks like brew supports only major and minor, not patch version export RUBY_VERSION=3.0 export COCOAPODS_VERSION=1.15.2 -export GRADLE_VERSION=8.10 export OSX_EXP_VERSION=12 export NVM_DIR="$HOME/.nvm" diff --git a/setup/setup_android_native.sh b/setup/setup_android_native.sh index 95dc9222e..3dfd5279e 100644 --- a/setup/setup_android_native.sh +++ b/setup/setup_android_native.sh @@ -27,19 +27,4 @@ else echo "ANDROID_HOME = $ANDROID_HOME; ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT" fi -echo "Setting up sdkman" -curl -s "https://get.sdkman.io" | bash -source ~/.sdkman/bin/sdkman-init.sh - -CURR_GRADLE_VER=`sdk current gradle | cut -d " " -f 4 | xargs` - -echo "CURR_GRADLE_VER = '$CURR_GRADLE_VER', expected $GRADLE_VERSION" - -if [[ $CURR_GRADLE_VER == $GRADLE_VERSION ]]; then - echo "Already have gradle version $GRADLE_VERSION" -else - echo "Setting up gradle using SDKMan" - sdk install gradle $GRADLE_VERSION -fi - source setup/setup_shared_native.sh From 4377e43ce570501b61f00db051fdcdda9193c246 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Mon, 26 Aug 2024 23:10:41 -0700 Subject: [PATCH 4/7] =?UTF-8?q?=F0=9F=94=A5=20Remove=20the=20pinned=20npm?= =?UTF-8?q?=20version;=20use=20the=20node=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We had a pinned npm version, but we didn't actually use it, using the default version in node instead. As long as we have a reasonbly recent version of node, that seems like it will work. It is still pinned (just pinned implicitly by the node pin), and we don't actually use the pinned version now anyway. Yay for simplicity and not keeping bitrotted code around... --- setup/activate_shared.sh | 3 --- setup/export_shared_dep_versions.sh | 1 - setup/setup_shared.sh | 8 -------- 3 files changed, 12 deletions(-) diff --git a/setup/activate_shared.sh b/setup/activate_shared.sh index 40f0c3fe7..1e46c9579 100644 --- a/setup/activate_shared.sh +++ b/setup/activate_shared.sh @@ -7,6 +7,3 @@ echo "Activating nvm" echo "Using version $NODE_VERSION" nvm use $NODE_VERSION - -CURR_NPM_VERSION=`npm --version` -echo "npm version = $CURR_NPM_VERSION" diff --git a/setup/export_shared_dep_versions.sh b/setup/export_shared_dep_versions.sh index 072977560..49d062a8b 100644 --- a/setup/export_shared_dep_versions.sh +++ b/setup/export_shared_dep_versions.sh @@ -1,6 +1,5 @@ export NVM_VERSION=0.40.0 export NODE_VERSION=20.9.0 -export NPM_VERSION=10.8.2 # make sure that this is a stable version from # so that https://github.com/postmodern/ruby-versions # ideally, this would be the same version as the CI diff --git a/setup/setup_shared.sh b/setup/setup_shared.sh index c47e892dd..53be485e6 100644 --- a/setup/setup_shared.sh +++ b/setup/setup_shared.sh @@ -12,11 +12,3 @@ echo "Setting up the variables to run nvm" echo "Installing the correct node version" nvm install $NODE_VERSION - -echo "Check the version of npm" -CURR_NPM_VERSION=`npm --version` -if [ $CURR_NPM_VERSION != $NPM_VERSION ]; -then - echo "Invalid npm version, expected $NPM_VERSION, got $CURR_NPM_VERSION" - npm install npm@$NPM_VERSION -fi From ff69416608222292c263785684f4a355c2e64787 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 27 Aug 2024 12:26:39 -0700 Subject: [PATCH 5/7] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20Use=20the=20correct?= =?UTF-8?q?=20package=20name=20for=20ibeacon=20plugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This ensures that we don't "discover" the plugin and try to install it https://github.com/e-mission/e-mission-phone/pull/1168#issuecomment-2313327905 Without this change: ``` Discovered plugin "cordova-plugin-ibeacon". Adding it to the project Plugin "com.unarin.cordova.beacon" already installed on android. Plugin "com.unarin.cordova.beacon" already installed on ios. ``` With this change: those logs don't show up --- package.cordovabuild.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.cordovabuild.json b/package.cordovabuild.json index ff3812841..3ee023ae8 100644 --- a/package.cordovabuild.json +++ b/package.cordovabuild.json @@ -98,7 +98,7 @@ }, "cordova-plugin-bluetooth-classic-serial-port": {}, "cordova-custom-config": {}, - "cordova-plugin-ibeacon": {} + "com.unarin.cordova.beacon": {} } }, "dependencies": { @@ -135,7 +135,7 @@ "cordova-plugin-x-socialsharing": "6.0.4", "cordova-plugin-bluetooth-classic-serial-port": "git+https://github.com/louisg1337/cordova-plugin-bluetooth-classic-serial-port.git", "cordova-custom-config": "^5.1.1", - "cordova-plugin-ibeacon": "git+https://github.com/louisg1337/cordova-plugin-ibeacon.git", + "com.unarin.cordova.beacon": "github:louisg1337/cordova-plugin-ibeacon", "core-js": "^2.5.7", "e-mission-common": "github:JGreenlee/e-mission-common#semver:0.5.4", "enketo-core": "^6.1.7", From 2a5f0bd7dd82525b5eab037ad82d02c6465835f4 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 27 Aug 2024 12:37:09 -0700 Subject: [PATCH 6/7] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20=20Move=20the=20ios=20?= =?UTF-8?q?script=20fix=20to=20`before=5Fcompile`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It was in `before_build` earlier, but that led to the changes from the script being overridden before the actual compile started https://github.com/e-mission/e-mission-docs/issues/1079#issuecomment-2311541336 https://github.com/e-mission/e-mission-phone/pull/1168#issuecomment-2313193479 https://github.com/e-mission/e-mission-phone/pull/1168#issuecomment-2313327905 https://github.com/e-mission/e-mission-phone/pull/1168#issuecomment-2313343892 https://github.com/e-mission/e-mission-phone/pull/1168#issuecomment-2313388338 Testing done: Before this change: ``` Done setting IPHONEOS_DEPLOYMENT_TARGET Overwriting existing resource file at platforms/ios/emission/Resources/GoogleService-Info.plist ^[[37mcordova-custom-config: Applied custom config from config.xml to /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/emission/emission-Info.plist^[[39m ``` After this change: ``` Overwriting existing resource file at platforms/ios/emission/Resources/GoogleService-Info.plist ^[[37mcordova-custom-config: Applied custom config from config.xml to /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/emission/emission-Info.plist^[[39m ... Done setting IPHONEOS_DEPLOYMENT_TARGET ... Touch /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/build/Debug-iphonesimulator/emission.app (in target 'emission' from project 'emission') cd /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios /usr/bin/touch -c /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/build/Debug-iphonesimulator/emission.app ** BUILD SUCCEEDED ** ``` --- config.cordovabuild.xml | 2 +- .../ios/ios_change_deployment.js | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename hooks/{before_build => before_compile}/ios/ios_change_deployment.js (100%) diff --git a/config.cordovabuild.xml b/config.cordovabuild.xml index 3401b9b9b..858f7fd4d 100644 --- a/config.cordovabuild.xml +++ b/config.cordovabuild.xml @@ -37,7 +37,7 @@ - + diff --git a/hooks/before_build/ios/ios_change_deployment.js b/hooks/before_compile/ios/ios_change_deployment.js similarity index 100% rename from hooks/before_build/ios/ios_change_deployment.js rename to hooks/before_compile/ios/ios_change_deployment.js From b93faf9d869d31a7e2caa3e255e2a443db76ec19 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Tue, 27 Aug 2024 13:36:01 -0700 Subject: [PATCH 7/7] =?UTF-8?q?=F0=9F=94=8A=20Improved=20logging=20around?= =?UTF-8?q?=20the=20script=20to=20patch=20the=20`IPHONEOS=5FDEPLOYMENT=5FT?= =?UTF-8?q?ARGET`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add additional logging to debug this more efficiently in the future The additional logging is accessed with `--verbose`. While testing this, I realized that `--verbose` would have been helpful in debugging this issue in the first place - it makes is really clear that the `pod install` happens as part of prepare before the compile. Still not sure how it worked locally before! - No verbose: ``` cordova-custom-config: Applied custom config from config.xml to /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/emission/emission-Info.plist Apply patch to [ 'node_modules/@shopify/flash-list/ios/RNFlashList.xcodeproj/project.pbxproj', 'node_modules/cordova-ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj', 'node_modules/cordova-ios/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj', 'node_modules/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj', 'node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj/project.pbxproj', 'node_modules/react-native-safe-area-context/ios/RNSafeAreaContext.xcodeproj/project.pbxproj', 'node_modules/react-native-screens/ios/RNScreens.xcodeproj/project.pbxproj', 'node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj/project.pbxproj', 'platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj', 'platforms/ios/Pods/Pods.xcodeproj/project.pbxproj', 'platforms/ios/emission.xcodeproj/project.pbxproj' ] Done setting IPHONEOS_DEPLOYMENT_TARGET List simulator targets Select last emulator from list as default. List simulator targets No simulator found for ". Falling back to the default target. Building for "iPhone 15 Pro Max" Simulator (com.apple.CoreSimulator.SimDeviceType.iPhone-15-Pro-Max, iPhone-15-Pro-Max). Building project: /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/emission.xcworkspace Configuration: Debug Platform: emulator Target: iPhone 15 Pro Max Command line invocation: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace emission.xcworkspace -scheme emission -configuration Debug -sdk iphonesimulator -destination "platform=iOS Simulator,name=iPhone 15 Pro Max" build SYMROOT=/Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/build ``` - verbose ``` pods.json found in platforms/ios Podfile found in platforms/ios Wrote to Podfile. Running `pod install` (to install plugins) ==== pod install start ==== ==== pod install end ==== Updating resource files at platforms/ios Prepared iOS project successfully Executing script found in config.xml for hook "before_compile": hooks/before_compile/ios/ios_change_deployment.js Context { hook: 'before_compile', opts: { platforms: [ 'ios' ], options: { verbose: true, argv: [] }, verbose: true, silent: false, nohooks: [], searchpath: undefined, projectRoot: '/Users/kshankar/Desktop/data/e-mission/native_code_upgrade', cordova: { platforms: [Array], plugins: [Array], version: '12.0.1' }, save: false, paths: [ '/Users/kshankar/Desktop/data/e-mission/native_code_upgrade/platforms/ios/www' ] }, cmdLine: '/Users/kshankar/.nvm/versions/node/v20.9.0/bin/node /Users/kshankar/Desktop/data/e-mission/native_code_upgrade/node_modules/.bin/cordova build ios --verbose', scriptLocation: '/Users/kshankar/Desktop/data/e-mission/native_code_upgrade/hooks/before_compile/ios/ios_change_deployment.js' } Apply patch to [ 'node_modules/@shopify/flash-list/ios/RNFlashList.xcodeproj/project.pbxproj', 'node_modules/cordova-ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj', 'node_modules/cordova-ios/templates/project/__PROJECT_NAME__.xcodeproj/project.pbxproj', 'node_modules/react-native/template/ios/HelloWorld.xcodeproj/project.pbxproj', 'node_modules/react-native-gesture-handler/ios/RNGestureHandler.xcodeproj/project.pbxproj', 'node_modules/react-native-safe-area-context/ios/RNSafeAreaContext.xcodeproj/project.pbxproj', 'node_modules/react-native-screens/ios/RNScreens.xcodeproj/project.pbxproj', 'node_modules/react-native-vector-icons/RNVectorIcons.xcodeproj/project.pbxproj', 'platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj', 'platforms/ios/Pods/Pods.xcodeproj/project.pbxproj', 'platforms/ios/emission.xcodeproj/project.pbxproj' ] Done setting IPHONEOS_DEPLOYMENT_TARGET Executing script found in plugin cordova-custom-config for hook "before_compile": plugins/cordova-custom-config/hooks/applyCustomConfig.js ^[[32mcordova-custom-config: Loaded module dependencies^[[39m ^[[32mcordova-custom-config: Running applyCustomConfig.js^[[39m ^[[32mcordova-custom-config: Finished applying platform config^[[39m before patching, grep -r IPHONEOS_DEPLOYMENT_TARGET platforms/ios | sort | uniq: platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 13.0; platforms/ios/Pods/Pods.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 10.0; platforms/ios/Pods/Pods.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 13.0; platforms/ios/Pods/Pods.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 8.0; platforms/ios/Pods/Pods.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 9.0; platforms/ios/emission.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 13.0; after patching, grep -r IPHONEOS_DEPLOYMENT_TARGET platforms/ios | sort | uniq: platforms/ios/CordovaLib/CordovaLib.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 13.0; platforms/ios/Pods/Pods.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 13.0; platforms/ios/emission.xcodeproj/project.pbxproj: IPHONEOS_DEPLOYMENT_TARGET = 13.0; ``` --- .../ios/ios_change_deployment.js | 41 +++++++++++++++---- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/hooks/before_compile/ios/ios_change_deployment.js b/hooks/before_compile/ios/ios_change_deployment.js index ad381162d..cb848cef4 100644 --- a/hooks/before_compile/ios/ios_change_deployment.js +++ b/hooks/before_compile/ios/ios_change_deployment.js @@ -1,5 +1,6 @@ const fs = require('fs'); const path = require('path'); +const { exec } = require('child_process'); function findFilePathsByFilename(directory, filename) { const files = fs.readdirSync(directory); @@ -21,17 +22,39 @@ function findFilePathsByFilename(directory, filename) { return filePaths; } +function logTarget(directory, logmsg) { + const grepstmt = `grep -r IPHONEOS_DEPLOYMENT_TARGET ${directory} | sort | uniq` + exec(grepstmt, (err, stdout, stderr) => { + if (err) { + console.log(`${logmsg}, ${grepstmt}:\n`, stderr) + return; + } + + // the *entire* stdout and stderr (buffered) + console.log(`${logmsg}, ${grepstmt}:\n`, stdout); + }); +} + +module.exports = function(context) { + if (context.opts.verbose) console.log(context); + + if (context.opts.verbose) logTarget("platforms/ios", "before patching"); -const paths1 = findFilePathsByFilename('.', 'project.pbxproj'); -const paths2 = findFilePathsByFilename('.', 'Pods.xcodeproj'); -const paths = paths1.concat(paths2) + const paths1 = findFilePathsByFilename('.', 'project.pbxproj'); + const paths2 = findFilePathsByFilename('.', 'Pods.xcodeproj'); + const paths = paths1.concat(paths2) -console.log('Apply patch to', paths); + console.log('Apply patch to', paths); -for (let path of paths) { - let content = fs.readFileSync(path, { encoding: 'utf-8' }); - content = content.replace(/IPHONEOS_DEPLOYMENT_TARGET = [0-9]+.0;/g, 'IPHONEOS_DEPLOYMENT_TARGET = 13.0;'); - fs.writeFileSync(path, content); + for (let path of paths) { + let content = fs.readFileSync(path, { encoding: 'utf-8' }); + content = content.replace(/IPHONEOS_DEPLOYMENT_TARGET = [0-9]+.0;/g, 'IPHONEOS_DEPLOYMENT_TARGET = 13.0;'); + fs.writeFileSync(path, content); + } + + console.log('Done setting IPHONEOS_DEPLOYMENT_TARGET'); + + if (context.opts.verbose) logTarget("platforms/ios", "after patching"); } -console.log('Done setting IPHONEOS_DEPLOYMENT_TARGET'); +