Skip to content

Commit e5cf288

Browse files
authored
Fix: Remove NDK Build ID (#63)
1 parent 1b08a6e commit e5cf288

File tree

1 file changed

+31
-20
lines changed

1 file changed

+31
-20
lines changed

scripts/removeDKBuildId.js

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
1-
const {
2-
withAppBuildGradle,
3-
} = require("@expo/config-plugins/build/plugins/android-plugins.js");
1+
// withAddLinkOption.js
2+
const { withDangerousMod } = require('@expo/config-plugins');
3+
const fs = require('fs');
4+
const path = require('path');
45

5-
const withNDKBuildId = (config) => {
6-
return withAppBuildGradle(config, (gradleConfig) => {
7-
if (typeof gradleConfig.modResults.contents === "string") {
8-
gradleConfig.modResults.contents =
9-
gradleConfig.modResults.contents.replace(
10-
"defaultConfig {",
11-
`defaultConfig {
12-
externalNativeBuild {
13-
cmake {
14-
path "CMakeLists.txt"
15-
}
16-
}
17-
`,
6+
const withAddLinkOption = (config) => {
7+
return withDangerousMod(config, [
8+
'android',
9+
async (config) => {
10+
const packages = ['react-native-screens', 'expo-modules-core'];
11+
for (const pkg of packages) {
12+
const cmakeFilePath = path.join(
13+
config.modRequest.projectRoot,
14+
'node_modules',
15+
pkg,
16+
'android',
17+
'CMakeLists.txt'
1818
);
19-
}
20-
return gradleConfig;
21-
});
19+
if (fs.existsSync(cmakeFilePath)) {
20+
let contents = fs.readFileSync(cmakeFilePath, 'utf8');
21+
// Insert the linker option after the first line if not already present.
22+
if (!contents.includes('LINKER:--build-id=none')) {
23+
const lines = contents.split('\n');
24+
lines.splice(1, 0, 'add_link_options("LINKER:--build-id=none")');
25+
contents = lines.join('\n');
26+
fs.writeFileSync(cmakeFilePath, contents, 'utf8');
27+
}
28+
}
29+
}
30+
return config;
31+
},
32+
]);
2233
};
2334

24-
module.exports = withNDKBuildId;
35+
module.exports = withAddLinkOption;

0 commit comments

Comments
 (0)