Skip to content

Commit

Permalink
Add scripts to debug the rn-tester project easier (facebook#33386)
Browse files Browse the repository at this point in the history
Summary:
This pull request simplifies and makes it easy to debug the `rn-tester` project and switch configurations within the project.

- `yarn start` : Start packager
- `yarn install-android-jsc` : Build with `installJscDebug`.
- `yarn install-android-hermes` : Build with `installHermesDebug`.
- `yarn clean-android` : Clean up the Android build files.
- `yarn setup-ios-jsc` : Install dependencies to use JSC.
- `yarn setup-ios-hermes` : Install dependencies to use Hermes.
- `yarn clean-ios` : Clean up the build files and Pods.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Changed] - Add scripts to debug `rn-tester` easier

Pull Request resolved: facebook#33386

Test Plan:
<details><summary>Log</summary>
<p>

```sh
// packages/rn-tester

$ yarn setup-ios-jsc

yarn run v1.22.17
$ yarn install && bundle install && bundle exec pod install
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
success Already up-to-date.
Using rexml 3.2.5
Using CFPropertyList 3.0.5
Using concurrent-ruby 1.1.9
Using i18n 1.9.1
Using minitest 5.15.0
Using tzinfo 2.0.4
Using zeitwerk 2.5.4
Using activesupport 6.1.4.4
Using public_suffix 4.0.6
Using addressable 2.8.0
Using httpclient 2.8.3
Using json 2.6.1
Using algoliasearch 1.27.5
Using atomos 0.1.3
Using bundler 2.1.4
Using claide 1.1.0
Using fuzzy_match 2.0.4
Using nap 1.1.0
Using netrc 0.11.0
Using ffi 1.15.5
Using ethon 0.15.0
Using typhoeus 1.4.0
Using cocoapods-core 1.11.2
Using cocoapods-deintegrate 1.0.5
Using cocoapods-downloader 1.5.1
Using cocoapods-plugins 1.0.0
Using cocoapods-search 1.0.1
Using cocoapods-trunk 1.6.0
Using cocoapods-try 1.2.0
Using colored2 3.1.2
Using escape 0.0.4
Using fourflusher 2.3.1
Using gh_inspector 1.1.3
Using molinillo 0.8.0
Using ruby-macho 2.5.1
Using nanaimo 0.3.0
Using xcodeproj 1.21.0
Using cocoapods 1.11.2
Bundle complete! 2 Gemfile dependencies, 38 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Building RNTester with Fabric enabled.
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Building RNTester with Fabric enabled.
[Codegen] Skipping React-Codegen podspec generation.
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Building RNTester with Fabric enabled.
[Codegen] Skipping React-Codegen podspec generation.
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Analyzing dependencies
[Codegen] Found FBReactNativeSpec
[Codegen] Found rncore
[Codegen] Found ScreenshotmanagerSpec
Downloading dependencies
Installing FBLazyVector 1000.0.0
Installing FBReactNativeSpec 1000.0.0
Installing RCTRequired 1000.0.0
Installing RCTTypeSafety 1000.0.0
Installing React 1000.0.0
Installing React-Core 1000.0.0
Installing React-CoreModules 1000.0.0
Installing React-Fabric 1000.0.0
Installing React-RCTActionSheet 1000.0.0
Installing React-RCTAnimation 1000.0.0
Installing React-RCTBlob 1000.0.0
Installing React-RCTFabric 1000.0.0
Installing React-RCTImage 1000.0.0
Installing React-RCTLinking 1000.0.0
Installing React-RCTNetwork 1000.0.0
Installing React-RCTPushNotification 1000.0.0
Installing React-RCTSettings 1000.0.0
Installing React-RCTTest 1000.0.0
Installing React-RCTText 1000.0.0
Installing React-RCTVibration 1000.0.0
Installing React-callinvoker 1000.0.0
Installing React-cxxreact 1000.0.0
Installing React-graphics 1000.0.0
Installing React-jsi 1000.0.0
Installing React-jsiexecutor 1000.0.0
Installing React-jsinspector 1000.0.0
Installing React-logger 1000.0.0
Installing React-perflogger 1000.0.0
Installing React-rncore 1000.0.0
Installing React-runtimeexecutor 1000.0.0
Installing ReactCommon 1000.0.0
Installing Yoga 1.14.0
Generating Pods project
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTester/Pods-RNTester.release.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTester/Pods-RNTester.debug.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.release.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.debug.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.release.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.debug.xcconfig
React-Core
Integrating client project
Pod installation complete! There are 65 dependencies from the Podfile and 53 total pods installed.
✨  Done in 8.68s.
```

</p>
</details>

Reviewed By: ShikaSD

Differential Revision: D34835086

Pulled By: cortinico

fbshipit-source-id: 83649f42e8ac77efd8617601e18f15bfcf8f1f61
  • Loading branch information
ken0nek authored and Saadnajmi committed Jan 14, 2023
1 parent d7062dd commit 4419067
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
18 changes: 8 additions & 10 deletions packages/rn-tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Before running the app, make sure you ran:

### Running on iOS

If you are testing non-fabric component, modify [the fabric_enabled flag in RNTester's Podfile](https://github.com/facebook/react-native/blob/main/packages/rn-tester/Podfile#L21).
If you are testing non-fabric component, modify [the fabric_enabled flag in RNTester's Podfile](https://github.com/facebook/react-native/blob/main/packages/rn-tester/Podfile#L24).

```ruby
fabric_enabled = false
Expand All @@ -21,18 +21,16 @@ fabric_enabled = false
Also, if you previously built RNTester with fabric enabled, you might need to clean up the build files and Pods.
```sh
# Clean the generated files and folders to clean install RNTester
cd packages/rn-tester/
rm -rf build/generated/ios
rm -rf Pods
rm Podfile.lock
cd packages/rn-tester
yarn clean-ios
```

If you are still having a problem after doing the clean up (which can happen if you have built RNTester with older React Native versions where files were generated inside the react-native folder.), the best way might be to clean-install react-native (e.g. remove node_modules and yarn install).

Both macOS and Xcode are required.
1. `cd packages/rn-tester`
1. Install [Bundler](https://bundler.io/): `gem install bundler`. We use bundler to install the right version of [CocoaPods](https://cocoapods.org/) locally.
1. Install Bundler and CocoaPods dependencies: `bundle install && bundle exec pod install`. In order to use Hermes engine instead of JSC, run: `USE_HERMES=1 bundle exec pod install` instead.
1. Install Bundler and CocoaPods dependencies: `bundle install && bundle exec pod install` or `yarn setup-ios-jsc`. In order to use Hermes engine instead of JSC, run: `USE_HERMES=1 bundle exec pod install` or `yarn setup-ios-hermes` instead.
1. Open the generated `RNTesterPods.xcworkspace`. This is not checked in, as it is generated by CocoaPods. Do not open `RNTesterPods.xcodeproj` directly.

#### Note for M1 users
Expand All @@ -48,10 +46,10 @@ You'll need to have all the [prerequisites](https://github.com/facebook/react-na
Start an Android emulator.

```sh
cd react-native
# In order to use Hermes engine, run `installHermesDebug` instead.
./gradlew :packages:rn-tester:android:app:installJscDebug
./scripts/packager.sh
cd packages/rn-tester
# In order to use Hermes engine, run `yarn install-android-hermes` instead.
yarn install-android-jsc
yarn start
```

_Note: Building for the first time can take a while._
Expand Down
9 changes: 9 additions & 0 deletions packages/rn-tester/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
"url": "git@github.com:facebook/react-native.git",
"directory": "packages/rn-tester"
},
"scripts": {
"start": "../../scripts/packager.sh",
"install-android-jsc": "../../gradlew :packages:rn-tester:android:app:installJscDebug",
"install-android-hermes": "../../gradlew :packages:rn-tester:android:app:installHermesDebug",
"clean-android": "rm -rf android/app/build",
"setup-ios-jsc": "bundle install && bundle exec pod install",
"setup-ios-hermes": "bundle install && USE_HERMES=1 bundle exec pod install",
"clean-ios": "rm -rf build/generated/ios && rm -rf Pods && rm Podfile.lock"
},
"dependencies": {
"invariant": "^2.2.4",
"nullthrows": "^1.1.1"
Expand Down

0 comments on commit 4419067

Please sign in to comment.