fixes#16310
We used to reply on `react-native cli` and would pass a `--device` flag to deploy the debug variant of `iOS` app on connected `iPhone`.
`react-native cli` under the hood uses `ios-deploy` library to achieve this functionality.
This showed many weird issues, specifically in locating connected devices and failures at build step with ambiguous error messages.
This commit fixes it by using our custom script `run-ios-devices.sh` which does not rely on `ios-deploy`.
We use `libimobiledevice` to identify `UDID` of a connected `iPhone`.
We use `xcrun devicectl device install app` and `xcrun devicectl device process launch` to install and launch the app.
This works well with `Xcode 15` and `iOS 17.x`.
We can now remove `ios-deploy` from `iOS` shell and `nix` overlay.
We also set up a logs folder and add a Readme.
## Review notes
- connect your iPhone to your Laptop via a cable
- `make run-clojure`
- `make run-ios-device`
(note: no need to pass device name now)
## Platforms
- iOS
## Summary
Improve iOS Simulator selection via `make run-ios` command.
Currently : `make run-ios SIMULATOR="iPhone SE (3rd generation)"` would fail because of our scripts inability to deal with this kind of a pattern.
This commit fixes that and makes this script more robust by storing output of `xcrun simctl list devices` in a json file `ios_simulators_list.json` and then using `jq` to properly get `UDIDs` of those simulators.
This script will now also prompt you to download a simulator image if you do not already have it.
The file `ios_simulators_list.json` will also help in future debugging when we want to check a quick summary of iOS simulator status of devs in the future.
We also append `-verbose` to `xcodebuild` for debug `iOS` builds, this helps debugging.
## Review notes
try such options -> `make run-ios SIMULATOR="iPhone SE (3rd generation)"`
## Platform
- iOS
`make run-android` would fail for connected Android devices because the android device was not able to talk to metro bundler.
This was discovered by @J-Son89
This was easily fixed by reverse tcping port 8081.
## Review notes
connect Android device by USB or Wifi
- `make run-clojure`
- `make run-android`
status app must run without any errors on the connected Android device.
we also replace during install on emulator.
otherwise on old emulators `make run-android` fails with :
```
adb: failed to install ./result/app-debug.apk: Failure [INSTALL_FAILED_ALREADY_EXISTS: Attempt to re-install im.status.ethereum.debug without first uninstalling.]
```
fixes#18888
## Summary
`make run-android` was sometimes flaky because we used to send metro to background via `nohup` and then bring it back to foreground after we read metro logs.
Now we do not send metro to background. We first wait for a successful build.
we then install the app on the simulator. After this is done we give command to sleep until metro server has started, Once metro server has started we open the installed app.
In this workflow the command to open the installed app goes in background and metro stays in foreground.
The new workflow should now be less flaky.
## Review notes
`make run-clojure`
`make run-android` OR `make run-ios` should just work
#### Platforms
- Android
- iOS
fixes#18836
## Summary
While introducing https://github.com/status-im/status-mobile/pull/18784 I missed out on adding an install step to `run-ios.sh` script.
`make run-ios` would work fine for simulators that already have the app installed but would fail for new emulators.
@flexsurfer discovered this problem.
This commit fixes that by adding an install step to the script.
## Review notes
- `make run-clojure`
- `make run-ios`
should just work.
## Platforms
- iOS
fixes#18831
We update the nix derivation to build android by passing `hermesEnabled` flag which checks the environment variable and if the environment variable is not set we default `hermesEnabled` to `true`.
This ensures that `hermes` is disabled for debug builds and enabled for release builds.
In this commit we also
- rename `nix/mobile/android/release.nix` → `nix/mobile/android/build.nix` since that nix file no longer generates release only builds.
- cleanup 2 other env vars and use the `gradle` project format
- replace `BUILD_NUMBER` with `verisonCode` for consistency
- replace `androidGradleOpts ` with `buildUrl `
- bump `status-jenkins-lib` to v1.8.7
After upgrading `react-native` to `0.72.5` we frequently started seeing the _red screen of death_ on both `Android` and `iOS` simulators right after the app was built and installed.
This used to happen because our workflow required us to do the following :
- `make run-clojure`
- `make run-metro`
- `make run-ios` OR `make run-android`
The problem with this approach was after `metro` was started the `iOS`, `Android` build step would change the files that `metro` couldn't handle and hence metro would go out of sync.
The quick fix back then was to restart `metro` terminal and to open the app again from the simulator.
This was however not a good DX.
This commit fixes that.
We no longer rely on `react-native` cli to generate and deploy debug builds on simulators. We take control of the process via our own script. The new workflow introduced in this commit will first build the app, then install the app on the simulators and then start metro terminal. When `metro` is successfully running the script will then open the app.
The new workflow now is :
- `make run-clojure`
- `make run-ios` OR `make run-android`
This commit adds support for the Sepolia test network and Rarible collectible/collection provider.
---------
Signed-off-by: Mohamed Javid <19339952+smohamedjavid@users.noreply.github.com>
The native module : `react-native-status` has always been 1 big fat file per platform which contained all of the native modules.
In case of Android it was `StatusModule.java`
This commit modularises it & attempts to thin out this 1 big file into these categories:
- `AccountManager.java`
- `EncryptionUtils.java`
- `DatabaseManager.java`
- `UIHelper.java`
- `LogManager.java`
- `NetworkManager.java`
- `Utils.java`
In case of iOS it was `RCTStatus.m`
This commit modularises it & attempts to thin out this 1 big file into these categories:
- `AccountManager.m`
- `EncryptionUtils.m`
- `DatabaseManager.m`
- `UIHelper.m`
- `LogManager.m`
- `NetworkManager.m`
- `Utils.m`
In this commit we also remove a lot of unused native code which has no reference on cljs side.
Fix all component tests after the latest RN upgrade.
Fixes https://github.com/status-im/status-mobile/issues/18157
Closes https://github.com/status-im/status-mobile/pull/18235
Dependency changes
- Upgraded Jest: from 26.6.3 to latest 29.7.0.
- Upgraded @testing-library/jest-native: from 5.3.0 to latest 5.4.3
- Upgraded @testing-library/react-native: from 11.5.4 to 12.4.2
- Removed explicit dependency on jest-circus, this is now the default test
runner.
- Removed explicit dependency on jest-environment-node. This is handled by the
package manager.
- Added jest-silent-reporter at version 0.5.0.
### Why component tests were failing?
Many tests were failing because we were using RN Testing Library (RNTL) in an
unreliable fashion. With the recent library upgrades, the unreliability was
excerbated. Other times, the tests were incorrectly arranging data.
### with-redefs does not work with async code
Generally speaking, with-redefs should not be used with async code, assume the
worst. The scope of the macro will cease to exist by the time the async code
runs. In many tests we were using with-redefs, then calling render, but for some
components that use use-effect, JS timers, animations, etc it's unreliable and
were the reason for failures.
It's easy to reproduce too:
```clojure
(defn foo []
:foo)
(foo)
;; => :foo
(with-redefs [foo (constantly :bar)]
(foo))
;; => :bar
(js/setTimeout
(fn []
(tap> [:calling-foo (foo)]))
100)
;; Taps [:calling-foo :foo]
;; As you would expect, when running without with-redefs, it prints :foo.
;; So far so good, but whatch what happens with async code:
(with-redefs [foo (constantly :bar)]
(js/setTimeout
(fn []
(tap> [:calling-foo (foo)]))
100))
;; Taps [:calling-foo :foo]
;; ====> PROBLEM: Taps :foo, not :bar as one might expect
```
### Not waiting on wait-for
When test-helpers.component/wait-for is used, subsequent assertions/etc should
be done after the promise returned by wait-for is resolved. But remember to not
perform side-effects inside the wait-for callback (check out the docs
https://callstack.github.io/react-native-testing-library/docs/api#waitfor).
Most, if not all of our usages of wait-for were not waiting.
#### Improvement 1 - Silence Jest on demand
If you need to re-run component tests frequently, you may want to reduce the
output verbosity. By passing JEST_USE_SILENT_REPORTER=true to make
component-test or make component-test-watch you will see a lot less noise and be
able to focus on what really matters to you.
#### Improvement 2 - Selectively focus/disable tests
Because of our need to first compile CLJS to JS before running tests via Jest,
we couldn't easily skip or focus on specific tests. From this commit onwards, we
should never again have to change the list of requires in files core_spec.cljs.
Commenting out required namespaces gives a bad DX because it causes constant
rebasing issues.
#### Improvement 3 - Translations now work as in prod code (but only English)
Translations performed by *-by-translation-text can be done now without any
workaround under the hood. The query functions are now linted just like
i18n/label, which means static translation keywords must be qualified with :t/,
which is good for consistency.
This commit does many things :
- Upgrade `react-native ` to `0.72.5`
- Upgrade `react-native-reanimated` to `3.5.4`
- Upgrade `react-native-navigation` to `7.37.0`
- `ndkVersion` has been bumped to `25.2.9519653`
- `cmakeVersion` has been bumped to `3.22.1`
- `kotlinVersion` has been bumped to `1.7.22`
- `AGP` has been bumped to `7.4.2`
- `Gradle` has been upgraded to `8.0.1`
- Android `CompileSDK` and `TargetSDK` have been bumped to 33
- `@react-native-async-storage/async-storage` has been upgraded to `1.19.3`
- `@walletconnect/client` has been nuked
- some of the old `react-native-reanimated` code has been nuked
- `react-native-keychain` fork has been replaced with `8.1.2`
- On Android we are currently relying on `Hermes` Engine.
- On iOS we are currently relying on `JSC`
- We are not enabling new architecture for now (I have plans for that in the future) ref: https://github.com/status-im/status-mobile/issues/18138
IOS only PR : https://github.com/status-im/status-mobile/pull/16721
Android only PR : https://github.com/status-im/status-mobile/pull/17062
- `make run-metro` now has a target of `android` which was `clojure` earlier, this will increase the time it takes to start metro terminal but this is needed otherwise you will get a nasty error while developing for android locally.
Many times devs run
`make component-test` or `make component-test-watch` when there is already a metro or clojure terminal running on their system.
This causes weird behaviour and it is advised to not run these commands together.
This commit prevents that and shows a warning.
We've often seen cases of devs attempting to change dependencies outside a nix-shell and run into weird side effects
This commit stops them from :
- updating pods outside a nix shell
- updating node deps outside a nix shell
This commit also cleanup unused scripts in package.json and adds a fake comment script.
Otherwise it fails early and doesn't work for branches.
I also refactored it a bit so the `pipefail` disbaling is local.
Signed-off-by: Jakub Sokołowski <jakub@status.im>
For an unknown reason the original Diawi plugin for Fastlane has been
removed from GitHub and RubyGems pages and can no longer be used.
This replaces it with a Node.js script which does the same job.
I tried using `diawi` and `diawi-nodejs-uploader` but both had issues,
one of them being depending on far too many useless packages.
Resolves: https://github.com/status-im/status-mobile/issues/15951
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This is no longer necessary as we sign APKs in a separate step using the
`scripts/sign-android.sh` script, and this causes issues for F-Droid builds.
Signed-off-by: Jakub Sokołowski <jakub@status.im>
Some systems don't have jq installed, and using something like
`nix-shell` in the shebang would make this script noticeably slower.
We're not using `grep` because it lacks `-P` flag on MacOS.
Resolves: https://github.com/status-im/status-mobile/issues/13322
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This passing of Watchman socket was implemented in order to avoid this:
```
Error: EMFILE: too many open files, watch
at FSEvent.FSWatcher._handle.onchange (node:internal/fs/watchers:204:21)
Emitted 'error' event on NodeWatcher instance at:
at NodeWatcher.checkedEmitError (/private/tmp/nix-build-status-mobile-build-nightly-android.drv-0/node_modules/sane/src/node_watcher.js:143:12)
at FSWatcher.emit (node:events:527:28)
at FSEvent.FSWatcher._handle.onchange (node:internal/fs/watchers:210:12) {
errno: -24,
syscall: 'watch',
code: 'EMFILE',
filename: null
}
```
Which is caused by `jest-haste-map` used by `metro` starting to watch
the filesystem for file changes, which is pointless when doing a
one-off build using Nix.
But by setting `CI=true` we can make `metro` not start this waching of
files in the first place, removing the need for use of Watchman entirely.
By entirely dropping use of Watchman we also fix the following issue:
```
[cli] unable to talk to your watchman on /tmp/tmp-status-mobile-ABC/jenkins-state/sock! (Permission denied)
```
Which happens on multi-user Nix installations becuase the user that the
Nix build is executed as is not the same as the user that starts
Watchman and creates the socket file.
Issue: https://github.com/status-im/status-mobile/issues/13783
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This way the name of the repo makes at least some sense and
matches the `status-desktop` repo naming.
Also updated `status-jenkins-lib` since it also contained
references to `status-react` repo and job names.
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This has several benefits:
* Less abuse of `extra-sandbox-paths` Nix option
* Less inputs to the Android release build derivation
* Easier for users to sign the build themselves
* Simplification of `scripts/release-android.sh`
* Preparation for building using Nix Flakes
The only two remaining credentials passed via `extra-sandbox-paths` is
the Infura and OpenSea API keys, and there is no way around that other
than passing them via Nix arguments, but that would cause them to end up
in `/nix/store` as part of `.drv` files.
I'm also renaming `release-fdroid` to `build-fdroid` to be consistent.
Depends on: https://github.com/status-im/status-jenkins-lib/pull/42
Signed-off-by: Jakub Sokołowski <jakub@status.im>