Skip to content

Commit a58a047

Browse files
authored
Merge pull request #94 from giolaq/fix/issue-93-ios-prebuild-swift-appdelegate
fix(ios): resolve prebuild failure with Swift AppDelegate (#93)
2 parents 5a23ec7 + f4ed4f6 commit a58a047

7 files changed

Lines changed: 107 additions & 111 deletions

File tree

.yarn/install-state.gz

215 KB
Binary file not shown.

apps/expo-multi-tv/app.json

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"expo": {
33
"plugins": [
44
"./plugins/withKotlinJvmTarget",
5-
"@bam.tech/react-native-keyevent-expo-config-plugin",
5+
"./plugins/withKeyEvent",
6+
"./plugins/withTvosDeploymentTarget",
67
[
78
"@react-native-tvos/config-tv",
89
{
@@ -22,14 +23,13 @@
2223
"expo-build-properties",
2324
{
2425
"ios": {
25-
"newArchEnabled": false
26+
"deploymentTarget": "15.1"
2627
},
2728
"android": {
28-
"newArchEnabled": false,
29-
"kotlinVersion": "1.9.24",
30-
"compileSdkVersion": 34,
29+
"kotlinVersion": "2.0.21",
30+
"compileSdkVersion": 36,
3131
"targetSdkVersion": 34,
32-
"minSdkVersion": 23
32+
"minSdkVersion": 24
3333
}
3434
}
3535
],
@@ -57,6 +57,7 @@
5757
},
5858
"ios": {
5959
"bundleIdentifier": "com.anonymous.MultiTVSample"
60-
}
60+
},
61+
"newArchEnabled": false
6162
}
6263
}

apps/expo-multi-tv/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"preset": "jest-expo"
2020
},
2121
"dependencies": {
22-
"@bam.tech/react-native-keyevent-expo-config-plugin": "^1.0.50",
2322
"@expo/metro-runtime": "~4.0.0",
2423
"@expo/vector-icons": "^14.0.0",
2524
"@multi-tv/shared-ui": "workspace:*",
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
const { withMainActivity } = require("expo/config-plugins");
2+
const {
3+
mergeContents,
4+
} = require("@expo/config-plugins/build/utils/generateCode");
5+
6+
const withAndroidMainActivityImport = (config) => {
7+
return withMainActivity(config, (config) => {
8+
const newSrc = [
9+
"import android.view.KeyEvent",
10+
"import com.github.kevinejohn.keyevent.KeyEventModule",
11+
];
12+
const newConfig = mergeContents({
13+
tag: "react-native-keyevent-import",
14+
src: config.modResults.contents,
15+
newSrc: newSrc.join("\n"),
16+
anchor: `import`,
17+
offset: 1,
18+
comment: "//",
19+
});
20+
return {
21+
...config,
22+
modResults: newConfig,
23+
};
24+
});
25+
};
26+
27+
const withAndroidMainActivityBody = (config) => {
28+
return withMainActivity(config, (config) => {
29+
const newSrc = [
30+
"override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {",
31+
" KeyEventModule.getInstance().onKeyDownEvent(keyCode, event)",
32+
" super.onKeyDown(keyCode, event)",
33+
" return true",
34+
"}",
35+
"",
36+
"override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {",
37+
" KeyEventModule.getInstance().onKeyUpEvent(keyCode, event)",
38+
" super.onKeyUp(keyCode, event)",
39+
" return true",
40+
"}",
41+
"",
42+
"override fun onKeyMultiple(keyCode: Int, repeatCount: Int, event: KeyEvent): Boolean {",
43+
" KeyEventModule.getInstance().onKeyMultipleEvent(keyCode, repeatCount, event)",
44+
" return super.onKeyMultiple(keyCode, repeatCount, event)",
45+
"}",
46+
];
47+
const newConfig = mergeContents({
48+
tag: "react-native-keyevent-body",
49+
src: config.modResults.contents,
50+
newSrc: newSrc.join("\n"),
51+
anchor: `class MainActivity`,
52+
offset: 1,
53+
comment: "//",
54+
});
55+
return {
56+
...config,
57+
modResults: newConfig,
58+
};
59+
});
60+
};
61+
62+
function withKeyEvent(config) {
63+
config = withAndroidMainActivityImport(config);
64+
config = withAndroidMainActivityBody(config);
65+
return config;
66+
}
67+
68+
module.exports = withKeyEvent;

apps/expo-multi-tv/plugins/withKotlinJvmTarget.js

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,20 @@ function withKotlinJvmTarget(config) {
66
return withDangerousMod(config, [
77
"android",
88
async (config) => {
9-
const buildGradlePath = path.join(
9+
const rootBuildGradle = path.join(
1010
config.modRequest.platformProjectRoot,
11-
"react-settings-plugin",
12-
"build.gradle.kts"
11+
"build.gradle"
1312
);
1413

15-
if (fs.existsSync(buildGradlePath)) {
16-
let contents = fs.readFileSync(buildGradlePath, "utf-8");
14+
if (fs.existsSync(rootBuildGradle)) {
15+
let contents = fs.readFileSync(rootBuildGradle, "utf-8");
1716

18-
if (!contents.includes("sourceCompatibility")) {
19-
const jvmConfig = `
20-
java {
21-
sourceCompatibility = JavaVersion.VERSION_17
22-
targetCompatibility = JavaVersion.VERSION_17
23-
}
24-
25-
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
26-
kotlinOptions {
27-
jvmTarget = "17"
28-
}
29-
}
30-
`;
17+
if (!contents.includes("ext.kotlinVersion")) {
3118
contents = contents.replace(
32-
/repositories\s*\{\s*mavenCentral\(\)\s*\}/,
33-
(match) => match + "\n" + jvmConfig
19+
"buildscript {",
20+
'buildscript {\n ext.kotlinVersion = findProperty("android.kotlinVersion") ?: "2.0.21"'
3421
);
35-
fs.writeFileSync(buildGradlePath, contents);
22+
fs.writeFileSync(rootBuildGradle, contents);
3623
}
3724
}
3825

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
const { withXcodeProject } = require("expo/config-plugins");
2+
3+
function withTvosDeploymentTarget(config) {
4+
return withXcodeProject(config, (config) => {
5+
const project = config.modResults;
6+
const configurations = project.pbxXCBuildConfigurationSection();
7+
8+
for (const key in configurations) {
9+
const buildSettings = configurations[key].buildSettings;
10+
if (buildSettings && buildSettings.TVOS_DEPLOYMENT_TARGET) {
11+
buildSettings.TVOS_DEPLOYMENT_TARGET = "15.1";
12+
}
13+
}
14+
15+
return config;
16+
});
17+
}
18+
19+
module.exports = withTvosDeploymentTarget;

yarn.lock

Lines changed: 4 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,17 +2094,6 @@ __metadata:
20942094
languageName: node
20952095
linkType: hard
20962096

2097-
"@bam.tech/react-native-keyevent-expo-config-plugin@npm:^1.0.50":
2098-
version: 1.0.52
2099-
resolution: "@bam.tech/react-native-keyevent-expo-config-plugin@npm:1.0.52"
2100-
dependencies:
2101-
"@expo/config-plugins": "npm:~8.0.0"
2102-
peerDependencies:
2103-
expo: ^51.0.9
2104-
checksum: 10c0/860ef6908ae57e65fc9c6c01ce606b39c2e96ea69d59436f5dcb0742af64dbec4f4e7011b8f03e104617f804d81e123d19d9d2ed868d7d29c5b85f589fc3373a
2105-
languageName: node
2106-
linkType: hard
2107-
21082097
"@bcoe/v8-coverage@npm:^0.2.3":
21092098
version: 0.2.3
21102099
resolution: "@bcoe/v8-coverage@npm:0.2.3"
@@ -2549,29 +2538,6 @@ __metadata:
25492538
languageName: node
25502539
linkType: hard
25512540

2552-
"@expo/config-plugins@npm:~8.0.0":
2553-
version: 8.0.11
2554-
resolution: "@expo/config-plugins@npm:8.0.11"
2555-
dependencies:
2556-
"@expo/config-types": "npm:^51.0.3"
2557-
"@expo/json-file": "npm:~8.3.0"
2558-
"@expo/plist": "npm:^0.1.0"
2559-
"@expo/sdk-runtime-versions": "npm:^1.0.0"
2560-
chalk: "npm:^4.1.2"
2561-
debug: "npm:^4.3.1"
2562-
find-up: "npm:~5.0.0"
2563-
getenv: "npm:^1.0.0"
2564-
glob: "npm:7.1.6"
2565-
resolve-from: "npm:^5.0.0"
2566-
semver: "npm:^7.5.4"
2567-
slash: "npm:^3.0.0"
2568-
slugify: "npm:^1.6.6"
2569-
xcode: "npm:^3.0.1"
2570-
xml2js: "npm:0.6.0"
2571-
checksum: 10c0/0dac5afd845c050334afb816fca447df96e27fc004bd99873e2f8ffed0ad8e7fc2e9bbb2877589b5ea6fc73c35144dc7bf174ca46cacfa14b1baf93a094e350d
2572-
languageName: node
2573-
linkType: hard
2574-
25752541
"@expo/config-plugins@npm:~9.0.17":
25762542
version: 9.0.17
25772543
resolution: "@expo/config-plugins@npm:9.0.17"
@@ -2594,13 +2560,6 @@ __metadata:
25942560
languageName: node
25952561
linkType: hard
25962562

2597-
"@expo/config-types@npm:^51.0.3":
2598-
version: 51.0.3
2599-
resolution: "@expo/config-types@npm:51.0.3"
2600-
checksum: 10c0/bd87a729da985b0097ab29367c0473a2bced5ff211d416f342729e1b2631a7c00d62878e05cdee49ece7e3b65d3296957917f24380d57e2faef2cf220194fdec
2601-
languageName: node
2602-
linkType: hard
2603-
26042563
"@expo/config-types@npm:^52.0.5":
26052564
version: 52.0.5
26062565
resolution: "@expo/config-types@npm:52.0.5"
@@ -2784,17 +2743,6 @@ __metadata:
27842743
languageName: node
27852744
linkType: hard
27862745

2787-
"@expo/json-file@npm:~8.3.0":
2788-
version: 8.3.3
2789-
resolution: "@expo/json-file@npm:8.3.3"
2790-
dependencies:
2791-
"@babel/code-frame": "npm:~7.10.4"
2792-
json5: "npm:^2.2.2"
2793-
write-file-atomic: "npm:^2.3.0"
2794-
checksum: 10c0/3b1b593a2fe6cb297713fbe2d1002bbc8d469fc55219343bffcce1b1abe941aace1b239d0afc1a3cf15b7ceed91e8da4ca36cb83b586f3bf9f05856e1ad560d3
2795-
languageName: node
2796-
linkType: hard
2797-
27982746
"@expo/json-file@npm:~9.0.2":
27992747
version: 9.0.2
28002748
resolution: "@expo/json-file@npm:9.0.2"
@@ -2894,17 +2842,6 @@ __metadata:
28942842
languageName: node
28952843
linkType: hard
28962844

2897-
"@expo/plist@npm:^0.1.0":
2898-
version: 0.1.3
2899-
resolution: "@expo/plist@npm:0.1.3"
2900-
dependencies:
2901-
"@xmldom/xmldom": "npm:~0.7.7"
2902-
base64-js: "npm:^1.2.3"
2903-
xmlbuilder: "npm:^14.0.0"
2904-
checksum: 10c0/134315260a7828bc1ce4563e2af67499b498feae46c39c5c2cab9d72082402a42d3b7575f13e269022bcf3c28668948ea960dd4943bd38f52f9c01154317aac5
2905-
languageName: node
2906-
linkType: hard
2907-
29082845
"@expo/plist@npm:^0.2.2":
29092846
version: 0.2.2
29102847
resolution: "@expo/plist@npm:0.2.2"
@@ -3828,7 +3765,6 @@ __metadata:
38283765
resolution: "@multi-tv/expo-multi-tv@workspace:apps/expo-multi-tv"
38293766
dependencies:
38303767
"@babel/core": "npm:^7.20.0"
3831-
"@bam.tech/react-native-keyevent-expo-config-plugin": "npm:^1.0.50"
38323768
"@commitlint/cli": "npm:^19.5.0"
38333769
"@commitlint/config-conventional": "npm:^19.5.0"
38343770
"@expo/metro-runtime": "npm:~4.0.0"
@@ -9742,7 +9678,7 @@ __metadata:
97429678
languageName: node
97439679
linkType: hard
97449680

9745-
"find-up@npm:^5.0.0, find-up@npm:~5.0.0":
9681+
"find-up@npm:^5.0.0":
97469682
version: 5.0.0
97479683
resolution: "find-up@npm:5.0.0"
97489684
dependencies:
@@ -10226,20 +10162,6 @@ __metadata:
1022610162
languageName: node
1022710163
linkType: hard
1022810164

10229-
"glob@npm:7.1.6":
10230-
version: 7.1.6
10231-
resolution: "glob@npm:7.1.6"
10232-
dependencies:
10233-
fs.realpath: "npm:^1.0.0"
10234-
inflight: "npm:^1.0.4"
10235-
inherits: "npm:2"
10236-
minimatch: "npm:^3.0.4"
10237-
once: "npm:^1.3.0"
10238-
path-is-absolute: "npm:^1.0.0"
10239-
checksum: 10c0/2575cce9306ac534388db751f0aa3e78afedb6af8f3b529ac6b2354f66765545145dba8530abf7bff49fb399a047d3f9b6901c38ee4c9503f592960d9af67763
10240-
languageName: node
10241-
linkType: hard
10242-
1024310165
"glob@npm:^10.3.10, glob@npm:^10.4.2":
1024410166
version: 10.5.0
1024510167
resolution: "glob@npm:10.5.0"
@@ -12901,7 +12823,7 @@ __metadata:
1290112823
languageName: node
1290212824
linkType: hard
1290312825

12904-
"json5@npm:^2.2.1, json5@npm:^2.2.2, json5@npm:^2.2.3":
12826+
"json5@npm:^2.2.1, json5@npm:^2.2.3":
1290512827
version: 2.2.3
1290612828
resolution: "json5@npm:2.2.3"
1290712829
bin:
@@ -19639,11 +19561,11 @@ __metadata:
1963919561

1964019562
"typescript@patch:typescript@npm%3A~5.7.0#optional!builtin<compat/typescript>":
1964119563
version: 5.7.3
19642-
resolution: "typescript@patch:typescript@npm%3A5.7.3#optional!builtin<compat/typescript>::version=5.7.3&hash=8c6c40"
19564+
resolution: "typescript@patch:typescript@npm%3A5.7.3#optional!builtin<compat/typescript>::version=5.7.3&hash=5786d5"
1964319565
bin:
1964419566
tsc: bin/tsc
1964519567
tsserver: bin/tsserver
19646-
checksum: 10c0/3b56d6afa03d9f6172d0b9cdb10e6b1efc9abc1608efd7a3d2f38773d5d8cfb9bbc68dfb72f0a7de5e8db04fc847f4e4baeddcd5ad9c9feda072234f0d788896
19568+
checksum: 10c0/6fd7e0ed3bf23a81246878c613423730c40e8bdbfec4c6e4d7bf1b847cbb39076e56ad5f50aa9d7ebd89877999abaee216002d3f2818885e41c907caaa192cc4
1964719569
languageName: node
1964819570
linkType: hard
1964919571

0 commit comments

Comments
 (0)