Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

macOS Support #2588

Merged
merged 56 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
55df064
add support for osx pan gesture.
HeroBanana Sep 14, 2023
79df1b2
add macos example project.
HeroBanana Sep 14, 2023
d508cc6
add support for yarn berry
HeroBanana Sep 14, 2023
9b3e011
add support for osx pinch and rotation gestures.
HeroBanana Sep 14, 2023
275ff2c
add support for tap gesture.
HeroBanana Sep 14, 2023
8aa2eef
make root view gesture simpeler.
HeroBanana Sep 14, 2023
3053c75
fix yarn.lock
jfedak Oct 24, 2023
ec1baa2
fix MacOSExample
jfedak Oct 24, 2023
78885f3
Fix pan gesture example
jfedak Oct 24, 2023
59109d9
Refactor apple handlers
jfedak Oct 24, 2023
f53aff2
Refactor v2
jfedak Oct 24, 2023
5af5002
Fix ios build
jfedak Oct 26, 2023
ee67ef2
correct pragma mark definition.
HeroBanana Oct 26, 2023
c117347
Fix macos
jfedak Nov 3, 2023
ea23d45
Add stack to macos example
jfedak Nov 3, 2023
34879b3
Merge remote-tracking branch 'upstream/main'
jfedak Nov 3, 2023
46ff275
Merge remote-tracking branch 'upstream/main'
jfedak Nov 8, 2023
b6aba91
Fix ios
jfedak Nov 8, 2023
6564d35
Add previous examples
jfedak Nov 8, 2023
63c98f6
refactor
jfedak Nov 10, 2023
500c90f
Fix activePointers counter
jfedak Nov 16, 2023
338d11b
Fix and run format:ios
jfedak Nov 16, 2023
c4ff6f8
Change ios to apple in paths
jfedak Nov 16, 2023
d790959
Delete ios and android directories in macOS example app
jfedak Nov 16, 2023
bc2e4ae
Clean babel config
jfedak Nov 16, 2023
f870f30
Add macos CI
jfedak Nov 24, 2023
5272362
Fix not supported handlers
jfedak Nov 24, 2023
a1385b1
Refactor macos specific code
jfedak Nov 24, 2023
1424b0a
Add tap example
jfedak Nov 24, 2023
4c7a91d
Refactor pinch handler
jfedak Nov 24, 2023
0e00c6f
Unify prettier file
jfedak Nov 24, 2023
ba09d00
Fix pan handler
jfedak Nov 24, 2023
f31b5de
Delete useless method
jfedak Nov 24, 2023
f74a0cf
Fix number of pointers
jfedak Nov 24, 2023
4ca19fa
Fix super call in pan handler
jfedak Nov 24, 2023
554a7e2
Add warnings for handlers not supported on mac
jfedak Nov 24, 2023
382e9b6
Invert rotation direction in example app
jfedak Nov 24, 2023
9a7bd69
Fix macos warnings
jfedak Nov 24, 2023
fecaca8
Fix colors in dark mode
jfedak Nov 28, 2023
fe9350e
Remove tvos changes
jfedak Nov 28, 2023
7e62647
Delete macos CI
jfedak Nov 28, 2023
76af355
Merge remote-tracking branch 'upstream/main'
jfedak Nov 28, 2023
0fba2e1
Fix warnings
jfedak Nov 28, 2023
b8a5055
Add macos CI v2
jfedak Nov 28, 2023
6dd46d3
Add workflow_dispatch to macos CI
jfedak Nov 29, 2023
fbaedc3
Fix pragma mark
jfedak Nov 29, 2023
4027027
Put setMinimumNumberOfTouches method inside if statement
jfedak Nov 29, 2023
38731f7
Warnings v2
jfedak Dec 6, 2023
c672092
Add endif comments
jfedak Dec 6, 2023
1e98aff
Add super call comments
jfedak Dec 6, 2023
ce878e2
Put pointinside and hittest inside conditional
jfedak Dec 6, 2023
fabc8aa
Delete ScrollView from tap example
jfedak Dec 6, 2023
9812017
Update readme in macos example app
jfedak Dec 13, 2023
f19f26d
Fix linter for macos example app
jfedak Dec 13, 2023
a683261
Add some newlines
jfedak Dec 13, 2023
52b9d48
Merge remote-tracking branch 'upstream/main'
jfedak Dec 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ios-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
paths:
- '.github/workflows/ios-build.yml'
- 'RNGestureHandler.podspec'
- 'ios/**'
- 'apple/**'
- 'Example/ios/**'
- 'FabricExample/ios/**'
push:
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/macos-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Test macOS build
on:
pull_request:
paths:
- '.github/workflows/macos-build.yml'
- 'RNGestureHandler.podspec'
- 'apple/**'
- 'MacOSExample/macos/**'
push:
branches:
- main
jfedak marked this conversation as resolved.
Show resolved Hide resolved
jobs:
build:
runs-on: macos-12
strategy:
matrix:
working-directory: [MacOSExample]
concurrency:
group: macos-${{ matrix.working-directory }}-${{ github.ref }}
cancel-in-progress: true
steps:
- name: checkout
uses: actions/checkout@v2
- name: Use Node.js 16
uses: actions/setup-node@v2
with:
node-version: 16
cache: 'yarn'
- name: Install node dependencies
working-directory: ${{ matrix.working-directory }}
run: yarn
- name: Install pods
working-directory: ${{ matrix.working-directory }}/macos
run: pod install
- name: Build app
working-directory: ${{ matrix.working-directory }}
run: yarn macos
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ jsconfig.json
.settings/
.vscode

# Yarn
.yarn
!.yarn/releases

# TS
dist/

Expand Down
2 changes: 2 additions & 0 deletions MacOSExample/.bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
BUNDLE_PATH: "vendor/bundle"
BUNDLE_FORCE_RUBY_PLATFORM: 1
4 changes: 4 additions & 0 deletions MacOSExample/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
root: true,
extends: '@react-native',
};
66 changes: 66 additions & 0 deletions MacOSExample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
ios/.xcode.env.local

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml
*.hprof
.cxx/
*.keystore
!debug.keystore

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

**/fastlane/report.xml
**/fastlane/Preview.html
**/fastlane/screenshots
**/fastlane/test_output

# Bundle artifact
*.jsbundle

# Ruby / CocoaPods
/ios/Pods/
/vendor/bundle/

# Temporary files created by Metro to check the health of the file watcher
.metro-health-check*

# testing
/coverage
8 changes: 8 additions & 0 deletions MacOSExample/.prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"bracketSameLine": true,
"printWidth": 80,
"tabWidth": 2,
"semi": true,
"singleQuote": true,
"trailingComma": "es5"
}
1 change: 1 addition & 0 deletions MacOSExample/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
3 changes: 3 additions & 0 deletions MacOSExample/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nmMode: hardlinks-global

nodeLinker: node-modules
6 changes: 6 additions & 0 deletions MacOSExample/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source 'https://rubygems.org'

# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version
ruby ">= 2.6.10"

gem 'cocoapods', '~> 1.12'
98 changes: 98 additions & 0 deletions MacOSExample/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (3.0.6)
rexml
activesupport (7.0.8)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
addressable (2.8.5)
public_suffix (>= 2.0.2, < 6.0)
algoliasearch (1.27.5)
httpclient (~> 2.8, >= 2.8.3)
json (>= 1.5.1)
atomos (0.1.3)
claide (1.1.0)
cocoapods (1.12.1)
addressable (~> 2.8)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.12.1)
cocoapods-deintegrate (>= 1.0.3, < 2.0)
cocoapods-downloader (>= 1.6.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.6.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (>= 2.3.0, < 3.0)
gh_inspector (~> 1.0)
molinillo (~> 0.8.0)
nap (~> 1.0)
ruby-macho (>= 2.3.0, < 3.0)
xcodeproj (>= 1.21.0, < 2.0)
cocoapods-core (1.12.1)
activesupport (>= 5.0, < 8)
addressable (~> 2.8)
algoliasearch (~> 1.0)
concurrent-ruby (~> 1.1)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
netrc (~> 0.11)
public_suffix (~> 4.0)
typhoeus (~> 1.0)
cocoapods-deintegrate (1.0.5)
cocoapods-downloader (1.6.3)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.1)
cocoapods-trunk (1.6.0)
nap (>= 0.8, < 2.0)
netrc (~> 0.11)
cocoapods-try (1.2.0)
colored2 (3.1.2)
concurrent-ruby (1.2.2)
escape (0.0.4)
ethon (0.16.0)
ffi (>= 1.15.0)
ffi (1.15.5)
fourflusher (2.3.1)
fuzzy_match (2.0.4)
gh_inspector (1.1.3)
httpclient (2.8.3)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
minitest (5.20.0)
molinillo (0.8.0)
nanaimo (0.3.0)
nap (1.1.0)
netrc (0.11.0)
public_suffix (4.0.7)
rexml (3.2.6)
ruby-macho (2.5.1)
typhoeus (1.4.0)
ethon (>= 0.9.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
xcodeproj (1.22.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.3.0)
rexml (~> 3.2.4)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (~> 1.12)

RUBY VERSION
ruby 3.0.0p0

BUNDLED WITH
2.2.3
79 changes: 79 additions & 0 deletions MacOSExample/README.md
jfedak marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
This is a new [**React Native**](https://reactnative.dev) project, bootstrapped using [`@react-native-community/cli`](https://github.com/react-native-community/cli).

# Getting Started

>**Note**: Make sure you have completed the [React Native - Environment Setup](https://reactnative.dev/docs/environment-setup) instructions till "Creating a new application" step, before proceeding.
## Step 1: Start the Metro Server

First, you will need to start **Metro**, the JavaScript _bundler_ that ships _with_ React Native.

To start Metro, run the following command from the _root_ of your React Native project:

```bash
# using npm
npm start

# OR using Yarn
yarn start
```

## Step 2: Start your Application

Let Metro Bundler run in its _own_ terminal. Open a _new_ terminal from the _root_ of your React Native project. Run the following command to start your _Android_ or _iOS_ app:

### For Android

```bash
# using npm
npm run android

# OR using Yarn
yarn android
```

### For iOS

```bash
# using npm
npm run ios

# OR using Yarn
yarn ios
```

If everything is set up _correctly_, you should see your new app running in your _Android Emulator_ or _iOS Simulator_ shortly provided you have set up your emulator/simulator correctly.

This is one way to run your app — you can also run it directly from within Android Studio and Xcode respectively.

## Step 3: Modifying your App

Now that you have successfully run the app, let's modify it.

1. Open `App.tsx` in your text editor of choice and edit some lines.
2. For **Android**: Press the <kbd>R</kbd> key twice or select **"Reload"** from the **Developer Menu** (<kbd>Ctrl</kbd> + <kbd>M</kbd> (on Window and Linux) or <kbd>Cmd ⌘</kbd> + <kbd>M</kbd> (on macOS)) to see your changes!

For **iOS**: Hit <kbd>Cmd ⌘</kbd> + <kbd>R</kbd> in your iOS Simulator to reload the app and see your changes!

## Congratulations! :tada:

You've successfully run and modified your React Native App. :partying_face:

### Now what?

- If you want to add this new React Native code to an existing application, check out the [Integration guide](https://reactnative.dev/docs/integration-with-existing-apps).
- If you're curious to learn more about React Native, check out the [Introduction to React Native](https://reactnative.dev/docs/getting-started).

# Troubleshooting

If you can't get this to work, see the [Troubleshooting](https://reactnative.dev/docs/troubleshooting) page.

# Learn More

To learn more about React Native, take a look at the following resources:

- [React Native Website](https://reactnative.dev) - learn more about React Native.
- [Getting Started](https://reactnative.dev/docs/environment-setup) - an **overview** of React Native and how setup your environment.
- [Learn the Basics](https://reactnative.dev/docs/getting-started) - a **guided tour** of the React Native **basics**.
- [Blog](https://reactnative.dev/blog) - read the latest official React Native **Blog** posts.
- [`@facebook/react-native`](https://github.com/facebook/react-native) - the Open Source; GitHub **repository** for React Native.
17 changes: 17 additions & 0 deletions MacOSExample/__tests__/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: import explicitly to use the types shiped with jest.
import {it} from '@jest/globals';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
4 changes: 4 additions & 0 deletions MacOSExample/app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "MacOSExample",
"displayName": "MacOSExample"
}
23 changes: 23 additions & 0 deletions MacOSExample/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
plugins: [
'@babel/plugin-transform-modules-commonjs',
'react-native-reanimated/plugin',
[
'module-resolver',
{
extensions: ['.js', '.ts', '.tsx'],
alias: {
react: './node_modules/react',
'react-native': './node_modules/react-native-macos',
'react-native-reanimated': './node_modules/react-native-reanimated',
'@babel': './node_modules/@babel',
'@egjs/hammerjs': './node_modules/@egjs/hammerjs',
fbjs: './node_modules/fbjs',
'hoist-non-react-statics': './node_modules/hoist-non-react-statics',
invariant: './node_modules/invariant',
},
},
],
j-piasecki marked this conversation as resolved.
Show resolved Hide resolved
],
};
9 changes: 9 additions & 0 deletions MacOSExample/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* @format
*/

import {AppRegistry} from 'react-native';
import App from './src/App';
import {name as appName} from './app.json';

AppRegistry.registerComponent(appName, () => App);
3 changes: 3 additions & 0 deletions MacOSExample/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
preset: 'react-native',
};
2 changes: 2 additions & 0 deletions MacOSExample/macos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# CocoaPods
Pods/
Loading