Skip to content

Commit 4294805

Browse files
misc(sample): Add react-native-macos to bare RN sample (#3785)
1 parent ef71eb8 commit 4294805

File tree

32 files changed

+1933
-11
lines changed

32 files changed

+1933
-11
lines changed

.github/workflows/sample-application.yml

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,20 +40,26 @@ jobs:
4040
matrix:
4141
rn-architecture: ['legacy', 'new']
4242
ios-use-frameworks: ['no-frameworks', 'dynamic-frameworks']
43-
platform: ['android', 'ios']
43+
platform: ['android', 'ios', 'macos']
4444
build-type: ['dev', 'production']
4545
include:
4646
- platform: ios
4747
runs-on: macos-14 # uses m1 https://github.blog/changelog/2024-01-30-github-actions-macos-14-sonoma-is-now-available/
4848
runtime: 'latest'
4949
device: 'iPhone 14'
50+
- platform: macos
51+
runs-on: macos-14
5052
- platform: android
5153
runs-on: ubuntu-latest
5254
exclude:
5355
- platform: 'android'
5456
ios-use-frameworks: 'dynamic-frameworks'
5557
- rn-architecture: 'new'
5658
ios-use-frameworks: 'dynamic-frameworks'
59+
- rn-architecture: 'new'
60+
platform: 'macos'
61+
- ios-use-frameworks: 'dynamic-frameworks'
62+
platform: 'macos'
5763
steps:
5864
- uses: actions/checkout@v4
5965

@@ -66,7 +72,7 @@ jobs:
6672
samples/react-native/yarn.lock
6773
6874
- uses: ruby/setup-ruby@v1
69-
if: ${{ matrix.platform == 'ios' }}
75+
if: ${{ matrix.platform == 'ios' || matrix.platform == 'macos' }}
7076
with:
7177
working-directory: samples/react-native
7278
ruby-version: '3.3.0' # based on what is used in the sample
@@ -96,9 +102,12 @@ jobs:
96102
run: yarn install --frozen-lockfile
97103

98104
- name: Install App Pods
99-
if: ${{ matrix.platform == 'ios' }}
100-
working-directory: samples/react-native/ios
105+
if: ${{ matrix.platform == 'ios' || matrix.platform == 'macos' }}
106+
working-directory: samples/react-native
101107
run: |
108+
[[ "${{ matrix.platform }}" == "ios" ]] && cd ios
109+
[[ "${{ matrix.platform }}" == "macos" ]] && cd macos
110+
102111
[[ "${{ matrix.build-type }}" == "production" ]] && ENABLE_PROD=1 || ENABLE_PROD=0
103112
[[ "${{ matrix.rn-architecture }}" == "new" ]] && ENABLE_NEW_ARCH=1 || ENABLE_NEW_ARCH=0
104113
[[ "${{ matrix.ios-use-frameworks }}" == "dynamic-frameworks" ]] && export USE_FRAMEWORKS=dynamic && export NO_FLIPPER=1
@@ -138,9 +147,28 @@ jobs:
138147
| tee xcodebuild.log \
139148
| xcbeautify --quieter --is-ci --disable-colored-output
140149
150+
- name: Build macOS App
151+
if: ${{ matrix.platform == 'macos' }}
152+
working-directory: samples/react-native/macos
153+
run: |
154+
[[ "${{ matrix.build-type }}" == "production" ]] && CONFIG='Release' || CONFIG='Debug'
155+
echo "Building $CONFIG"
156+
mkdir -p "DerivedData"
157+
derivedData="$(cd "DerivedData" ; pwd -P)"
158+
set -o pipefail && xcodebuild \
159+
-workspace sentry-react-native-sample.xcworkspace \
160+
-configuration "$CONFIG" \
161+
-scheme sentry-react-native-sample-macOS \
162+
-destination 'platform=macOS' \
163+
ONLY_ACTIVE_ARCH=yes \
164+
-derivedDataPath "$derivedData" \
165+
build \
166+
| tee xcodebuild.log \
167+
| xcbeautify --quieter --is-ci --disable-colored-output
168+
141169
- name: Upload logs
142170
if: ${{ always() }}
143171
uses: actions/upload-artifact@v4
144172
with:
145173
name: build-sample-${{ matrix.rn-architecture }}-${{ matrix.platform }}-${{ matrix.build-type }}-${{ matrix.ios-use-frameworks}}-logs
146-
path: samples/react-native/ios/*.log
174+
path: samples/react-native/${{ matrix.platform }}/*.log

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"type": "node",
77
"request": "launch",
88
"runtimeArgs": ["--inspect-brk", "${workspaceRoot}/node_modules/jest/bin/jest.js"],
9-
"args": ["--runInBand", "-t", ""],
9+
"args": ["--runInBand", "-t", "gesture cancel previous interaction transaction"],
1010
"cwd": "${workspaceRoot}",
1111
"console": "integratedTerminal",
1212
"internalConsoleOptions": "neverOpen",

samples/react-native/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ DerivedData
2020
*.hmap
2121
*.ipa
2222
*.xcuserstate
23-
ios/.xcode.env.local
23+
*.xcode.env.local
2424

2525
# Android/IntelliJ
2626
#
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# CocoaPods
2+
Pods/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export NODE_BINARY=$(command -v node)

samples/react-native/macos/Podfile

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
require_relative '../node_modules/react-native-macos/scripts/react_native_pods'
2+
require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
3+
4+
prepare_react_native_project!
5+
6+
target 'sentry-react-native-sample-macOS' do
7+
platform :macos, '10.15'
8+
use_native_modules!
9+
10+
# Flags change depending on the env values.
11+
flags = get_default_flags()
12+
13+
use_react_native!(
14+
:path => '../node_modules/react-native-macos',
15+
:hermes_enabled => false,
16+
:fabric_enabled => ENV['RCT_NEW_ARCH_ENABLED'] == '1',
17+
# Flipper is not compatible w/ macOS
18+
:flipper_configuration => FlipperConfiguration.disabled,
19+
# An absolute path to your application root.
20+
:app_path => "#{Pod::Config.instance.installation_root}/.."
21+
)
22+
23+
post_install do |installer|
24+
react_native_post_install(installer)
25+
end
26+
end
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#import <RCTAppDelegate.h>
2+
#import <Cocoa/Cocoa.h>
3+
4+
@interface AppDelegate : RCTAppDelegate
5+
6+
@end
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#import "AppDelegate.h"
2+
3+
#import <React/RCTBundleURLProvider.h>
4+
5+
@implementation AppDelegate
6+
7+
- (void)applicationDidFinishLaunching:(NSNotification *)notification
8+
{
9+
self.moduleName = @"sentry-react-native-sample";
10+
// You can add your custom initial props in the dictionary below.
11+
// They will be passed down to the ViewController used by React Native.
12+
self.initialProps = @{};
13+
14+
return [super applicationDidFinishLaunching:notification];
15+
}
16+
17+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
18+
{
19+
#if DEBUG
20+
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
21+
#else
22+
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
23+
#endif
24+
}
25+
26+
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
27+
///
28+
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
29+
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
30+
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
31+
- (BOOL)concurrentRootEnabled
32+
{
33+
#ifdef RN_FABRIC_ENABLED
34+
return true;
35+
#else
36+
return false;
37+
#endif
38+
}
39+
40+
@end
2.61 KB
Loading
248 Bytes
Loading

0 commit comments

Comments
 (0)