From aa1423d69f81dd8085a5a5ec93dfc03cc6ae243a Mon Sep 17 00:00:00 2001 From: staszekscp Date: Fri, 15 Nov 2024 17:14:28 +0100 Subject: [PATCH 01/38] Add Mobile-Expensify submodule and build HybridApp on both platforms --- .gitmodules | 3 ++ Mobile-Expensify | 1 + patches/@onfido+react-native-sdk+10.6.0.patch | 2 +- ...ve+gradle-plugin+0.75.2+001+initial.patch} | 0 ...+gradle-plugin+0.75.2+002+hybrid-app.patch | 36 +++++++++++++ ...oll+camera-roll+7.4.0+001+hybrid-app.patch | 15 ------ ...ity+cli-config+14.0.0+001+hybrid-app.patch | 15 ++++++ ...atform-android+14.0.0+001+hybrid-app.patch | 52 ------------------- ...i-platform-ios+14.0.0+001+hybrid-app.patch | 46 ---------------- patches/expo+51.0.31+001+hybrid-app.patch | 12 ----- patches/expo-av+14.0.7+001+hybrid-app.patch | 19 ------- ...es-autolinking+1.11.2+001+hybrid-app.patch | 40 -------------- ...-modules-core+1.12.23+002+hybrid-app.patch | 21 -------- .../react-native-plaid-link-sdk+11.11.0.patch | 2 +- ...ive-reanimated+3.15.3+001+hybrid-app.patch | 17 ------ ...4.0.0-beta.13+001+rn75-compatibility.patch | 4 +- scripts/applyPatches.sh | 1 + scripts/postInstall.sh | 5 ++ 18 files changed, 65 insertions(+), 226 deletions(-) create mode 100644 .gitmodules create mode 160000 Mobile-Expensify rename patches/{@react-native+gradle-plugin+0.75.2.patch => @react-native+gradle-plugin+0.75.2+001+initial.patch} (100%) create mode 100644 patches/@react-native+gradle-plugin+0.75.2+002+hybrid-app.patch delete mode 100644 patches/@react-native-camera-roll+camera-roll+7.4.0+001+hybrid-app.patch create mode 100644 patches/@react-native-community+cli-config+14.0.0+001+hybrid-app.patch delete mode 100644 patches/@react-native-community+cli-platform-android+14.0.0+001+hybrid-app.patch delete mode 100644 patches/@react-native-community+cli-platform-ios+14.0.0+001+hybrid-app.patch delete mode 100644 patches/expo+51.0.31+001+hybrid-app.patch delete mode 100644 patches/expo-av+14.0.7+001+hybrid-app.patch delete mode 100644 patches/expo-modules-autolinking+1.11.2+001+hybrid-app.patch delete mode 100644 patches/expo-modules-core+1.12.23+002+hybrid-app.patch delete mode 100644 patches/react-native-reanimated+3.15.3+001+hybrid-app.patch diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000000..7b3a3d9f9432 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "Mobile-Expensify"] + path = Mobile-Expensify + url = https://github.com/Expensify/Mobile-Expensify.git diff --git a/Mobile-Expensify b/Mobile-Expensify new file mode 160000 index 000000000000..aa88107c87b8 --- /dev/null +++ b/Mobile-Expensify @@ -0,0 +1 @@ +Subproject commit aa88107c87b88bf64f3841a09d40a76fdcf24ab5 diff --git a/patches/@onfido+react-native-sdk+10.6.0.patch b/patches/@onfido+react-native-sdk+10.6.0.patch index 201e9ab92c22..87f0aad1618d 100644 --- a/patches/@onfido+react-native-sdk+10.6.0.patch +++ b/patches/@onfido+react-native-sdk+10.6.0.patch @@ -1252,7 +1252,7 @@ index a9de0d0..da83d9f 100644 - s.dependency "Onfido", "~> 29.6.0" + s.dependency "Onfido", "~> 29.7.0" + -+ if ENV['USE_FRAMEWORKS'] == '1' ++ if ENV['USE_FRAMEWORKS'] != nil + s.pod_target_xcconfig = { + "OTHER_CFLAGS" => "$(inherited) -DUSE_FRAMEWORKS", + "OTHER_CPLUSPLUSFLAGS" => "$(inherited) -DUSE_FRAMEWORKS", diff --git a/patches/@react-native+gradle-plugin+0.75.2.patch b/patches/@react-native+gradle-plugin+0.75.2+001+initial.patch similarity index 100% rename from patches/@react-native+gradle-plugin+0.75.2.patch rename to patches/@react-native+gradle-plugin+0.75.2+001+initial.patch diff --git a/patches/@react-native+gradle-plugin+0.75.2+002+hybrid-app.patch b/patches/@react-native+gradle-plugin+0.75.2+002+hybrid-app.patch new file mode 100644 index 000000000000..f25e1d28a03f --- /dev/null +++ b/patches/@react-native+gradle-plugin+0.75.2+002+hybrid-app.patch @@ -0,0 +1,36 @@ +diff --git a/node_modules/@react-native/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt b/node_modules/@react-native/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt +index 8f2f447..cf35d99 100644 +--- a/node_modules/@react-native/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt ++++ b/node_modules/@react-native/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt +@@ -31,6 +31,17 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings + it.toString() + } + ++ private var defaultWorkingDirectory: File = settings.layout.rootDirectory.dir("../").asFile ++ ++ private var defaultLockFiles: FileCollection = ++ settings.layout.rootDirectory ++ .dir("../") ++ .files("yarn.lock", "package-lock.json", "package.json", "react-native.config.js") ++ ++ public fun autolinkLibrariesFromCommandForPath(path: String) { ++ autolinkLibrariesFromCommand(defaultConfigCommand, settings.layout.rootDirectory.dir(path).asFile, defaultLockFiles) ++ } ++ + /** + * Utility function to autolink libraries using an external command as source of truth. + * +@@ -46,11 +57,8 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings + @JvmOverloads + public fun autolinkLibrariesFromCommand( + command: List = defaultConfigCommand, +- workingDirectory: File? = settings.layout.rootDirectory.dir("../").asFile, +- lockFiles: FileCollection = +- settings.layout.rootDirectory +- .dir("../") +- .files("yarn.lock", "package-lock.json", "package.json", "react-native.config.js") ++ workingDirectory: File? = defaultWorkingDirectory, ++ lockFiles: FileCollection = defaultLockFiles + ) { + outputFile.parentFile.mkdirs() + val lockFilesChanged = checkAndUpdateLockfiles(lockFiles, outputFolder) diff --git a/patches/@react-native-camera-roll+camera-roll+7.4.0+001+hybrid-app.patch b/patches/@react-native-camera-roll+camera-roll+7.4.0+001+hybrid-app.patch deleted file mode 100644 index 9d848520a943..000000000000 --- a/patches/@react-native-camera-roll+camera-roll+7.4.0+001+hybrid-app.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle b/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle -index 6891fa3..8397f95 100644 ---- a/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle -+++ b/node_modules/@react-native-camera-roll/camera-roll/android/build.gradle -@@ -81,7 +81,9 @@ def findNodeModulePath(baseDir, packageName) { - } - - def resolveReactNativeDirectory() { -- def reactNative = file("${findNodeModulePath(rootProject.projectDir, "react-native")}") -+ def projectDir = this.hasProperty('reactNativeProject') ? this.reactNativeProject : rootProject.projectDir -+ def modulePath = file(projectDir); -+ def reactNative = file("${findNodeModulePath(modulePath, 'react-native')}") - if (reactNative.exists()) { - return reactNative - } diff --git a/patches/@react-native-community+cli-config+14.0.0+001+hybrid-app.patch b/patches/@react-native-community+cli-config+14.0.0+001+hybrid-app.patch new file mode 100644 index 000000000000..0b82526c88ac --- /dev/null +++ b/patches/@react-native-community+cli-config+14.0.0+001+hybrid-app.patch @@ -0,0 +1,15 @@ +diff --git a/node_modules/@react-native-community/cli-config/build/findDependencies.js b/node_modules/@react-native-community/cli-config/build/findDependencies.js +index d59a1ba..3c0983c 100644 +--- a/node_modules/@react-native-community/cli-config/build/findDependencies.js ++++ b/node_modules/@react-native-community/cli-config/build/findDependencies.js +@@ -24,8 +24,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de + */ + function findDependencies(root) { + let pjson; ++ let pkg = process.env.IS_HYBRID_APP ? '../package.json' : 'package.json' + try { +- pjson = JSON.parse(_fs().default.readFileSync(_path().default.join(root, 'package.json'), 'utf8')); ++ pjson = JSON.parse(_fs().default.readFileSync(_path().default.join(root, pkg), 'utf8')); + } catch (e) { + return []; + } diff --git a/patches/@react-native-community+cli-platform-android+14.0.0+001+hybrid-app.patch b/patches/@react-native-community+cli-platform-android+14.0.0+001+hybrid-app.patch deleted file mode 100644 index 7f64391efe4c..000000000000 --- a/patches/@react-native-community+cli-platform-android+14.0.0+001+hybrid-app.patch +++ /dev/null @@ -1,52 +0,0 @@ -diff --git a/node_modules/@react-native-community/cli-platform-android/native_modules.gradle b/node_modules/@react-native-community/cli-platform-android/native_modules.gradle -index 43296c6..0d91033 100644 ---- a/node_modules/@react-native-community/cli-platform-android/native_modules.gradle -+++ b/node_modules/@react-native-community/cli-platform-android/native_modules.gradle -@@ -149,16 +149,18 @@ class ReactNativeModules { - private ProviderFactory providers - private String packageName - private File root -+ private File rnRoot - private ArrayList> reactNativeModules - private HashMap reactNativeModulesBuildVariants - private String reactNativeVersion - - private static String LOG_PREFIX = ":ReactNative:" - -- ReactNativeModules(Logger logger, ProviderFactory providers, File root) { -+ ReactNativeModules(Logger logger, ProviderFactory providers, File root, File rnRoot) { - this.logger = logger - this.providers = providers - this.root = root -+ this.rnRoot = rnRoot - - def (nativeModules, reactNativeModulesBuildVariants, androidProject, reactNativeVersion) = this.getReactNativeConfig() - this.reactNativeModules = nativeModules -@@ -440,10 +442,10 @@ class ReactNativeModules { - */ - def cliResolveScript = "try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}" - String[] nodeCommand = ["node", "-e", cliResolveScript] -- def cliPath = this.getCommandOutput(nodeCommand, this.root) -+ def cliPath = this.getCommandOutput(nodeCommand, this.rnRoot) - - String[] reactNativeConfigCommand = ["node", cliPath, "config", "--platform", "android"] -- def reactNativeConfigOutput = this.getCommandOutput(reactNativeConfigCommand, this.root) -+ def reactNativeConfigOutput = this.getCommandOutput(reactNativeConfigCommand, this.rnRoot) - - def json - try { -@@ -513,7 +515,13 @@ class ReactNativeModules { - */ - def projectRoot = rootProject.projectDir - --def autoModules = new ReactNativeModules(logger, providers, projectRoot) -+def autoModules -+ -+if(this.hasProperty('reactNativeProject')){ -+ autoModules = new ReactNativeModules(logger, providers, projectRoot, new File(projectRoot, reactNativeProject)) -+} else { -+ autoModules = new ReactNativeModules(logger, providers, projectRoot, projectRoot) -+} - - def reactNativeVersionRequireNewArchEnabled(autoModules) { - def rnVersion = autoModules.reactNativeVersion diff --git a/patches/@react-native-community+cli-platform-ios+14.0.0+001+hybrid-app.patch b/patches/@react-native-community+cli-platform-ios+14.0.0+001+hybrid-app.patch deleted file mode 100644 index e54ab17c43dd..000000000000 --- a/patches/@react-native-community+cli-platform-ios+14.0.0+001+hybrid-app.patch +++ /dev/null @@ -1,46 +0,0 @@ -diff --git a/node_modules/@react-native-community/cli-platform-ios/native_modules.rb b/node_modules/@react-native-community/cli-platform-ios/native_modules.rb -index 82f537c..df441e2 100644 ---- a/node_modules/@react-native-community/cli-platform-ios/native_modules.rb -+++ b/node_modules/@react-native-community/cli-platform-ios/native_modules.rb -@@ -12,7 +12,7 @@ - require 'pathname' - require 'cocoapods' - --def use_native_modules!(config = nil) -+def updateConfig(config = nil) - if (config.is_a? String) - Pod::UI.warn("Passing custom root to use_native_modules! is deprecated.", - [ -@@ -24,7 +24,6 @@ def use_native_modules!(config = nil) - # Resolving the path the RN CLI. The `@react-native-community/cli` module may not be there for certain package managers, so we fall back to resolving it through `react-native` package, that's always present in RN projects - cli_resolve_script = "try {console.log(require('@react-native-community/cli').bin);} catch (e) {console.log(require('react-native/cli').bin);}" - cli_bin = Pod::Executable.execute_command("node", ["-e", cli_resolve_script], true).strip -- - if (!config) - json = [] - -@@ -36,9 +35,24 @@ def use_native_modules!(config = nil) - - config = JSON.parse(json.join("\n")) - end -+end -+ -+def use_native_modules!(config = nil) -+ if (ENV['REACT_NATIVE_DIR']) -+ Dir.chdir(ENV['REACT_NATIVE_DIR']) do -+ config = updateConfig(config) -+ end -+ else -+ config = updateConfig(config) -+ end - - project_root = Pathname.new(config["project"]["ios"]["sourceDir"]) - -+ if(ENV["PROJECT_ROOT_DIR"]) -+ project_root = File.join(Dir.pwd, ENV["PROJECT_ROOT_DIR"]) -+ -+ end -+ - packages = config["dependencies"] - found_pods = [] - diff --git a/patches/expo+51.0.31+001+hybrid-app.patch b/patches/expo+51.0.31+001+hybrid-app.patch deleted file mode 100644 index 44048857fc1b..000000000000 --- a/patches/expo+51.0.31+001+hybrid-app.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/node_modules/expo/scripts/autolinking.gradle b/node_modules/expo/scripts/autolinking.gradle -index 929b7f0..c948ebb 100644 ---- a/node_modules/expo/scripts/autolinking.gradle -+++ b/node_modules/expo/scripts/autolinking.gradle -@@ -1,6 +1,6 @@ - // Resolve `expo` > `expo-modules-autolinking` dependency chain - def autolinkingPath = ["node", "--print", "require.resolve('expo-modules-autolinking/package.json', { paths: [require.resolve('expo/package.json')] })"] --apply from: new File( -+apply from: hasProperty("reactNativeProject") ? file('../../expo-modules-autolinking/scripts/android/autolinking_implementation.gradle') : new File( - providers.exec { - workingDir(rootDir) - commandLine(autolinkingPath) diff --git a/patches/expo-av+14.0.7+001+hybrid-app.patch b/patches/expo-av+14.0.7+001+hybrid-app.patch deleted file mode 100644 index 4cf0dee990c5..000000000000 --- a/patches/expo-av+14.0.7+001+hybrid-app.patch +++ /dev/null @@ -1,19 +0,0 @@ -diff --git a/node_modules/expo-av/android/build.gradle b/node_modules/expo-av/android/build.gradle -index 11e7574..6dae6a0 100644 ---- a/node_modules/expo-av/android/build.gradle -+++ b/node_modules/expo-av/android/build.gradle -@@ -3,12 +3,13 @@ apply plugin: 'com.android.library' - group = 'host.exp.exponent' - version = '14.0.7' - -+def REACT_NATIVE_PATH = this.hasProperty('reactNativeProject') ? this.reactNativeProject + '/node_modules/react-native/package.json' : 'react-native/package.json' - def REACT_NATIVE_BUILD_FROM_SOURCE = findProject(":ReactAndroid") != null - def REACT_NATIVE_DIR = REACT_NATIVE_BUILD_FROM_SOURCE - ? findProject(":ReactAndroid").getProjectDir().parent - : file(providers.exec { - workingDir(rootDir) -- commandLine("node", "--print", "require.resolve('react-native/package.json')") -+ commandLine("node", "--print", "require.resolve('${REACT_NATIVE_PATH}')") - }.standardOutput.asText.get().trim()).parent - - def reactNativeArchitectures() { diff --git a/patches/expo-modules-autolinking+1.11.2+001+hybrid-app.patch b/patches/expo-modules-autolinking+1.11.2+001+hybrid-app.patch deleted file mode 100644 index a345f84b8f20..000000000000 --- a/patches/expo-modules-autolinking+1.11.2+001+hybrid-app.patch +++ /dev/null @@ -1,40 +0,0 @@ -diff --git a/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle b/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle -index f085818..fcb9594 100644 ---- a/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle -+++ b/node_modules/expo-modules-autolinking/scripts/android/autolinking_implementation.gradle -@@ -152,12 +152,13 @@ class ExpoAutolinkingManager { - } - - static private String[] convertOptionsToCommandArgs(String command, Map options) { -+ def expoPath = options.searchPaths ? "../react-native/node_modules/expo" : "expo" - String[] args = [ - 'node', - '--no-warnings', - '--eval', - // Resolve the `expo` > `expo-modules-autolinking` chain from the project root -- 'require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo\')] }))(process.argv.slice(1))', -+ "require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'${expoPath}\')] }))(process.argv.slice(1))", - '--', - command, - '--platform', -diff --git a/node_modules/expo-modules-autolinking/scripts/ios/project_integrator.rb b/node_modules/expo-modules-autolinking/scripts/ios/project_integrator.rb -index 5d46f1e..fec4f34 100644 ---- a/node_modules/expo-modules-autolinking/scripts/ios/project_integrator.rb -+++ b/node_modules/expo-modules-autolinking/scripts/ios/project_integrator.rb -@@ -215,6 +215,7 @@ module Expo - args = autolinking_manager.base_command_args.map { |arg| "\"#{arg}\"" } - platform = autolinking_manager.platform_name.downcase - package_names = autolinking_manager.packages_to_generate.map { |package| "\"#{package.name}\"" } -+ expo_path = ENV['REACT_NATIVE_DIR'] ? "#{ENV['REACT_NATIVE_DIR']}/node_modules/expo" : "expo" - - <<~SUPPORT_SCRIPT - #!/usr/bin/env bash -@@ -262,7 +263,7 @@ module Expo - - with_node \\ - --no-warnings \\ -- --eval "require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'expo/package.json\')] }))(process.argv.slice(1))" \\ -+ --eval "require(require.resolve(\'expo-modules-autolinking\', { paths: [require.resolve(\'#{expo_path}/package.json\')] }))(process.argv.slice(1))" \\ - generate-modules-provider #{args.join(' ')} \\ - --target "#{modules_provider_path}" \\ - --platform "apple" \\ diff --git a/patches/expo-modules-core+1.12.23+002+hybrid-app.patch b/patches/expo-modules-core+1.12.23+002+hybrid-app.patch deleted file mode 100644 index b32830615aaa..000000000000 --- a/patches/expo-modules-core+1.12.23+002+hybrid-app.patch +++ /dev/null @@ -1,21 +0,0 @@ -diff --git a/node_modules/expo-modules-core/android/build.gradle b/node_modules/expo-modules-core/android/build.gradle -index f22a3c3..4884cea 100644 ---- a/node_modules/expo-modules-core/android/build.gradle -+++ b/node_modules/expo-modules-core/android/build.gradle -@@ -20,12 +20,13 @@ def isExpoModulesCoreTests = { - }.call() - - def REACT_NATIVE_BUILD_FROM_SOURCE = findProject(":packages:react-native:ReactAndroid") != null --def REACT_NATIVE_DIR = REACT_NATIVE_BUILD_FROM_SOURCE -- ? findProject(":packages:react-native:ReactAndroid").getProjectDir().parent -- : file(providers.exec { -+def FALLBACK_REACT_NATIVE_DIR = hasProperty("reactNativeProject") ? file('../../react-native') : file(providers.exec { - workingDir(rootDir) - commandLine("node", "--print", "require.resolve('react-native/package.json')") - }.standardOutput.asText.get().trim()).parent -+def REACT_NATIVE_DIR = REACT_NATIVE_BUILD_FROM_SOURCE -+ ? findProject(":packages:react-native:ReactAndroid").getProjectDir().parent -+ : FALLBACK_REACT_NATIVE_DIR - - def reactProperties = new Properties() - file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) } diff --git a/patches/react-native-plaid-link-sdk+11.11.0.patch b/patches/react-native-plaid-link-sdk+11.11.0.patch index 28e492f6999f..39ae7b3cd1e7 100644 --- a/patches/react-native-plaid-link-sdk+11.11.0.patch +++ b/patches/react-native-plaid-link-sdk+11.11.0.patch @@ -23,7 +23,7 @@ index 7c60081..4a13a3c 100644 # we don't want this to be seen by Swift s.private_header_files = 'ios/PLKFabricHelpers.h' -+ if ENV['USE_FRAMEWORKS'] == '1' ++ if ENV['USE_FRAMEWORKS'] != nil + s.pod_target_xcconfig = { + "OTHER_CFLAGS" => "$(inherited) -DUSE_FRAMEWORKS", + "OTHER_CPLUSPLUSFLAGS" => "$(inherited) -DUSE_FRAMEWORKS", diff --git a/patches/react-native-reanimated+3.15.3+001+hybrid-app.patch b/patches/react-native-reanimated+3.15.3+001+hybrid-app.patch deleted file mode 100644 index 3b40360d5860..000000000000 --- a/patches/react-native-reanimated+3.15.3+001+hybrid-app.patch +++ /dev/null @@ -1,17 +0,0 @@ -diff --git a/node_modules/react-native-reanimated/scripts/reanimated_utils.rb b/node_modules/react-native-reanimated/scripts/reanimated_utils.rb -index af0935f..ccd2a9e 100644 ---- a/node_modules/react-native-reanimated/scripts/reanimated_utils.rb -+++ b/node_modules/react-native-reanimated/scripts/reanimated_utils.rb -@@ -17,7 +17,11 @@ def find_config() - :react_native_common_dir => nil, - } - -- react_native_node_modules_dir = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..') -+ root_project = Pod::Config.instance.installation_root.to_s -+ if(ENV['PROJECT_ROOT_DIR']) -+ root_project = ENV['PROJECT_ROOT_DIR'] -+ end -+ react_native_node_modules_dir = File.join(File.dirname(`cd "#{root_project}" && node --print "require.resolve('react-native/package.json')"`), '..') - react_native_json = try_to_parse_react_native_package_json(react_native_node_modules_dir) - - if react_native_json == nil diff --git a/patches/react-native-vision-camera+4.0.0-beta.13+001+rn75-compatibility.patch b/patches/react-native-vision-camera+4.0.0-beta.13+001+rn75-compatibility.patch index 7c585ddf9f27..2d0b20505cac 100644 --- a/patches/react-native-vision-camera+4.0.0-beta.13+001+rn75-compatibility.patch +++ b/patches/react-native-vision-camera+4.0.0-beta.13+001+rn75-compatibility.patch @@ -7,7 +7,7 @@ index 3a0e313..83ab343 100644 package = JSON.parse(File.read(File.join(__dir__, "package.json"))) -nodeModules = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('react-native/package.json')"`), '..') -+pkgJsonPath = ENV['REACT_NATIVE_DIR'] ? '../react-native/package.json' : 'react-native/package.json' ++pkgJsonPath = 'react-native/package.json' +nodeModules = File.join(File.dirname(`cd "#{Pod::Config.instance.installation_root.to_s}" && node --print "require.resolve('#{pkgJsonPath}')"`), '..') + +frameworks_flags = { @@ -67,7 +67,7 @@ index 3a0e313..83ab343 100644 - s.dependency "React" - s.dependency "React-Core" - s.dependency "React-callinvoker" -+ if ENV['USE_FRAMEWORKS'] == '1' ++ if ENV['USE_FRAMEWORKS'] != nil + s.pod_target_xcconfig = default_config.merge(frameworks_flags) + else + s.pod_target_xcconfig = default_config diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh index 4ce023755258..9e6b4ceb2c4a 100755 --- a/scripts/applyPatches.sh +++ b/scripts/applyPatches.sh @@ -12,6 +12,7 @@ function patchPackage { OS="$(uname)" if [[ "$OS" == "Darwin" || "$OS" == "Linux" ]]; then npx patch-package --error-on-fail --color=always + npx patch-package --patch-dir 'Mobile-Expensify/patches' --error-on-fail --color=always else error "Unsupported OS: $OS" exit 1 diff --git a/scripts/postInstall.sh b/scripts/postInstall.sh index 782c8ef5822c..607b88edd129 100755 --- a/scripts/postInstall.sh +++ b/scripts/postInstall.sh @@ -7,6 +7,11 @@ set -e ROOT_DIR=$(dirname "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)") cd "$ROOT_DIR" || exit 1 +cd Mobile-Expensify || exit 1 +npm i + +cd "$ROOT_DIR" || exit 1 + # Apply packages using patch-package scripts/applyPatches.sh From 8d83853b2157d112076284b01a86fb5da46ea35b Mon Sep 17 00:00:00 2001 From: staszekscp Date: Mon, 18 Nov 2024 12:56:23 +0100 Subject: [PATCH 02/38] Add bash scripts for HybridApp --- package.json | 14 +++++--- react-native.config.js | 4 +-- scripts/clean.sh | 19 +++++++++++ scripts/is-hybrid-app.sh | 22 ++++++++++++ scripts/pod-install.sh | 21 ++++++++++++ scripts/run-build.sh | 74 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 148 insertions(+), 6 deletions(-) create mode 100755 scripts/clean.sh create mode 100755 scripts/is-hybrid-app.sh create mode 100755 scripts/run-build.sh diff --git a/package.json b/package.json index 6d10be51df3c..78c5e7a6dbbe 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,17 @@ "startAndroidEmulator": "./scripts/start-android.sh", "postinstall": "./scripts/postInstall.sh", "clean": "npx react-native clean-project-auto", - "android": "./scripts/set-pusher-suffix.sh && npx react-native run-android --mode=developmentDebug --appId=com.expensify.chat.dev --active-arch-only", - "ios": "./scripts/set-pusher-suffix.sh && npx react-native run-ios --list-devices --mode=\"DebugDevelopment\" --scheme=\"New Expensify Dev\"", + "clean-standalone": "./scripts/clean.sh", + "android": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --android", + "android-standalone": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --android --new-dot", + "ios": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --ios", + "ios-standalone": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --ios --new-dot", "pod-install": "./scripts/pod-install.sh", - "ipad": "concurrently \"npx react-native run-ios --simulator=\\\"iPad Pro (12.9-inch) (6th generation)\\\" --mode=\\\"DebugDevelopment\\\" --scheme=\\\"New Expensify Dev\\\"\"", - "ipad-sm": "concurrently \"npx react-native run-ios --simulator=\\\"iPad Pro (11-inch) (4th generation)\\\" --mode=\\\"DebugDevelopment\\\" --scheme=\\\"New Expensify Dev\\\"\"", + "pod-install-standalone": "./scripts/pod-install.sh --new-dot", + "ipad": "concurrently \"./scripts/run-build.sh --ipad\"", + "ipad-standalone": "concurrently \"./scripts/run-build.sh --ipad --new-dot\"", + "ipad-sm": "concurrently \"./scripts/run-build.sh --ipad-sm\"", + "ipad-sm-standalone": "concurrently \"./scripts/run-build.sh --ipad-sm --new-dot\"", "start": "npx react-native start", "web": "./scripts/set-pusher-suffix.sh && concurrently npm:web-proxy npm:web-server", "web-proxy": "ts-node web/proxy.ts", diff --git a/react-native.config.js b/react-native.config.js index 6d6dd3f5805f..d673c19a5cf1 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -1,7 +1,7 @@ module.exports = { project: { - ios: {sourceDir: 'ios'}, - android: {}, + ios: {sourceDir: process.env.PROJECT_ROOT + 'ios'}, + android: {sourceDir: process.env.PROJECT_ROOT + 'android'}, }, assets: ['./assets/fonts/native'], }; diff --git a/scripts/clean.sh b/scripts/clean.sh new file mode 100755 index 000000000000..99cce1e56ad0 --- /dev/null +++ b/scripts/clean.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e + +BLUE='\033[1;34m' +NC='\033[0m' + +# See if we're in the HybridApp repo +IS_HYBRID_APP_REPO=$(scripts/is-hybrid-app.sh) + +if [[ "$IS_HYBRID_APP_REPO" == "true" && "$1" != "--new-dot" ]]; then + echo -e "${BLUE}Cleaning HybridApp project...${NC}" + # Navigate to Mobile-Expensify repository, and clean + cd Mobile-Expensify + npm run clean +else + # Clean NewDot + echo -e "${BLUE}Cleaning standalone NewDot project...${NC}" + npx react-native clean-project-auto +fi diff --git a/scripts/is-hybrid-app.sh b/scripts/is-hybrid-app.sh new file mode 100755 index 000000000000..e8264ef659e8 --- /dev/null +++ b/scripts/is-hybrid-app.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +cd Mobile-Expensify || echo false + +# Check if 'package.json' exists +if [[ -f package.json ]]; then + # Read the 'name' field from 'package.json' + + package_name=$(jq -r '.name' package.json 2>/dev/null) + # Check if the 'name' field is 'mobile-expensify' + if [[ "$package_name" == "mobile-expensify" ]]; then + echo true + exit 0 + else + echo "Wrong package name in Mobile-Expensify" + exit 1 + fi +else + echo "package.json not found in Mobile-Expensify" + echo false +fi \ No newline at end of file diff --git a/scripts/pod-install.sh b/scripts/pod-install.sh index cb2976d64587..8b2e2b66c829 100755 --- a/scripts/pod-install.sh +++ b/scripts/pod-install.sh @@ -8,6 +8,9 @@ # Exit immediately if any command exits with a non-zero status set -e +BLUE='\033[1;34m' +NC='\033[0m' + # Go to project root START_DIR="$(pwd)" ROOT_DIR="$(dirname "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)")" @@ -40,6 +43,24 @@ if ! yq --version > /dev/null 2>&1; then cleanupAndExit 1 fi +# See if we're in the HybridApp repo +IS_HYBRID_APP_REPO=$(scripts/is-hybrid-app.sh) +NEW_DOT_FLAG="false" + +if [ "$1" == "--new-dot" ]; then + NEW_DOT_FLAG="true" +fi + +if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then + echo -e "${BLUE}Executing npm run pod-install for HybridApp...${NC}" + cd Mobile-Expensify/ios + # Navigate to the OldDot repository, and run pod install + bundle exec pod install + exit 0 +fi + +echo -e "${BLUE}Executing npm run pod-install for standalone NewDot...${NC}" + CACHED_PODSPEC_DIR='ios/Pods/Local Podspecs' if [ -d "$CACHED_PODSPEC_DIR" ]; then info "Verifying pods from Podfile.lock match local podspecs..." diff --git a/scripts/run-build.sh b/scripts/run-build.sh new file mode 100755 index 000000000000..6ea4a0b38524 --- /dev/null +++ b/scripts/run-build.sh @@ -0,0 +1,74 @@ +#!/bin/bash +set -e + +export PROJECT_ROOT + +BUILD="$1" +NEW_DOT_FLAG="false" +IOS_MODE="DebugDevelopment" +ANDROID_MODE="DevelopmentDebug" +SCHEME="New Expensify Dev" +APP_ID="com.expensify.chat.dev" + +GREEN='\033[1;32m' +RED='\033[1;31m' +NC='\033[0m' + +# Function to print error message and exit +function print_error_and_exit { + echo -e "${RED}Error: Invalid invocation. Please use one of: [ios, ipad, ipad-sm, android].${NC}" + exit 1 +} + +# Assign the arguments to variables +if [ "$#" -eq 1 ]; then + BUILD="$1" +elif [ "$#" -eq 2 ]; then + if [ "$1" == "--new-dot" ]; then + BUILD="$2" + NEW_DOT_FLAG="true" + elif [ "$2" == "--new-dot" ]; then + BUILD="$1" + NEW_DOT_FLAG="true" + else + print_error_and_exit + fi +else + print_error_and_exit +fi + +# See if we're in the HybridApp repo +IS_HYBRID_APP_REPO=$(scripts/is-hybrid-app.sh) + + if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then + # Set HybridApp-specific arguments + IOS_MODE="Debug" + ANDROID_MODE="Debug" + SCHEME="Expensify" + APP_ID="org.me.mobiexpensifyg" + + echo -e "\n${GREEN}Starting a HybridApp build!${NC}" + PROJECT_ROOT="Mobile-Expensify/" +else + echo -e "\n${GREEN}Starting a standalone NewDot build!${NC}" + PROJECT_ROOT="./" +fi + +# Check if the argument is one of the desired values +case "$BUILD" in + --ios) + npx react-native run-ios --list-devices --mode $IOS_MODE --scheme "$SCHEME" + ;; + --ipad) + npx react-native run-ios --simulator "iPad Pro (12.9-inch) (6th generation)" --mode $IOS_MODE --scheme "$SCHEME" + ;; + --ipad-sm) + npx react-native run-ios --simulator "iPad Pro (11-inch) (4th generation)" --mode $IOS_MODE --scheme "$SCHEME" + ;; + --android) + npx react-native run-android --list-devices --mode $ANDROID_MODE --appId $APP_ID --active-arch-only + ;; + *) + print_error_and_exit + ;; +esac \ No newline at end of file From 00624428889a4353b500e48594d54bd80a9bdf7a Mon Sep 17 00:00:00 2001 From: staszekscp Date: Mon, 18 Nov 2024 13:43:47 +0100 Subject: [PATCH 03/38] Remove HybridApp-specific patches from Expensify/App --- ...+gradle-plugin+0.75.2+002+hybrid-app.patch | 36 ------------------- ...ity+cli-config+14.0.0+001+hybrid-app.patch | 15 -------- 2 files changed, 51 deletions(-) delete mode 100644 patches/@react-native+gradle-plugin+0.75.2+002+hybrid-app.patch delete mode 100644 patches/@react-native-community+cli-config+14.0.0+001+hybrid-app.patch diff --git a/patches/@react-native+gradle-plugin+0.75.2+002+hybrid-app.patch b/patches/@react-native+gradle-plugin+0.75.2+002+hybrid-app.patch deleted file mode 100644 index f25e1d28a03f..000000000000 --- a/patches/@react-native+gradle-plugin+0.75.2+002+hybrid-app.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff --git a/node_modules/@react-native/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt b/node_modules/@react-native/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt -index 8f2f447..cf35d99 100644 ---- a/node_modules/@react-native/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt -+++ b/node_modules/@react-native/gradle-plugin/settings-plugin/src/main/kotlin/com/facebook/react/ReactSettingsExtension.kt -@@ -31,6 +31,17 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings - it.toString() - } - -+ private var defaultWorkingDirectory: File = settings.layout.rootDirectory.dir("../").asFile -+ -+ private var defaultLockFiles: FileCollection = -+ settings.layout.rootDirectory -+ .dir("../") -+ .files("yarn.lock", "package-lock.json", "package.json", "react-native.config.js") -+ -+ public fun autolinkLibrariesFromCommandForPath(path: String) { -+ autolinkLibrariesFromCommand(defaultConfigCommand, settings.layout.rootDirectory.dir(path).asFile, defaultLockFiles) -+ } -+ - /** - * Utility function to autolink libraries using an external command as source of truth. - * -@@ -46,11 +57,8 @@ abstract class ReactSettingsExtension @Inject constructor(val settings: Settings - @JvmOverloads - public fun autolinkLibrariesFromCommand( - command: List = defaultConfigCommand, -- workingDirectory: File? = settings.layout.rootDirectory.dir("../").asFile, -- lockFiles: FileCollection = -- settings.layout.rootDirectory -- .dir("../") -- .files("yarn.lock", "package-lock.json", "package.json", "react-native.config.js") -+ workingDirectory: File? = defaultWorkingDirectory, -+ lockFiles: FileCollection = defaultLockFiles - ) { - outputFile.parentFile.mkdirs() - val lockFilesChanged = checkAndUpdateLockfiles(lockFiles, outputFolder) diff --git a/patches/@react-native-community+cli-config+14.0.0+001+hybrid-app.patch b/patches/@react-native-community+cli-config+14.0.0+001+hybrid-app.patch deleted file mode 100644 index 0b82526c88ac..000000000000 --- a/patches/@react-native-community+cli-config+14.0.0+001+hybrid-app.patch +++ /dev/null @@ -1,15 +0,0 @@ -diff --git a/node_modules/@react-native-community/cli-config/build/findDependencies.js b/node_modules/@react-native-community/cli-config/build/findDependencies.js -index d59a1ba..3c0983c 100644 ---- a/node_modules/@react-native-community/cli-config/build/findDependencies.js -+++ b/node_modules/@react-native-community/cli-config/build/findDependencies.js -@@ -24,8 +24,9 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de - */ - function findDependencies(root) { - let pjson; -+ let pkg = process.env.IS_HYBRID_APP ? '../package.json' : 'package.json' - try { -- pjson = JSON.parse(_fs().default.readFileSync(_path().default.join(root, 'package.json'), 'utf8')); -+ pjson = JSON.parse(_fs().default.readFileSync(_path().default.join(root, pkg), 'utf8')); - } catch (e) { - return []; - } From 8cdf9fbdcc57718ffa67eea4d9fb2408b9121ea3 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Mon, 18 Nov 2024 13:55:07 +0100 Subject: [PATCH 04/38] Distinguish HybridApp in the applyPatches.sh script --- scripts/applyPatches.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh index 9e6b4ceb2c4a..29e121acc968 100755 --- a/scripts/applyPatches.sh +++ b/scripts/applyPatches.sh @@ -9,10 +9,15 @@ source "$SCRIPTS_DIR/shellUtils.sh" # Wrapper to run patch-package. function patchPackage { + # See if we're in the HybridApp repo + IS_HYBRID_APP_REPO=$(scripts/is-hybrid-app.sh) + OS="$(uname)" if [[ "$OS" == "Darwin" || "$OS" == "Linux" ]]; then npx patch-package --error-on-fail --color=always - npx patch-package --patch-dir 'Mobile-Expensify/patches' --error-on-fail --color=always + if [[ "$IS_HYBRID_APP_REPO" == "true" ]]; then + npx patch-package --patch-dir 'Mobile-Expensify/patches' --error-on-fail --color=always + fi else error "Unsupported OS: $OS" exit 1 From 72edef44aa3117cd43d329cdd047b9c2f1c8b7b9 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Mon, 18 Nov 2024 14:47:54 +0100 Subject: [PATCH 05/38] Fix postInstall.sh when Mobile-Expensify directory doesn't exist --- scripts/is-hybrid-app.sh | 12 +++++++----- scripts/postInstall.sh | 11 ++++++++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/scripts/is-hybrid-app.sh b/scripts/is-hybrid-app.sh index e8264ef659e8..ebed4a85c547 100755 --- a/scripts/is-hybrid-app.sh +++ b/scripts/is-hybrid-app.sh @@ -1,20 +1,22 @@ #!/bin/bash set -e -cd Mobile-Expensify || echo false +if [[ ! -d Mobile-Expensify ]]; then + echo false + exit 0 +else + cd Mobile-Expensify +fi # Check if 'package.json' exists if [[ -f package.json ]]; then # Read the 'name' field from 'package.json' - package_name=$(jq -r '.name' package.json 2>/dev/null) + # Check if the 'name' field is 'mobile-expensify' if [[ "$package_name" == "mobile-expensify" ]]; then echo true exit 0 - else - echo "Wrong package name in Mobile-Expensify" - exit 1 fi else echo "package.json not found in Mobile-Expensify" diff --git a/scripts/postInstall.sh b/scripts/postInstall.sh index 607b88edd129..db24f04f8a6c 100755 --- a/scripts/postInstall.sh +++ b/scripts/postInstall.sh @@ -7,10 +7,15 @@ set -e ROOT_DIR=$(dirname "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)") cd "$ROOT_DIR" || exit 1 -cd Mobile-Expensify || exit 1 -npm i +# See if we're in the HybridApp repo +IS_HYBRID_APP_REPO=$(scripts/is-hybrid-app.sh) -cd "$ROOT_DIR" || exit 1 +if [[ "$IS_HYBRID_APP_REPO" == "true" ]]; then + cd Mobile-Expensify || exit 1 + npm i + + cd "$ROOT_DIR" || exit 1 +fi # Apply packages using patch-package scripts/applyPatches.sh From 886d2277ed001ab49595d777e8c623dfab49c904 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Mon, 18 Nov 2024 17:38:13 +0100 Subject: [PATCH 06/38] Update README.md --- README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/README.md b/README.md index 6b75fbed1b2c..f5536fd5124a 100644 --- a/README.md +++ b/README.md @@ -436,6 +436,70 @@ export default withOnyx({ 1. The application uses [`react-navigation`](https://reactnavigation.org/) for navigating between parts of the app. 1. [Higher Order Components](https://reactjs.org/docs/higher-order-components.html) are used to connect React components to persistent storage via [`react-native-onyx`](https://github.com/Expensify/react-native-onyx). +---- +# HybridApp + +Currently, the production Expensify app contains both "Expensify Classic" and "New Expensify". The file structure is as follows: + +- 📂 [**App**](https://github.com/Expensify/App) + - 📂 [**android**](https://github.com/Expensify/App/tree/main/android): New Expensify Android specific code (not a part of HybridApp native code) + - 📂 [**ios**](https://github.com/Expensify/App/tree/main/ios): New Expensify iOS specific code (not a part of HybridApp native code) + - 📂 [**src**](https://github.com/Expensify/App/tree/main/src): New Expensify TypeScript logic + - 📂 [**Mobile-Expensify**](https://github.com/Expensify/Mobile-Expensify): `git` submodule that is pointed to [Mobile-Expensify](https://github.com/Expensify/Mobile-Expensify) + - 📂 [**Android**](https://github.com/Expensify/Mobile-Expensify/tree/main/Android): Expensify Classic Android specific code + - 📂 [**iOS**](https://github.com/Expensify/Mobile-Expensify/tree/main/iOS): Expensify Classic iOS specific code + - 📂 [**app**](https://github.com/Expensify/Mobile-Expensify/tree/main/app): Expensify Classic JavaScript logic (aka YAPL) + +If you have access to [`Mobile-Expensify`](https://github.com/Expensify/Mobile-Expensify), you are eligible to build HybridApp. Otherwise you can still continue working on the standalone `NewDot` application. + +## Getting started with HybridApp + +1. If you haven't, please follow [these setup instructions](https://github.com/Expensify/App?tab=readme-ov-file#getting-started) to setup the NewDot local environment. +2. Run `git submodule update --init` to download the `Mobile-Expensify` sourcecode. + +At this point, the default behavior of some `npm` scripts will change to target HybridApp: +- `npm run ios` - build HybridApp +- `npm run ipad` - build HybridApp for iPad +- `npm run ipad-sm` - build HybridApp for small iPad +- `npm run pod-install` - install pods for HybridApp +- `npm run clean` - clean native code of HybridApp + +If for some reason, you need to target the standalone NewDot application, you can append `*-standalone` to each of these scripts (eg. `npm run ios-standalone` will build NewDot instead of HybridApp). + +## Working with HybridApp +Day-to-day work with HybridApp shouldn't differ much from the work on the standalone NewDot repo. + +The main difference is that the native code which runs React Native is located in `Mobile-Expensify/Android` and `Mobile-Expensify/iOS` directories. It means, that changes in `android` and `ios` folders in the root **won't affect the HybridApp build**. + +In that case, if you'd like to eg. remove `Pods`, you need to do it in `Mobile-Expensify/iOS`. The same rule applies to Android builds - if you'd like to delete `.cxx`, `build` or `.gradle` directories, you need to go to `Mobile-Expensify/android` first. + +### Updating the Mobile-Expensify submodule + +`Mobile-Expensify` directory is a git submodule. It means, that it points to a specific commit on the `Mobile-Expensify` repository. If you'd like to download the most recent changes from `main`, please use the following command: + +`git submodule update --remote` + +### Modifying Mobile-Expensify code + +It's important to emphasise that a git submodule is just a **regular git repository** after all. It means that you can switch branches, pull the newest changes, and execute all regular git commands within the `Mobile-Expensify` directory. + +> [!Note] +> #### For external contributors +> +> If you'd like to modify the `Mobile-Expensify` source code, it is best that you create your own fork. Then, you can swap origin of the remote repository by executing this command: +> +> `cd Mobile-Expensify && git remote set-url origin ` +> +> This way, you'll attach the submodule to your fork repository. + +### Adding HybridApp-related patches + +Applying patches from the `patches` directory is performed automatically with the `npm install` command executed in `Expensify/App`. + +If you'd like to add HybridApp-specific patches, use the `--patch-dir` flag: + +`npx patch-package --patch-dir Mobile-Expensify/patches` + ---- # Philosophy From e9d89dafac63da851b241a0950b0028606a5a920 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 19 Nov 2024 09:16:23 +0100 Subject: [PATCH 07/38] Add additional last lines to run-build.shand is-hybrid-app.sh files --- scripts/is-hybrid-app.sh | 2 +- scripts/run-build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/is-hybrid-app.sh b/scripts/is-hybrid-app.sh index ebed4a85c547..32ca190ac832 100755 --- a/scripts/is-hybrid-app.sh +++ b/scripts/is-hybrid-app.sh @@ -21,4 +21,4 @@ if [[ -f package.json ]]; then else echo "package.json not found in Mobile-Expensify" echo false -fi \ No newline at end of file +fi diff --git a/scripts/run-build.sh b/scripts/run-build.sh index 6ea4a0b38524..9ac184b2ea78 100755 --- a/scripts/run-build.sh +++ b/scripts/run-build.sh @@ -71,4 +71,4 @@ case "$BUILD" in *) print_error_and_exit ;; -esac \ No newline at end of file +esac From 10466a5fe7c652cae8cd1d4541ba2ecfc31750ad Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 19 Nov 2024 09:17:01 +0100 Subject: [PATCH 08/38] Update Mobile-Expensify submodule --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index aa88107c87b8..65937e19d6f1 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit aa88107c87b88bf64f3841a09d40a76fdcf24ab5 +Subproject commit 65937e19d6f1976eedfb278fa705f6ec9c7781b2 From be406974a49db374984bed6c340cd50c32fd2dd9 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 19 Nov 2024 13:07:49 +0100 Subject: [PATCH 09/38] Update submodule url --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 7b3a3d9f9432..59abf2448f1d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "Mobile-Expensify"] path = Mobile-Expensify - url = https://github.com/Expensify/Mobile-Expensify.git + url = git@github.com:Expensify/Mobile-Expensify.git From f5c210af8c314c66b3dbbbd52bbf957e029df733 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 19 Nov 2024 13:18:21 +0100 Subject: [PATCH 10/38] Add bundle install command to pod-install.sh to simplify the initial HybridApp setup --- scripts/pod-install.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/pod-install.sh b/scripts/pod-install.sh index 8b2e2b66c829..8e38f1706d6f 100755 --- a/scripts/pod-install.sh +++ b/scripts/pod-install.sh @@ -53,8 +53,9 @@ fi if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then echo -e "${BLUE}Executing npm run pod-install for HybridApp...${NC}" + # Navigate to the OldDot repository, and run bundle install and pod install cd Mobile-Expensify/ios - # Navigate to the OldDot repository, and run pod install + bundle install bundle exec pod install exit 0 fi From de68ceb22053426d9c25c5b38db999ff78f5f63e Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 19 Nov 2024 13:31:11 +0100 Subject: [PATCH 11/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 65937e19d6f1..ec1b66c85deb 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 65937e19d6f1976eedfb278fa705f6ec9c7781b2 +Subproject commit ec1b66c85deb7482400122fef956f3453357f042 From ea1dd0e6987b3afeac85f79244ea8e4c9f1ab443 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 20 Nov 2024 09:55:33 +0100 Subject: [PATCH 12/38] Fix 'npm run ios' command --- react-native.config.js | 4 ++-- scripts/run-build.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/react-native.config.js b/react-native.config.js index d673c19a5cf1..a8c2436688e4 100644 --- a/react-native.config.js +++ b/react-native.config.js @@ -1,7 +1,7 @@ module.exports = { project: { - ios: {sourceDir: process.env.PROJECT_ROOT + 'ios'}, - android: {sourceDir: process.env.PROJECT_ROOT + 'android'}, + ios: {sourceDir: process.env.PROJECT_ROOT_PATH + 'ios'}, + android: {sourceDir: process.env.PROJECT_ROOT_PATH + 'android'}, }, assets: ['./assets/fonts/native'], }; diff --git a/scripts/run-build.sh b/scripts/run-build.sh index 9ac184b2ea78..bb050b6c609b 100755 --- a/scripts/run-build.sh +++ b/scripts/run-build.sh @@ -1,7 +1,7 @@ #!/bin/bash set -e -export PROJECT_ROOT +export PROJECT_ROOT_PATH BUILD="$1" NEW_DOT_FLAG="false" @@ -48,10 +48,10 @@ IS_HYBRID_APP_REPO=$(scripts/is-hybrid-app.sh) APP_ID="org.me.mobiexpensifyg" echo -e "\n${GREEN}Starting a HybridApp build!${NC}" - PROJECT_ROOT="Mobile-Expensify/" + PROJECT_ROOT_PATH="Mobile-Expensify/" else echo -e "\n${GREEN}Starting a standalone NewDot build!${NC}" - PROJECT_ROOT="./" + PROJECT_ROOT_PATH="./" fi # Check if the argument is one of the desired values From 51015f58753099b2184a26c20a42b5e41b7bd4fe Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 20 Nov 2024 10:00:06 +0100 Subject: [PATCH 13/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index ec1b66c85deb..51e0033d5671 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit ec1b66c85deb7482400122fef956f3453357f042 +Subproject commit 51e0033d5671faced49f83ec05737a89d1d4aa3f From 83e3e3865053e9dfbfb862e863b03f5e9df2eaf2 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 20 Nov 2024 12:41:02 +0100 Subject: [PATCH 14/38] Add improvements to pod-install.sh and run-build.sh scripts --- scripts/pod-install.sh | 2 +- scripts/run-build.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/pod-install.sh b/scripts/pod-install.sh index 8e38f1706d6f..e22c96f331c5 100755 --- a/scripts/pod-install.sh +++ b/scripts/pod-install.sh @@ -56,7 +56,7 @@ if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then # Navigate to the OldDot repository, and run bundle install and pod install cd Mobile-Expensify/ios bundle install - bundle exec pod install + bundle exec pod install --repo-update exit 0 fi diff --git a/scripts/run-build.sh b/scripts/run-build.sh index bb050b6c609b..5348fcb2138f 100755 --- a/scripts/run-build.sh +++ b/scripts/run-build.sh @@ -49,6 +49,7 @@ IS_HYBRID_APP_REPO=$(scripts/is-hybrid-app.sh) echo -e "\n${GREEN}Starting a HybridApp build!${NC}" PROJECT_ROOT_PATH="Mobile-Expensify/" + export CUSTOM_APK_NAME="Expensify-debug.apk" else echo -e "\n${GREEN}Starting a standalone NewDot build!${NC}" PROJECT_ROOT_PATH="./" From 2d88e985aa4eecde48d6bb708f057a9059512a3a Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 20 Nov 2024 12:43:38 +0100 Subject: [PATCH 15/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 51e0033d5671..6d0e1082ae36 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 51e0033d5671faced49f83ec05737a89d1d4aa3f +Subproject commit 6d0e1082ae367f8f59d60a919ec46de390143d29 From 03b25ca8a79bda9fb5bdc7514ad29ccf3fe379e3 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 20 Nov 2024 12:52:08 +0100 Subject: [PATCH 16/38] Update submodule path to https --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 59abf2448f1d..7b3a3d9f9432 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "Mobile-Expensify"] path = Mobile-Expensify - url = git@github.com:Expensify/Mobile-Expensify.git + url = https://github.com/Expensify/Mobile-Expensify.git From 3f1068b778a8e49281305e60af3c01f76595a9a9 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 21 Nov 2024 08:37:53 +0100 Subject: [PATCH 17/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 6d0e1082ae36..8cf603919288 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 6d0e1082ae367f8f59d60a919ec46de390143d29 +Subproject commit 8cf6039192889954800e37d818153c245272e18d From 13c3b1bb7b112547f64412320b93180817be827b Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 21 Nov 2024 08:48:19 +0100 Subject: [PATCH 18/38] Add info where to find correct workspace for AS and XCode --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index f5536fd5124a..bbdc191920ab 100644 --- a/README.md +++ b/README.md @@ -473,6 +473,11 @@ The main difference is that the native code which runs React Native is located i In that case, if you'd like to eg. remove `Pods`, you need to do it in `Mobile-Expensify/iOS`. The same rule applies to Android builds - if you'd like to delete `.cxx`, `build` or `.gradle` directories, you need to go to `Mobile-Expensify/android` first. +Additionally, If you'd like to open the HybridApp project in Android Studio or XCode, you **must choose a workspace located in the `Mobile-Expensify`** directory: + +- Android: `./Mobile-Expensify/Android` +- iOS: `./Mobile-Expensify/iOS/Expensify.xcworkspace` + ### Updating the Mobile-Expensify submodule `Mobile-Expensify` directory is a git submodule. It means, that it points to a specific commit on the `Mobile-Expensify` repository. If you'd like to download the most recent changes from `main`, please use the following command: From fcbd7b468e5bc2824420f05ca2f9db56bc79db0c Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 21 Nov 2024 09:10:47 +0100 Subject: [PATCH 19/38] Fix the clean.sh script --- package.json | 2 +- scripts/clean.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 78c5e7a6dbbe..f8000c26198a 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "setupNewDotWebForEmulators": "./scripts/setup-newdot-web-emulators.sh", "startAndroidEmulator": "./scripts/start-android.sh", "postinstall": "./scripts/postInstall.sh", - "clean": "npx react-native clean-project-auto", + "clean": "./scripts/clean.sh", "clean-standalone": "./scripts/clean.sh", "android": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --android", "android-standalone": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --android --new-dot", diff --git a/scripts/clean.sh b/scripts/clean.sh index 99cce1e56ad0..1ecd73731b61 100755 --- a/scripts/clean.sh +++ b/scripts/clean.sh @@ -11,7 +11,7 @@ if [[ "$IS_HYBRID_APP_REPO" == "true" && "$1" != "--new-dot" ]]; then echo -e "${BLUE}Cleaning HybridApp project...${NC}" # Navigate to Mobile-Expensify repository, and clean cd Mobile-Expensify - npm run clean + npm run clean -- "$@" else # Clean NewDot echo -e "${BLUE}Cleaning standalone NewDot project...${NC}" From 947e97018de5315abb0537833a01e7352c246935 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 21 Nov 2024 11:21:03 +0100 Subject: [PATCH 20/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 8cf603919288..a05af9dccde6 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 8cf6039192889954800e37d818153c245272e18d +Subproject commit a05af9dccde685719d491f90a9a468153f2eb4b5 From a17f39c63a21162195ba3dde9182947a17fb6792 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 21 Nov 2024 12:12:24 +0100 Subject: [PATCH 21/38] Add HybridApp troubleshooting section in README.md --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index bbdc191920ab..9bb85f1704c4 100644 --- a/README.md +++ b/README.md @@ -505,6 +505,26 @@ If you'd like to add HybridApp-specific patches, use the `--patch-dir` flag: `npx patch-package --patch-dir Mobile-Expensify/patches` +### HybridApp troubleshooting + +#### Cleaning the repo +- `npm run clean` - deep clean of all HybridApp artifacts (including NewDot's `node_modules`) +- `npm run clean -- --ios` - clean only iOS HybridApp artifacts (`Pods`, `build` folder, `DerivedData`) +- `npm run clean -- --android` - clean only Android HybridApp artifacts (`.cxx`, `build`, and `.gradle` folders, execute `./gradlew clean`) + +If you'd like to do it manually, remember to `cd Mobile-Expensify` first! + +#### Common errors +1. **Please check your internet connection** - set `_isOnDev` in `api.js` to always return `false` +2. **CDN: trunk URL couldn't be downloaded** - `cd Mobile-Expensify && pod repo remove trunk` + +3. **Task :validateSigningRelease FAILED** - open `Mobile-Expensify/Android/build.gradle` and do the following: + ``` + - signingConfig signingConfigs.release + + signingConfig signingConfigs.debug + ``` +4. **Build service could not create build operation: unknown error while handling message: MsgHandlingError(message: "unable to initiate PIF transfer session (operation in progress?)")** - reopen XCode + ---- # Philosophy From 158de252732f877078509553729c697e2b6d2f93 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 21 Nov 2024 13:45:26 +0100 Subject: [PATCH 22/38] Adjust HybridApp deployment to the added submodule --- .github/workflows/deploy.yml | 43 ++++++------------------------------ fastlane/Fastfile | 16 +++++++------- 2 files changed, 15 insertions(+), 44 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1447bbf20c6d..84492faa8f02 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -167,18 +167,13 @@ jobs: name: Build and deploy Android HybridApp needs: prep runs-on: ubuntu-latest-xl - defaults: - run: - working-directory: Mobile-Expensify/react-native env: RUBYOPT: '-rostruct' steps: - name: Checkout uses: actions/checkout@v4 with: - repository: 'Expensify/Mobile-Expensify' submodules: true - path: 'Mobile-Expensify' token: ${{ secrets.OS_BOTIFY_TOKEN }} # fetch-depth: 0 is required in order to fetch the correct submodule branch fetch-depth: 0 @@ -193,19 +188,9 @@ jobs: - name: Configure MapBox SDK run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} - - uses: actions/setup-node@v4 - with: - node-version-file: 'Mobile-Expensify/react-native/.nvmrc' - cache: npm - cache-dependency-path: 'Mobile-Expensify/react-native' - - - name: Install node modules - run: | - npm install - cd .. && npm install - - # Fixes https://github.com/Expensify/App/issues/51682 - npm run grunt:build:shared + - name: Setup Node + id: setup-node + uses: ./.github/actions/composite/setupNode - name: Setup Java uses: actions/setup-java@v4 @@ -217,7 +202,6 @@ jobs: uses: ruby/setup-ruby@v1.190.0 with: bundler-cache: true - working-directory: 'Mobile-Expensify/react-native' - name: Install New Expensify Gems run: bundle install @@ -232,7 +216,7 @@ jobs: op document get --output ./upload-key.keystore upload-key.keystore op document get --output ./android-fastlane-json-key.json android-fastlane-json-key.json # Copy the keystore to the Android directory for Fullstory - cp ./upload-key.keystore ../Android + cp ./upload-key.keystore Mobile-Expensify/Android - name: Load Android upload keystore credentials from 1Password id: load-credentials @@ -487,16 +471,11 @@ jobs: runs-on: macos-13-xlarge env: DEVELOPER_DIR: /Applications/Xcode_15.2.0.app/Contents/Developer - defaults: - run: - working-directory: Mobile-Expensify/react-native steps: - name: Checkout uses: actions/checkout@v4 with: - repository: 'Expensify/Mobile-Expensify' submodules: true - path: 'Mobile-Expensify' token: ${{ secrets.OS_BOTIFY_TOKEN }} # fetch-depth: 0 is required in order to fetch the correct submodule branch fetch-depth: 0 @@ -512,22 +491,14 @@ jobs: run: | ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} - - uses: actions/setup-node@v4 + - name: Setup Node id: setup-node - with: - node-version-file: 'Mobile-Expensify/react-native/.nvmrc' - cache-dependency-path: 'Mobile-Expensify/react-native' - - - name: Install node modules - run: | - npm install - cd .. && npm install + uses: ./.github/actions/composite/setupNode - name: Setup Ruby uses: ruby/setup-ruby@v1.190.0 with: bundler-cache: true - working-directory: 'Mobile-Expensify/react-native' - name: Install New Expensify Gems run: bundle install @@ -549,7 +520,7 @@ jobs: with: timeout_minutes: 10 max_attempts: 5 - command: cd Mobile-Expensify/iOS && pod install + command: npm run pod-install - name: Install 1Password CLI uses: 1password/install-cli-action@v1 diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 1c8b62cfb579..697923dcfc30 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -71,9 +71,9 @@ platform :android do desc "Generate a production HybridApp AAB" lane :build_hybrid do - ENV["ENVFILE"]="../.env.production.hybridapp" + ENV["ENVFILE"]="Mobile-Expensify/.env.production.hybridapp" gradle( - project_dir: '../Android', + project_dir: 'Mobile-Expensify/Android', task: "bundleRelease", flags: "--refresh-dependencies", properties: { @@ -102,7 +102,7 @@ platform :android do lane :build_local_hybrid do ENV["ENVFILE"]=".env.production" gradle( - project_dir: '../Android', + project_dir: 'Mobile-Expensify/Android', task: 'assemble', flavor: 'Production', build_type: 'Release', @@ -353,7 +353,7 @@ platform :ios do desc "Build an iOS HybridApp production build" lane :build_hybrid do - ENV["ENVFILE"]="../.env.production.hybridapp" + ENV["ENVFILE"]="Mobile-Expensify/.env.production.hybridapp" setupIOSSigningCertificate() @@ -366,7 +366,7 @@ platform :ios do ) build_app( - workspace: "../iOS/Expensify.xcworkspace", + workspace: "Mobile-Expensify/iOS/Expensify.xcworkspace", scheme: "Expensify", output_name: "Expensify.ipa", export_method: "app-store", @@ -394,9 +394,9 @@ platform :ios do desc "Build an unsigned iOS HybridApp production build" lane :build_unsigned_hybrid do - ENV["ENVFILE"]="../Mobile-Expensify/.env.production.hybridapp" + ENV["ENVFILE"]="./Mobile-Expensify/.env.production.hybridapp" build_app( - workspace: "../Mobile-Expensify/iOS/Expensify.xcworkspace", + workspace: "./Mobile-Expensify/iOS/Expensify.xcworkspace", scheme: "Expensify" ) setIOSBuildOutputsInEnv() @@ -513,7 +513,7 @@ platform :ios do dsym_path: ENV[KEY_DSYM_PATH], gsp_path: "./ios/GoogleService-Info.plist", # Assuming we are running this from the react-native submodule directory for HybridApp - binary_path: "../iOS/Pods/FirebaseCrashlytics/upload-symbols" + binary_path: "./Mobile-Expensify/iOS/Pods/FirebaseCrashlytics/upload-symbols" ) end From 8244b48cf7ce7957f34729634a41a988ea16f706 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 21 Nov 2024 15:48:11 +0100 Subject: [PATCH 23/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index a05af9dccde6..54d67afd89ec 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit a05af9dccde685719d491f90a9a468153f2eb4b5 +Subproject commit 54d67afd89ec741d11a26b99c37fdc3b7ece3038 From bbd6009e672216a8a55165d2993661c556bb8c3f Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 26 Nov 2024 16:20:25 +0100 Subject: [PATCH 24/38] Fix npm run clean-standalone script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a0cb085cfb84..0932c53b55ce 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "startAndroidEmulator": "./scripts/start-android.sh", "postinstall": "./scripts/postInstall.sh", "clean": "./scripts/clean.sh", - "clean-standalone": "./scripts/clean.sh", + "clean-standalone": "./scripts/clean.sh --new-dot", "android": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --android", "android-standalone": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --android --new-dot", "ios": "./scripts/set-pusher-suffix.sh && ./scripts/run-build.sh --ios", From 43e9dfb55cc40a1b0d63fddeb11bb85348efe886 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 26 Nov 2024 16:22:12 +0100 Subject: [PATCH 25/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 54d67afd89ec..5964b56ba836 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 54d67afd89ec741d11a26b99c37fdc3b7ece3038 +Subproject commit 5964b56ba836302579c18aeaa5e264b05d0fab59 From b218c1ea4f191bc6c44e7fa799ae8e2e917c2943 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 26 Nov 2024 16:38:50 +0100 Subject: [PATCH 26/38] Remove -rostruct flag from deploy.yml --- .github/workflows/deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 438cfbbb99aa..a5f39ef5f5ed 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -118,8 +118,6 @@ jobs: name: Build and deploy Android HybridApp needs: prep runs-on: ubuntu-latest-xl - env: - RUBYOPT: '-rostruct' steps: - name: Checkout uses: actions/checkout@v4 From e71007d03b6123d8eb60ee4b93040917927b00b9 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Tue, 26 Nov 2024 16:43:14 +0100 Subject: [PATCH 27/38] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7bda97b0ff0a..9bad4f8979db 100644 --- a/README.md +++ b/README.md @@ -451,7 +451,7 @@ Currently, the production Expensify app contains both "Expensify Classic" and "N - 📂 [**iOS**](https://github.com/Expensify/Mobile-Expensify/tree/main/iOS): Expensify Classic iOS specific code - 📂 [**app**](https://github.com/Expensify/Mobile-Expensify/tree/main/app): Expensify Classic JavaScript logic (aka YAPL) -If you have access to [`Mobile-Expensify`](https://github.com/Expensify/Mobile-Expensify), you are eligible to build HybridApp. Otherwise you can still continue working on the standalone `NewDot` application. +You can only build HybridApp if you have been granted access to [`Mobile-Expensify`](https://github.com/Expensify/Mobile-Expensify). For most contributors, you will be working on the standalone NewDot application. ## Getting started with HybridApp From 9a31329d1c344db48ae3a1b0214c8ec9aeb46095 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 28 Nov 2024 09:50:36 +0100 Subject: [PATCH 28/38] Fix npm run pod-install-standalone script --- scripts/pod-install.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/pod-install.sh b/scripts/pod-install.sh index e22c96f331c5..6d5acdb5e81b 100755 --- a/scripts/pod-install.sh +++ b/scripts/pod-install.sh @@ -11,6 +11,8 @@ set -e BLUE='\033[1;34m' NC='\033[0m' +export PROJECT_ROOT_PATH + # Go to project root START_DIR="$(pwd)" ROOT_DIR="$(dirname "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)")" @@ -54,6 +56,7 @@ fi if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then echo -e "${BLUE}Executing npm run pod-install for HybridApp...${NC}" # Navigate to the OldDot repository, and run bundle install and pod install + PROJECT_ROOT_PATH="Mobile-Expensify/" cd Mobile-Expensify/ios bundle install bundle exec pod install --repo-update @@ -61,6 +64,7 @@ if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then fi echo -e "${BLUE}Executing npm run pod-install for standalone NewDot...${NC}" +PROJECT_ROOT_PATH="./" CACHED_PODSPEC_DIR='ios/Pods/Local Podspecs' if [ -d "$CACHED_PODSPEC_DIR" ]; then From d371d3af014591817f110de3d9a814ed6b614bbf Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 28 Nov 2024 10:01:37 +0100 Subject: [PATCH 29/38] Improve logic for pod install command --- Mobile-Expensify | 2 +- ios/Podfile | 2 ++ ios/Podfile.lock | 2 +- scripts/pod-install.sh | 5 +---- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 5964b56ba836..451f0516c31a 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 5964b56ba836302579c18aeaa5e264b05d0fab59 +Subproject commit 451f0516c31a76190215960c330852706593acde diff --git a/ios/Podfile b/ios/Podfile index 4d139711ef01..41dc5179752d 100644 --- a/ios/Podfile +++ b/ios/Podfile @@ -3,6 +3,7 @@ require File.join(File.dirname(`node --print "require.resolve('expo/package.json # This value is used by $RNMapboxMaps $RNMapboxMapsImpl = 'mapbox' $VCDisableFrameProcessors = true +ENV['PROJECT_ROOT_PATH'] = "./"; def node_require(script) # Resolve script with node to allow for hoisting @@ -82,6 +83,7 @@ target 'NewExpensify' do # ENV Variable enables/disables TurboModules ENV['RCT_NEW_ARCH_ENABLED'] = '1'; + use_react_native!( :path => config[:reactNativePath], # An absolute path to your application root. diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 21633b432c12..62ff489fb9fd 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -3305,6 +3305,6 @@ SPEC CHECKSUMS: VisionCamera: c6c8aa4b028501fc87644550fbc35a537d4da3fb Yoga: a1d7895431387402a674fd0d1c04ec85e87909b8 -PODFILE CHECKSUM: 15e2f095b9c80d658459723edf84005a6867debf +PODFILE CHECKSUM: 615266329434ea4a994dccf622008a2197313c88 COCOAPODS: 1.15.2 diff --git a/scripts/pod-install.sh b/scripts/pod-install.sh index 6d5acdb5e81b..9d36255a659e 100755 --- a/scripts/pod-install.sh +++ b/scripts/pod-install.sh @@ -11,8 +11,6 @@ set -e BLUE='\033[1;34m' NC='\033[0m' -export PROJECT_ROOT_PATH - # Go to project root START_DIR="$(pwd)" ROOT_DIR="$(dirname "$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)")" @@ -56,15 +54,14 @@ fi if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then echo -e "${BLUE}Executing npm run pod-install for HybridApp...${NC}" # Navigate to the OldDot repository, and run bundle install and pod install - PROJECT_ROOT_PATH="Mobile-Expensify/" cd Mobile-Expensify/ios bundle install + bundle exec pod repo remove trunk bundle exec pod install --repo-update exit 0 fi echo -e "${BLUE}Executing npm run pod-install for standalone NewDot...${NC}" -PROJECT_ROOT_PATH="./" CACHED_PODSPEC_DIR='ios/Pods/Local Podspecs' if [ -d "$CACHED_PODSPEC_DIR" ]; then From d0cae08cfe900e4f3d2bafc9491b1cbc9605c7c0 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 28 Nov 2024 12:23:38 +0100 Subject: [PATCH 30/38] Update README.md with info how to solve problems with git submodule update --init command --- README.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9bad4f8979db..3bc4d823260a 100644 --- a/README.md +++ b/README.md @@ -455,11 +455,18 @@ You can only build HybridApp if you have been granted access to [`Mobile-Expensi ## Getting started with HybridApp -1. If you haven't, please follow [these setup instructions](https://github.com/Expensify/App?tab=readme-ov-file#getting-started) to setup the NewDot local environment. +1. If you haven't, please follow [these instructions](https://github.com/Expensify/App?tab=readme-ov-file#getting-started) to setup the NewDot local environment. 2. Run `git submodule update --init` to download the `Mobile-Expensify` sourcecode. +- If you have access to `Mobile-Expensify` and the command fails with a https-related error add this to your `~/.gitconfig` file: + + ``` + [url "ssh://git@github.com/"] + insteadOf = https://github.com/ + ``` At this point, the default behavior of some `npm` scripts will change to target HybridApp: -- `npm run ios` - build HybridApp +- `npm run android` - build HybridApp for Android +- `npm run ios` - build HybridApp for iOS - `npm run ipad` - build HybridApp for iPad - `npm run ipad-sm` - build HybridApp for small iPad - `npm run pod-install` - install pods for HybridApp From b92f56732b39a97d583e21cc281dd3dfb68537ef Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 28 Nov 2024 12:28:17 +0100 Subject: [PATCH 31/38] Add relative paths to better explain where the native code lies in HybridApp in README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3bc4d823260a..750bc6229d33 100644 --- a/README.md +++ b/README.md @@ -477,9 +477,9 @@ If for some reason, you need to target the standalone NewDot application, you ca ## Working with HybridApp Day-to-day work with HybridApp shouldn't differ much from the work on the standalone NewDot repo. -The main difference is that the native code which runs React Native is located in `Mobile-Expensify/Android` and `Mobile-Expensify/iOS` directories. It means, that changes in `android` and `ios` folders in the root **won't affect the HybridApp build**. +The main difference is that the native code which runs React Native is located in `./Mobile-Expensify/Android` and `./Mobile-Expensify/iOS` directories. It means, that changes in `./android` and `./ios` folders in the root **won't affect the HybridApp build**. -In that case, if you'd like to eg. remove `Pods`, you need to do it in `Mobile-Expensify/iOS`. The same rule applies to Android builds - if you'd like to delete `.cxx`, `build` or `.gradle` directories, you need to go to `Mobile-Expensify/android` first. +In that case, if you'd like to eg. remove `Pods`, you need to do it in `./Mobile-Expensify/iOS`. The same rule applies to Android builds - if you'd like to delete `.cxx`, `build` or `.gradle` directories, you need to go to `./Mobile-Expensify/android` first. Additionally, If you'd like to open the HybridApp project in Android Studio or XCode, you **must choose a workspace located in the `Mobile-Expensify`** directory: From d026fb39e393f9db6153a1a0c097d5510ab12bfe Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 28 Nov 2024 13:00:48 +0100 Subject: [PATCH 32/38] Remove 'pod repo remove trunk' command from pod-install.sh --- scripts/pod-install.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/pod-install.sh b/scripts/pod-install.sh index 9d36255a659e..e22c96f331c5 100755 --- a/scripts/pod-install.sh +++ b/scripts/pod-install.sh @@ -56,7 +56,6 @@ if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then # Navigate to the OldDot repository, and run bundle install and pod install cd Mobile-Expensify/ios bundle install - bundle exec pod repo remove trunk bundle exec pod install --repo-update exit 0 fi From bb95e91df322fb1a0478abf7b9149377927db57b Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 28 Nov 2024 13:23:39 +0100 Subject: [PATCH 33/38] Fix standalone NewDot installation step --- scripts/run-build.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/run-build.sh b/scripts/run-build.sh index 5348fcb2138f..7689aabbbf59 100755 --- a/scripts/run-build.sh +++ b/scripts/run-build.sh @@ -6,7 +6,7 @@ export PROJECT_ROOT_PATH BUILD="$1" NEW_DOT_FLAG="false" IOS_MODE="DebugDevelopment" -ANDROID_MODE="DevelopmentDebug" +ANDROID_MODE="developmentDebug" SCHEME="New Expensify Dev" APP_ID="com.expensify.chat.dev" @@ -52,7 +52,9 @@ IS_HYBRID_APP_REPO=$(scripts/is-hybrid-app.sh) export CUSTOM_APK_NAME="Expensify-debug.apk" else echo -e "\n${GREEN}Starting a standalone NewDot build!${NC}" + echo $ANDROID_MODE PROJECT_ROOT_PATH="./" + unset CUSTOM_APK_NAME fi # Check if the argument is one of the desired values @@ -67,7 +69,7 @@ case "$BUILD" in npx react-native run-ios --simulator "iPad Pro (11-inch) (4th generation)" --mode $IOS_MODE --scheme "$SCHEME" ;; --android) - npx react-native run-android --list-devices --mode $ANDROID_MODE --appId $APP_ID --active-arch-only + npx react-native run-android --mode $ANDROID_MODE --appId $APP_ID --active-arch-only ;; *) print_error_and_exit From 49183bc3b9ee2ea1553f9904450a090fe8812fce Mon Sep 17 00:00:00 2001 From: staszekscp Date: Thu, 5 Dec 2024 10:56:48 +0100 Subject: [PATCH 34/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 3f4b7deec3c0..88778242d462 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 3f4b7deec3c0717807775d29dec9b0c954d81d29 +Subproject commit 88778242d4626be84791efe061c184a09b5228e1 From 793d49574fa92dca091e0e7a7b5ce6175165875d Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 11 Dec 2024 09:02:23 +0100 Subject: [PATCH 35/38] Update submodule and README.md --- Mobile-Expensify | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index 88778242d462..c6706958e76e 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit 88778242d4626be84791efe061c184a09b5228e1 +Subproject commit c6706958e76ef0a64c44165c21f134c3d2ed27c5 diff --git a/README.md b/README.md index 750bc6229d33..77b9d509a74d 100644 --- a/README.md +++ b/README.md @@ -524,7 +524,7 @@ If you'd like to do it manually, remember to `cd Mobile-Expensify` first! #### Common errors 1. **Please check your internet connection** - set `_isOnDev` in `api.js` to always return `false` -2. **CDN: trunk URL couldn't be downloaded** - `cd Mobile-Expensify && pod repo remove trunk` +2. **CDN: trunk URL couldn't be downloaded** - `cd Mobile-Expensify/iOS && pod repo remove trunk` 3. **Task :validateSigningRelease FAILED** - open `Mobile-Expensify/Android/build.gradle` and do the following: ``` From 621cb78510e76abbcd479034d656031768058e8e Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 11 Dec 2024 11:40:05 +0100 Subject: [PATCH 36/38] Update submodule commit --- Mobile-Expensify | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mobile-Expensify b/Mobile-Expensify index c6706958e76e..7df7a0a1002d 160000 --- a/Mobile-Expensify +++ b/Mobile-Expensify @@ -1 +1 @@ -Subproject commit c6706958e76ef0a64c44165c21f134c3d2ed27c5 +Subproject commit 7df7a0a1002d7622fd8b9c59a5dbfcc39164e736 From 255b634a88f52ab5f52df3760731254bf201ac37 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 11 Dec 2024 12:21:06 +0100 Subject: [PATCH 37/38] Remove --repo-update flag from the pod-install script --- scripts/pod-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/pod-install.sh b/scripts/pod-install.sh index e22c96f331c5..8e38f1706d6f 100755 --- a/scripts/pod-install.sh +++ b/scripts/pod-install.sh @@ -56,7 +56,7 @@ if [[ "$IS_HYBRID_APP_REPO" == "true" && "$NEW_DOT_FLAG" == "false" ]]; then # Navigate to the OldDot repository, and run bundle install and pod install cd Mobile-Expensify/ios bundle install - bundle exec pod install --repo-update + bundle exec pod install exit 0 fi From 791dbee169972c642a1ee9059fcb52d1e6429866 Mon Sep 17 00:00:00 2001 From: staszekscp Date: Wed, 11 Dec 2024 12:38:43 +0100 Subject: [PATCH 38/38] Fix deploy.yml --- .github/workflows/deploy.yml | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 220b58cfa39e..d58a81c8d80a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -164,10 +164,7 @@ jobs: needs: prep runs-on: ubuntu-latest-xl steps: - - name: Checkout App repo - uses: actions/checkout@v4 - - - name: Checkout Mobile-Expensify repo + - name: Checkout App and Mobile-Expensify repo uses: actions/checkout@v4 with: submodules: true @@ -175,12 +172,9 @@ jobs: # fetch-depth: 0 is required in order to fetch the correct submodule branch fetch-depth: 0 - - name: Update submodule + - name: Update submodule to match main run: | - git submodule update --init - # Update submodule to latest on staging - git fetch - git checkout staging + git submodule update --init --remote - name: Configure MapBox SDK run: ./scripts/setup-mapbox-sdk.sh ${{ secrets.MAPBOX_SDK_DOWNLOAD_TOKEN }} @@ -491,10 +485,7 @@ jobs: - name: Update submodule run: | - git submodule update --init - # Update submodule to latest on staging - git fetch - git checkout staging + git submodule update --init --remote - name: Configure MapBox SDK run: | @@ -516,12 +507,12 @@ jobs: uses: actions/cache@v4 id: pods-cache with: - path: ios/Pods - key: ${{ runner.os }}-pods-cache-${{ hashFiles('ios/Podfile.lock', 'firebase.json') }} + path: Mobile-Expensify/ios/Pods + key: ${{ runner.os }}-pods-cache-${{ hashFiles('Mobile-Expensify/ios/Podfile.lock', 'firebase.json') }} - name: Compare Podfile.lock and Manifest.lock id: compare-podfile-and-manifest - run: echo "IS_PODFILE_SAME_AS_MANIFEST=${{ hashFiles('ios/Podfile.lock') == hashFiles('ios/Pods/Manifest.lock') }}" >> "$GITHUB_OUTPUT" + run: echo "IS_PODFILE_SAME_AS_MANIFEST=${{ hashFiles('Mobile-Expensify/ios/Podfile.lock') == hashFiles('Mobile-Expensify/ios/Pods/Manifest.lock') }}" >> "$GITHUB_OUTPUT" - name: Install cocoapods uses: nick-fields/retry@3f757583fb1b1f940bc8ef4bf4734c8dc02a5847