Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ci): Expo #12244

Open
wants to merge 59 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
c36edda
Expo init & initial dependencies fixes
andrepimenta Nov 8, 2024
abcb412
Fix Minimizer
andrepimenta Nov 8, 2024
b181a1f
Fix android - expo-build-properties
andrepimenta Nov 8, 2024
f586844
Install dev client & fix iOS startup
andrepimenta Nov 8, 2024
820321f
Deeplinks working
andrepimenta Nov 8, 2024
d482e09
Update commands
andrepimenta Nov 8, 2024
b239c13
Merge branch 'main' into feat/expo
andrepimenta Nov 8, 2024
b62c24f
dedupe dependencies
andrepimenta Nov 8, 2024
537b324
Merge branch 'feat/expo' of https://github.com/MetaMask/metamask-mobi…
andrepimenta Nov 8, 2024
75f15f8
Change SWIFT_PRECOMPILE_BRIDGING_HEADER to no because of AST error
andrepimenta Nov 11, 2024
7d3908a
Update jest because of expo vector icons incompatibility
andrepimenta Nov 11, 2024
97dfdba
Test npx expo for building release
andrepimenta Nov 11, 2024
8313809
Add if debug
andrepimenta Nov 11, 2024
d629c06
Test fix iOS QA builds
andrepimenta Nov 12, 2024
15e0ff3
Fix podfile
andrepimenta Nov 12, 2024
0bee935
Update tsconfig.json
andrepimenta Nov 12, 2024
42499c2
Merge branch 'main' into feat/expo
andrepimenta Nov 12, 2024
1d9f6f0
Merge branch 'main' into feat/expo
andrepimenta Nov 12, 2024
c492be1
Update github scripts tsconfig
andrepimenta Nov 12, 2024
b0a927a
Merge branch 'feat/expo' of https://github.com/MetaMask/metamask-mobi…
andrepimenta Nov 12, 2024
8d11697
Merge branch 'main' into feat/expo
andrepimenta Nov 12, 2024
6bc1cd8
Fix gh tsconfig
andrepimenta Nov 12, 2024
4c50f3f
Merge branch 'feat/expo' of https://github.com/MetaMask/metamask-mobi…
andrepimenta Nov 12, 2024
40bd6fb
Merge branch 'main' into feat/expo
andrepimenta Nov 12, 2024
a73d485
Merge branch 'main' into feat/expo
andrepimenta Nov 13, 2024
e7e3495
Fix e2e for expo
andrepimenta Nov 19, 2024
8aebcb8
Update all build scripts to use expo
andrepimenta Nov 22, 2024
1c1f175
Android dev build
andrepimenta Nov 22, 2024
a11c4b1
Merge branch 'main' into feat/expo
andrepimenta Nov 22, 2024
20a93f6
Prepare bitrise android
andrepimenta Nov 22, 2024
0602870
Rename apk
andrepimenta Nov 22, 2024
39a57be
Test bitrise ios
andrepimenta Nov 22, 2024
a2779ee
Fix plist bitrise
andrepimenta Nov 22, 2024
fabefda
Update build script for ios dev build
andrepimenta Nov 22, 2024
e74fd8e
dedupe and return jest to react-native preset
andrepimenta Nov 25, 2024
723dfb3
Merge branch 'main' into feat/expo
andrepimenta Nov 25, 2024
90d5074
Dedupe
andrepimenta Nov 25, 2024
75710d7
Merge branch 'feat/expo' of https://github.com/MetaMask/metamask-mobi…
andrepimenta Nov 25, 2024
0b2af90
Readme updates
andrepimenta Nov 25, 2024
4e6408f
Trying iOS development build in bitrise
andrepimenta Nov 25, 2024
71208d9
Update IosExportOptionsMetaMaskDevelopment.plist
andrepimenta Nov 25, 2024
cf16d2d
allowProvisioningUpdates for bitrise development
andrepimenta Nov 25, 2024
0a9b59c
Update bitrise devbuild script
andrepimenta Nov 25, 2024
4906eda
remove automatic signing and pinned debug build to a specific profile
sethkfman Nov 25, 2024
9c5fe55
Add team name
andrepimenta Nov 26, 2024
a84d7f8
test open ssl
andrepimenta Nov 26, 2024
6cd1d70
Merge branch 'main' into feat/expo
andrepimenta Nov 26, 2024
e56a8f0
Bitrise rename IPA
andrepimenta Nov 26, 2024
22e6dad
fix bitrise yml
andrepimenta Nov 26, 2024
4298bfb
Fix audit
andrepimenta Nov 26, 2024
b189129
Merge branch 'main' into feat/expo
andrepimenta Nov 26, 2024
c0fa724
ignore dependencies
andrepimenta Nov 26, 2024
cf5f536
Merge branch 'feat/expo' of https://github.com/MetaMask/metamask-mobi…
andrepimenta Nov 26, 2024
99857cb
Merge branch 'main' into feat/expo
andrepimenta Nov 27, 2024
a4cc538
fix lint errors
andrepimenta Nov 27, 2024
d0bb7d9
Merge branch 'feat/expo' of https://github.com/MetaMask/metamask-mobi…
andrepimenta Nov 27, 2024
d966508
fix name of the function launchApp
andrepimenta Nov 27, 2024
03cdfe1
Merge branch 'main' into feat/expo
andrepimenta Nov 27, 2024
807f875
Fix has icon
andrepimenta Nov 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .depcheckrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,10 @@ ignores:
- 'app'
- 'i18n-js'
- 'images'

## Expo
- '@config-plugins/detox'
- 'cross-spawn'
- 'expo-build-properties'
- 'expo-dev-client'

60 changes: 59 additions & 1 deletion .github/scripts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
{
"extends": "../../tsconfig.json"
"compilerOptions": {
/* Basic Options */
"target": "esnext" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */,
"module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */,
"lib": [
"es2017",
] /* Specify library files to be included in the compilation. */,
"allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react-native" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "removeComments": true, /* Do not emit comments to output. */
"noEmit": true /* Do not emit outputs. */,
// "incremental": true, /* Enable incremental compilation */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
"isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
/* Strict Type-Checking Options */
"strict": true /* Enable all strict type-checking options. */,
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"resolveJsonModule": true /* Allows importing JSON files */,
"baseUrl": "." /* Base directory to resolve non-absolute module names. */,
/* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
"esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
"skipLibCheck": true /* Skip type checking of declaration files. */
/* Source Map Options */
// "sourceRoot": "./", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "./", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
},
"exclude": [
"node_modules",
"jest.config.js"
]
}
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ DerivedData
project.xcworkspace
ios/debug.xcconfig
ios/release.xcconfig
.xcode.env.local

# android / intellij
build/
Expand Down Expand Up @@ -130,4 +131,8 @@ docs/assets/termsOfUse.html
android/app/src/main/assets/modules.json

# Google firebase base64 derived configs
**/GoogleService-Info.plist
**/GoogleService-Info.plist
# Expo
.expo
dist/
web-build/
65 changes: 56 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ To learn how to contribute to the MetaMask codebase, visit our [Contributor Docs
## Documentation

- [Architecture](./docs/readme/architecture.md)
- [Development Environment Setup](./docs/readme/environment.md)
- [Expo Development Environment Setup](./docs/readme/expo-environment.md)
- [Native Development Environment Setup](./docs/readme/environment.md)
- [Build Troubleshooting](./docs/readme/troubleshooting.md)
- [Testing](./docs/readme/testing.md)
- [Debugging](./docs/readme/debugging.md)
Expand All @@ -24,13 +25,59 @@ To learn how to contribute to the MetaMask codebase, visit our [Contributor Docs

## Getting started

### Environment setup
### Using Expo (recommended)

Before running the app, make sure your development environment has all the required tools. Several of these tools (ie Node and Ruby) may require specific versions in order to successfully build the app.
Expo is the fastest way to start developing. With the Expo framework, developers don't need to compile the native side of the application as before, hence no need for any native enviornment setup, developers only need to download a precompiled develpoment build and run the javascript bundler. The development build will then connect with the bundler to load the javascript code.

#### Expo Environment Setup

[Install node, yarn and watchman.](./docs/readme/expo-environment.md)

#### Clone the project

```bash
git clone [email protected]:MetaMask/metamask-mobile.git && \
cd metamask-mobile
```

#### Install dependencies

```bash
yarn setup:expo
```

#### Run the bundler

```bash
yarn watch
```

#### Download and install the development build

Go to the app's [GitHub Releases page](https://github.com/MetaMask/metamask-mobile/releases), download the latest release development build (android-expo-dev-build.apk or ios-expo-dev-build.ipa) and install it on an Android/iOS simulator or Android/iOS physical device.

#### Load the app

If on a simulator:
- use the initial expo screen that appears when starting the development to choose the bundler url
- OR press "a" for Android or "i" for iOS on the terminal where the bundler is running

If on a physical device:
- Use the camera app to scan the QR code presented by the bundler running on the terminal

That's it! This will work for any javascript development, if you need to develop or modify native code please see the next section.

### Native Development

If developing or modifying native code or installing any library that introduces or uses native code, it is not possible to use an Expo precompiled development build as you need to compile the native side of the application again. To do so, please follow the steps stated in this section.

#### Native Environment setup

Before running the app for native development, make sure your development environment has all the required tools. Several of these tools (ie Node and Ruby) may require specific versions in order to successfully build the app.

[Setup your development environment](./docs/readme/environment.md)

### Building the app
#### Building the app

**Clone the project**

Expand All @@ -39,16 +86,16 @@ git clone [email protected]:MetaMask/metamask-mobile.git && \
cd metamask-mobile
```

#### Firebase Messaging Setup
##### Firebase Messaging Setup

MetaMask uses Firebase Cloud Messaging (FCM) to enable app communications. To integrate FCM, you’ll need configuration files for both iOS and Android platforms.

##### Internal Contributor instructions
###### Internal Contributor instructions

1. Grab the `.js.env` file from 1Password, ask around for the correct vault. This file contains the `GOOGLE_SERVICES_B64_ANDROID` and `GOOGLE_SERVICES_B64_IOS` secrets that will be used to generate the relevant configuration files for IOS/Android.
2. [Install](./README.md#install-dependencies) and [run & start](./README.md#running-the-app) the application as documented below.

##### External Contributor instructions
###### External Contributor instructions

As an external contributor, you need to provide your own Firebase project configuration files:
- **`GoogleService-Info.plist`** (iOS)
Expand Down Expand Up @@ -77,15 +124,15 @@ export GOOGLE_SERVICES_B64_IOS="$(base64 -w0 -i ./ios/GoogleServices/GoogleServi
In case of any doubt, please follow the instructions in the link below to get your Firebase project config file.
[Firebase Project Quickstart](https://firebaseopensource.com/projects/firebase/quickstart-js/messaging/readme/#getting_started)

#### Install dependencies
##### Install dependencies

```bash
yarn setup
```

_Not the usual install command, this will run scripts and a lengthy postinstall flow_

### Running the app
#### Running the app for native development

**Run Metro bundler**

Expand Down
5 changes: 5 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ react {
//
// The list of flags to pass to the Hermes compiler. By default is "-O", "-output-source-map"
// hermesFlags = ["-O", "-output-source-map"]
//
// Added by install-expo-modules
entryFile = file(["node", "-e", "require('expo/scripts/resolveAppEntry')", rootDir.getAbsoluteFile().getParentFile().getAbsolutePath(), "android", "absolute"].execute(null, rootDir).text.trim())
cliFile = new File(["node", "--print", "require.resolve('@expo/cli')"].execute(null, rootDir).text.trim())
bundleCommand = "export:embed"
}

// Override default React Native to generate source maps for Hermes
Expand Down
7 changes: 7 additions & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<data android:host="metamask-alternate.app.link" />
<data android:host="metamask.test-app.link" />
<data android:host="metamask-alternate.test-app.link" />
<data android:scheme="expo-metamask" />
</intent-filter>
<!-- Branch URI Scheme -->
<intent-filter>
Expand Down Expand Up @@ -114,6 +115,12 @@
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
<intent-filter>
<data android:scheme="expo-metamask" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
</intent-filter>
</activity>
<!-- Explicitly opt-in to safe browsing -->
<meta-data android:name="android.webkit.WebView.EnableSafeBrowsing" android:value="true" />
Expand Down
5 changes: 3 additions & 2 deletions android/app/src/main/java/io/metamask/MainActivity.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
package io.metamask;
import expo.modules.ReactActivityDelegateWrapper;

import com.facebook.react.ReactActivity;
import com.facebook.react.ReactActivityDelegate;
Expand Down Expand Up @@ -62,7 +63,7 @@ public void onNewIntent(Intent intent) {
*/
@Override
protected ReactActivityDelegate createReactActivityDelegate() {
return new DefaultReactActivityDelegate(this, getMainComponentName(), DefaultNewArchitectureEntryPoint.getFabricEnabled()) {
return new ReactActivityDelegateWrapper(this, BuildConfig.IS_NEW_ARCHITECTURE_ENABLED, new DefaultReactActivityDelegate(this, getMainComponentName(), DefaultNewArchitectureEntryPoint.getFabricEnabled()) {
@Override
protected Bundle getLaunchOptions() {
Bundle initialProperties = new Bundle();
Expand All @@ -73,6 +74,6 @@ protected Bundle getLaunchOptions() {
}
return initialProperties;
}
};
});
}
}
16 changes: 13 additions & 3 deletions android/app/src/main/java/io/metamask/MainApplication.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
package io.metamask;
import android.content.res.Configuration;
import expo.modules.ApplicationLifecycleDispatcher;
import expo.modules.ReactNativeHostWrapper;

import android.app.Application;
import com.facebook.react.ReactApplication;
Expand Down Expand Up @@ -37,7 +40,7 @@ public String getFileProviderAuthority() {
return BuildConfig.APPLICATION_ID + ".provider";
}

private final ReactNativeHost mReactNativeHost = new DefaultReactNativeHost(this) {
private final ReactNativeHost mReactNativeHost = new ReactNativeHostWrapper(this, new DefaultReactNativeHost(this) {
@Override
public boolean getUseDeveloperSupport() {
return BuildConfig.DEBUG;
Expand Down Expand Up @@ -68,9 +71,9 @@ protected Boolean isHermesEnabled() {

@Override
protected String getJSMainModuleName() {
return "index";
return ".expo/.virtual-metro-entry";
}
};
});

@Override
public ReactNativeHost getReactNativeHost() {
Expand Down Expand Up @@ -112,5 +115,12 @@ public void onCreate() {
}

ReactNativeFlipper.initializeFlipper(this, getReactNativeHost().getReactInstanceManager());
ApplicationLifecycleDispatcher.onApplicationCreate(this);
}

@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
ApplicationLifecycleDispatcher.onConfigurationChanged(this, newConfig);
}
}
2 changes: 1 addition & 1 deletion android/app/src/main/res/xml/react_native_config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<domain includeSubdomains="false">10.0.2.2</domain>
<domain includeSubdomains="false">10.0.3.2</domain>
</domain-config>
<base-config cleartextTrafficPermitted="false" />
<base-config cleartextTrafficPermitted="${isDebug}" />
</network-security-config>
3 changes: 3 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,6 @@ include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')
include ':react-native-video'
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')

apply from: new File(["node", "--print", "require.resolve('expo/package.json')"].execute(null, rootDir).text.trim(), "../scripts/autolinking.gradle")
useExpoModules()
23 changes: 21 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
{
"name": "MetaMask",
"displayName": "MetaMask"
}
"displayName": "MetaMask",
"plugins": [
[
"expo-build-properties",
{
"android": {
"extraMavenRepos": [
"../../node_modules/@notifee/react-native/android/libs"
]
},
"ios": {}
}
],
[
"@config-plugins/detox",
{
"subdomains": "*"
}
]
]
}
11 changes: 10 additions & 1 deletion app/components/UI/Ramp/components/PaymentMethodIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,18 @@
}
}

/*

Check warning on line 87 in app/components/UI/Ramp/components/PaymentMethodIcon.tsx

View workflow job for this annotation

GitHub Actions / scripts (lint)

Trailing spaces not allowed
* With the integration of Expo, it introduced a compatibility layer (https://github.com/expo/vector-icons)

Check warning on line 88 in app/components/UI/Ramp/components/PaymentMethodIcon.tsx

View workflow job for this annotation

GitHub Actions / scripts (lint)

Trailing spaces not allowed
* around react-native-vector-icons which doesn't expose hasIcon anymore so we need to build our own
*/
const hasIcon = (IconComponent: { glyphMap: {[key: string]: number} }, name: string) => {

Check failure on line 91 in app/components/UI/Ramp/components/PaymentMethodIcon.tsx

View workflow job for this annotation

GitHub Actions / scripts (lint)

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return IconComponent && Object.prototype.hasOwnProperty.call(IconComponent.glyphMap, name)

Check warning on line 92 in app/components/UI/Ramp/components/PaymentMethodIcon.tsx

View workflow job for this annotation

GitHub Actions / scripts (lint)

Missing semicolon
}

Check warning on line 93 in app/components/UI/Ramp/components/PaymentMethodIcon.tsx

View workflow job for this annotation

GitHub Actions / scripts (lint)

Missing semicolon

function getIcon(icon: PaymentIcon) {
const IconComponent = getIconComponent(icon);
if (IconComponent?.hasIcon(icon.name)) {

if (hasIcon(IconComponent, icon.name)) {
return IconComponent;
}
return null;
Expand Down
2 changes: 1 addition & 1 deletion babel.config.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// eslint-disable-next-line import/no-commonjs
module.exports = {
ignore: [/\/ses\.cjs/],
presets: ['module:metro-react-native-babel-preset'],
presets: ['babel-preset-expo'],
plugins: [
'transform-inline-environment-variables',
'react-native-reanimated/plugin',
Expand Down
Loading
Loading