Skip to content

Commit

Permalink
Merge pull request #1149 from louisg1337/ios_build_fix
Browse files Browse the repository at this point in the history
iOS build fix for Xcode 15
  • Loading branch information
shankari authored May 5, 2024
2 parents 9f3fc59 + d890502 commit 0a43a4d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 7 deletions.
8 changes: 1 addition & 7 deletions .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: macos-13
runs-on: macos-14

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -33,12 +33,6 @@ jobs:
- name: Print the xcode path
run: xcode-select --print-path

- name: Set xcode to 14.1
run: |
sudo xcode-select --switch /Applications/Xcode_14.1.app
echo "After setting xcode version "`xcode-select --print-path`
- name: Print the xcode setup
run: xcodebuild -version -sdk

Expand Down
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_build/ios/ios_change_deployment.js" type="before_build" />
<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_build/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 0a43a4d

Please sign in to comment.