Skip to content

Commit

Permalink
♻️ Move the ios script fix to before_compile
Browse files Browse the repository at this point in the history
It was in `before_build` earlier, but that led to the changes from the script
being overridden before the actual compile started
e-mission/e-mission-docs#1079 (comment)
e-mission#1168 (comment)
e-mission#1168 (comment)
e-mission#1168 (comment)
e-mission#1168 (comment)

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 **
```
  • Loading branch information
shankari authored and idillon-sfl committed Sep 3, 2024
1 parent f2fe97b commit b10e730
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config.cordovabuild.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
<param name="ios-package" onload="true" value="CDVStatusBar" />
</feature>
<platform name="ios">
<preference name="deployment-target" value="13.0"/>
<hook src="hooks/before_compile/ios/ios_change_deployment.js" type="before_compile" />
<hook src="hooks/after_platform_add/ios/ios_copy_locales.js" type="after_platform_add" />
<resource-file src="GoogleService-Info.plist" />
<preference name="WKWebViewOnly" value="true" />
Expand Down
37 changes: 37 additions & 0 deletions hooks/before_compile/ios/ios_change_deployment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
const fs = require('fs');
const path = require('path');

function findFilePathsByFilename(directory, filename) {
const files = fs.readdirSync(directory);
const filePaths = [];

for (const file of files) {
const filePath = path.join(directory, file);
const stats = fs.statSync(filePath);

if (stats.isDirectory()) {
// Recursively search in subdirectories
const subdirectoryFilePaths = findFilePathsByFilename(filePath, filename);
filePaths.push(...subdirectoryFilePaths);
} else if (stats.isFile() && file === filename) {
// If the file matches the filename, add its path to the result
filePaths.push(filePath);
}
}
return filePaths;
}


const paths1 = findFilePathsByFilename('.', 'project.pbxproj');
const paths2 = findFilePathsByFilename('.', 'Pods.xcodeproj');
const paths = paths1.concat(paths2)

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);
}

console.log('Done setting IPHONEOS_DEPLOYMENT_TARGET');

0 comments on commit b10e730

Please sign in to comment.