Skip to content

Commit

Permalink
fix(apple): fix embed-manifest failing to find app.json (#2023)
Browse files Browse the repository at this point in the history
  • Loading branch information
tido64 committed May 7, 2024
1 parent 99b6feb commit 58ac77d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
35 changes: 30 additions & 5 deletions .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
- common/**/*
- example/android/**/*
- scripts/*.js
- test/android-test-app/**/*
- scripts/configure.mjs
- scripts/embed-manifest/kotlin.mjs
- scripts/embed-manifest/main.mjs
- scripts/embed-manifest/validate.mjs
- scripts/init.mjs
- scripts/template.mjs
- test-app.gradle
"platform: iOS":
- changed-files:
Expand All @@ -24,8 +29,13 @@
- example/ios/**/*
- ios/**/*
- scripts/*.js
- scripts/configure.mjs
- scripts/embed-manifest/main.mjs
- scripts/embed-manifest/swift.mjs
- scripts/embed-manifest/validate.mjs
- scripts/init.mjs
- scripts/template.mjs
- scripts/xcodebuild.sh
- test/*.rb
- test_app.rb
"platform: macOS":
- changed-files:
Expand All @@ -47,8 +57,13 @@
- ios/ReactTestApp/UIViewController+ReactTestApp.{h,m}
- macos/**/*
- scripts/*.js
- scripts/configure.mjs
- scripts/embed-manifest/main.mjs
- scripts/embed-manifest/swift.mjs
- scripts/embed-manifest/validate.mjs
- scripts/init.mjs
- scripts/template.mjs
- scripts/xcodebuild.sh
- test/*.rb
"platform: visionOS":
- changed-files:
- any-glob-to-any-file:
Expand All @@ -63,8 +78,13 @@
- ios/*.rb
- ios/ReactTestApp/*.{h,m,mm,swift}
- scripts/*.js
- scripts/configure.mjs
- scripts/embed-manifest/main.mjs
- scripts/embed-manifest/swift.mjs
- scripts/embed-manifest/validate.mjs
- scripts/init.mjs
- scripts/template.mjs
- scripts/xcodebuild.sh
- test/*.rb
- visionos/**/*
"platform: Windows":
- changed-files:
Expand All @@ -76,5 +96,10 @@
- example/windows/**/*
- scripts/*.ps1
- scripts/*.js
- test/windows-test-app/**/*
- scripts/configure.mjs
- scripts/embed-manifest/cpp.mjs
- scripts/embed-manifest/main.mjs
- scripts/embed-manifest/validate.mjs
- scripts/init.mjs
- scripts/template.mjs
- windows/**/*
24 changes: 6 additions & 18 deletions scripts/embed-manifest/swift.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// @ts-check
import * as nodefs from "node:fs";
import * as path from "node:path";
import { findFile, isMain } from "../helpers.js";
import { isMain } from "../helpers.js";
import { main, warn } from "./main.mjs";

const INDENT = " ";
const SRCROOT = process.env["SRCROOT"] || process.cwd();
const PODS_ROOT = process.env["PODS_ROOT"] || SRCROOT;

/**
* @param {unknown} s
Expand Down Expand Up @@ -134,15 +136,6 @@ function components(components, level) {
* @returns {string}
*/
export function generate(json, checksum, fs = nodefs) {
const srcRoot = process.env["SRCROOT"] || process.cwd();
const nodeModulesPath = findFile("node_modules", srcRoot, fs);
if (!nodeModulesPath) {
console.error(
"Failed to find 'node_modules' — make sure you've installed npm dependencies"
);
return "";
}

const code = [
"import Foundation",
"",
Expand All @@ -165,18 +158,13 @@ export function generate(json, checksum, fs = nodefs) {
"",
].join("\n");

const dest = path.join(
nodeModulesPath,
".generated",
path.basename(srcRoot),
"Manifest+Embedded.g.swift"
);
const dest = path.join(SRCROOT, "Manifest+Embedded.g.swift");
fs.promises
.mkdir(path.dirname(dest), { recursive: true, mode: 0o755 })
.mkdir(SRCROOT, { recursive: true, mode: 0o755 })
.then(() => fs.promises.writeFile(dest, code));
return "app.json -> " + dest;
}

if (!process.argv[1] || isMain(import.meta.url)) {
process.exitCode = main(generate);
process.exitCode = main(generate, PODS_ROOT);
}

0 comments on commit 58ac77d

Please sign in to comment.