Skip to content

Commit 1d29292

Browse files
committed
feat(macos): add react-native-macos demo app
1 parent 56c804e commit 1d29292

27 files changed

+5023
-3063
lines changed

examples/demo/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ yarn-error.log
5757

5858
# Ruby / CocoaPods
5959
/ios/Pods/
60+
/macos/Pods/
6061
/vendor/bundle/
6162

6263
# Temporary files created by Metro to check the health of the file watcher

examples/demo/README.md

+27-13
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,39 @@
22

33
![Demo](demo.gif)
44

5-
## Running the iOS app
5+
## Running the example apps
66

77
After cloning the repository, run the following:
88

99
```sh
1010
cd react-native-app-auth/Example
1111
yarn
12-
(cd ios && pod install)
13-
npx react-native run-ios
14-
```
15-
16-
## Running the Android app
17-
18-
After cloning the repository, run the following:
19-
20-
```sh
21-
cd react-native-app-auth/Example
22-
yarn
23-
npx react-native run-android
12+
# Install the pods for the iOS example app
13+
cd ios && pod install
14+
# Install the pods for the macOS example app
15+
cd macos && pod install
16+
17+
# From here on, you'll need two terminals.
18+
19+
# [In terminal A]
20+
# Start the Metro bundler
21+
yarn start
22+
23+
# [In terminal B]
24+
# Run the iOS app
25+
yarn ios
26+
27+
# or:
28+
# Run the Android app
29+
yarn android
30+
31+
# or:
32+
# Run the macOS app (after setting `applePlatform = "macos"` in metro.config.js)
33+
#
34+
# Note that we do not currently support running the macOS demo simultaneously
35+
# with iOS or Android apps, as we use the `applePlatform = "macos"` flag to
36+
# force Metro to resolve react-native-macos instead of react-native.
37+
yarn macos
2438
```
2539

2640
### Notes
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

examples/demo/macos/.xcode.env

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export NODE_BINARY=$(command -v node)

examples/demo/macos/.xcode.env.local

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export NODE_BINARY=/Users/jamie/.volta/tools/image/node/20.7.0/bin/node
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#import <Cocoa/Cocoa.h>
2+
#import <RCTAppDelegate.h>
3+
#import <React/RCTLinkingManager.h>
4+
#import "RNAppAuthAuthorizationFlowManager.h"
5+
6+
@interface AppDelegate : RCTAppDelegate <RNAppAuthAuthorizationFlowManager>
7+
8+
@property(nonatomic, weak) id<RNAppAuthAuthorizationFlowManagerDelegate>
9+
authorizationFlowManagerDelegate;
10+
11+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#import "AppDelegate.h"
2+
3+
#import <React/RCTBundleURLProvider.h>
4+
#import <React/RCTLinkingManager.h>
5+
6+
@implementation AppDelegate
7+
8+
- (void)applicationDidFinishLaunching:(NSNotification *)notification
9+
{
10+
self.moduleName = @"Example";
11+
// You can add your custom initial props in the dictionary below.
12+
// They will be passed down to the ViewController used by React Native.
13+
self.initialProps = @{};
14+
15+
return [super applicationDidFinishLaunching:notification];
16+
}
17+
18+
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
19+
[[NSAppleEventManager sharedAppleEventManager] setEventHandler:self
20+
andSelector:@selector(getURL:withReplyEvent:)
21+
forEventClass:kInternetEventClass
22+
andEventID:kAEGetURL];
23+
}
24+
25+
- (void)getURL:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)reply
26+
{
27+
NSString* urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
28+
NSURL *url = [NSURL URLWithString:urlString];
29+
30+
if ([self.authorizationFlowManagerDelegate resumeExternalUserAgentFlowWithURL:url]) {
31+
return;
32+
}
33+
34+
[RCTLinkingManager getUrlEventHandler:event withReplyEvent:reply];
35+
}
36+
37+
- (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
38+
{
39+
#if DEBUG
40+
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index"];
41+
#else
42+
return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
43+
#endif
44+
}
45+
46+
/// This method controls whether the `concurrentRoot`feature of React18 is turned on or off.
47+
///
48+
/// @see: https://reactjs.org/blog/2022/03/29/react-v18.html
49+
/// @note: This requires to be rendering on Fabric (i.e. on the New Architecture).
50+
/// @return: `true` if the `concurrentRoot` feature is enabled. Otherwise, it returns `false`.
51+
- (BOOL)concurrentRootEnabled
52+
{
53+
#ifdef RN_FABRIC_ENABLED
54+
return true;
55+
#else
56+
return false;
57+
#endif
58+
}
59+
60+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "mac",
5+
"scale" : "1x",
6+
"size" : "16x16"
7+
},
8+
{
9+
"idiom" : "mac",
10+
"scale" : "2x",
11+
"size" : "16x16"
12+
},
13+
{
14+
"idiom" : "mac",
15+
"scale" : "1x",
16+
"size" : "32x32"
17+
},
18+
{
19+
"idiom" : "mac",
20+
"scale" : "2x",
21+
"size" : "32x32"
22+
},
23+
{
24+
"idiom" : "mac",
25+
"scale" : "1x",
26+
"size" : "128x128"
27+
},
28+
{
29+
"idiom" : "mac",
30+
"scale" : "2x",
31+
"size" : "128x128"
32+
},
33+
{
34+
"idiom" : "mac",
35+
"scale" : "1x",
36+
"size" : "256x256"
37+
},
38+
{
39+
"idiom" : "mac",
40+
"scale" : "2x",
41+
"size" : "256x256"
42+
},
43+
{
44+
"idiom" : "mac",
45+
"scale" : "1x",
46+
"size" : "512x512"
47+
},
48+
{
49+
"idiom" : "mac",
50+
"scale" : "2x",
51+
"size" : "512x512"
52+
}
53+
],
54+
"info" : {
55+
"author" : "xcode",
56+
"version" : 1
57+
}
58+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"info" : {
3+
"author" : "xcode",
4+
"version" : 1
5+
}
6+
}

0 commit comments

Comments
 (0)