Skip to content

Commit

Permalink
Added support for macos (oblador#490)
Browse files Browse the repository at this point in the history
* added macos example project

* added support of macos

* added command to run macos

* updated readme

* fixed jsbundle script

* fixed null pointer in dict
  • Loading branch information
bomjkolyadun authored Oct 2, 2021
1 parent 9624055 commit 45a78a2
Show file tree
Hide file tree
Showing 25 changed files with 2,080 additions and 8 deletions.
18 changes: 18 additions & 0 deletions KeychainExample/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,24 @@ cd ..
react-native run-ios
```

## macOS

To run the app on macOS starting from the KeychainExample folder execute
the following commands:

```bash
cd macos

# verify updates: pod install --clean-install --repo-update --deployment
# forced updates: pod install --clean-install --repo-update
#
# Or regular usage:
pod install

cd ..
react-native run-macos
```

## Android

just run
Expand Down
2 changes: 2 additions & 0 deletions KeychainExample/macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CocoaPods
Pods/
9 changes: 9 additions & 0 deletions KeychainExample/macos/KeychainExample-macOS/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#import <Cocoa/Cocoa.h>

@class RCTBridge;

@interface AppDelegate : NSObject <NSApplicationDelegate>

@property (nonatomic, readonly) RCTBridge *bridge;

@end
32 changes: 32 additions & 0 deletions KeychainExample/macos/KeychainExample-macOS/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>

@interface AppDelegate () <RCTBridgeDelegate>

@end

@implementation AppDelegate

- (void)awakeFromNib {
[super awakeFromNib];

_bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:nil];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
}

- (void)applicationWillTerminate:(NSNotification *)aNotification {
// Insert code here to tear down your application
}

#pragma mark - RCTBridgeDelegate Methods

- (NSURL *)sourceURLForBridge:(__unused RCTBridge *)bridge {
return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:@"main"]; // .jsbundle;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"images" : [
{
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
717 changes: 717 additions & 0 deletions KeychainExample/macos/KeychainExample-macOS/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions KeychainExample/macos/KeychainExample-macOS/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>localhost</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
</dict>
</dict>
</dict>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSSupportsAutomaticTermination</key>
<true/>
<key>NSSupportsSuddenTermination</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
5 changes: 5 additions & 0 deletions KeychainExample/macos/KeychainExample-macOS/ViewController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>

@interface ViewController : NSViewController

@end
22 changes: 22 additions & 0 deletions KeychainExample/macos/KeychainExample-macOS/ViewController.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#import "ViewController.h"
#import "AppDelegate.h"

#import <React/RCTRootView.h>

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];

RCTBridge *bridge = [((AppDelegate *)[NSApp delegate])bridge];
RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:@"KeychainExample" initialProperties:nil];

NSView *view = [self view];

[view addSubview:rootView];
[rootView setBackgroundColor:[NSColor windowBackgroundColor]];
[rootView setFrame:[view bounds]];
[rootView setAutoresizingMask:(NSViewMinXMargin | NSViewMinXMargin | NSViewMinYMargin | NSViewMaxYMargin | NSViewWidthSizable | NSViewHeightSizable)];
}

@end
5 changes: 5 additions & 0 deletions KeychainExample/macos/KeychainExample-macOS/main.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#import <Cocoa/Cocoa.h>

int main(int argc, const char *argv[]) {
return NSApplicationMain(argc, argv);
}
Loading

0 comments on commit 45a78a2

Please sign in to comment.