Skip to content

Commit c921e01

Browse files
committed
Modification of the plugin for the new architecture
1 parent b15b091 commit c921e01

File tree

148 files changed

+21505
-6142
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+21505
-6142
lines changed

.github/actions/setup/action.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Setup
2+
description: Setup Node.js and install dependencies
3+
4+
runs:
5+
using: composite
6+
steps:
7+
- name: Setup Node.js
8+
uses: actions/setup-node@v3
9+
with:
10+
node-version-file: .nvmrc
11+
12+
- name: Cache dependencies
13+
id: yarn-cache
14+
uses: actions/cache@v3
15+
with:
16+
path: |
17+
**/node_modules
18+
.yarn/install-state.gz
19+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ hashFiles('**/package.json') }}
20+
restore-keys: |
21+
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
22+
${{ runner.os }}-yarn-
23+
24+
- name: Install dependencies
25+
if: steps.yarn-cache.outputs.cache-hit != 'true'
26+
run: yarn install --immutable
27+
shell: bash

.github/workflows/ci.yml

+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
10+
jobs:
11+
lint:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v3
16+
17+
- name: Setup
18+
uses: ./.github/actions/setup
19+
20+
- name: Lint files
21+
run: yarn lint
22+
23+
- name: Typecheck files
24+
run: yarn typecheck
25+
26+
test:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v3
31+
32+
- name: Setup
33+
uses: ./.github/actions/setup
34+
35+
- name: Run unit tests
36+
run: yarn test --maxWorkers=2 --coverage
37+
38+
build-library:
39+
runs-on: ubuntu-latest
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v3
43+
44+
- name: Setup
45+
uses: ./.github/actions/setup
46+
47+
- name: Build package
48+
run: yarn prepare
49+
50+
build-android:
51+
runs-on: ubuntu-latest
52+
env:
53+
TURBO_CACHE_DIR: .turbo/android
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v3
57+
58+
- name: Setup
59+
uses: ./.github/actions/setup
60+
61+
- name: Cache turborepo for Android
62+
uses: actions/cache@v3
63+
with:
64+
path: ${{ env.TURBO_CACHE_DIR }}
65+
key: ${{ runner.os }}-turborepo-android-${{ hashFiles('**/yarn.lock') }}
66+
restore-keys: |
67+
${{ runner.os }}-turborepo-android-
68+
69+
- name: Check turborepo cache for Android
70+
run: |
71+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")
72+
73+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
74+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
75+
fi
76+
77+
- name: Install JDK
78+
if: env.turbo_cache_hit != 1
79+
uses: actions/setup-java@v3
80+
with:
81+
distribution: 'zulu'
82+
java-version: '11'
83+
84+
- name: Finalize Android SDK
85+
if: env.turbo_cache_hit != 1
86+
run: |
87+
/bin/bash -c "yes | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --licenses > /dev/null"
88+
89+
- name: Cache Gradle
90+
if: env.turbo_cache_hit != 1
91+
uses: actions/cache@v3
92+
with:
93+
path: |
94+
~/.gradle/wrapper
95+
~/.gradle/caches
96+
key: ${{ runner.os }}-gradle-${{ hashFiles('example/android/gradle/wrapper/gradle-wrapper.properties') }}
97+
restore-keys: |
98+
${{ runner.os }}-gradle-
99+
100+
- name: Build example for Android
101+
run: |
102+
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
103+
104+
build-ios:
105+
runs-on: macos-latest
106+
env:
107+
TURBO_CACHE_DIR: .turbo/ios
108+
steps:
109+
- name: Checkout
110+
uses: actions/checkout@v3
111+
112+
- name: Setup
113+
uses: ./.github/actions/setup
114+
115+
- name: Cache turborepo for iOS
116+
uses: actions/cache@v3
117+
with:
118+
path: ${{ env.TURBO_CACHE_DIR }}
119+
key: ${{ runner.os }}-turborepo-ios-${{ hashFiles('**/yarn.lock') }}
120+
restore-keys: |
121+
${{ runner.os }}-turborepo-ios-
122+
123+
- name: Check turborepo cache for iOS
124+
run: |
125+
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:ios').cache.status")
126+
127+
if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
128+
echo "turbo_cache_hit=1" >> $GITHUB_ENV
129+
fi
130+
131+
- name: Cache cocoapods
132+
if: env.turbo_cache_hit != 1
133+
id: cocoapods-cache
134+
uses: actions/cache@v3
135+
with:
136+
path: |
137+
**/ios/Pods
138+
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
139+
restore-keys: |
140+
${{ runner.os }}-cocoapods-
141+
142+
- name: Install cocoapods
143+
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
144+
run: |
145+
yarn pod-install example/ios
146+
env:
147+
NO_FLIPPER: 1
148+
149+
- name: Build example for iOS
150+
run: |
151+
yarn turbo run build:ios --cache-dir="${{ env.TURBO_CACHE_DIR }}"

.gitignore

+15-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ android.iml
4444
#
4545
example/ios/Pods
4646

47+
# Ruby
48+
example/vendor/
49+
4750
# node.js
4851
#
4952
node_modules/
@@ -57,8 +60,19 @@ buck-out/
5760
android/app/libs
5861
android/keystores/debug.keystore
5962

63+
# Yarn
64+
.yarn/*
65+
!.yarn/patches
66+
!.yarn/plugins
67+
!.yarn/releases
68+
!.yarn/sdks
69+
!.yarn/versions
70+
6071
# Expo
61-
.expo/*
72+
.expo/
73+
74+
# Turborepo
75+
.turbo/
6276

6377
# generated by bob
6478
lib/

.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v18

.yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs

+541
Large diffs are not rendered by default.

.yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

+28
Large diffs are not rendered by default.

.yarn/releases/yarn-3.6.1.cjs

+874
Large diffs are not rendered by default.

.yarnrc

-3
This file was deleted.

.yarnrc.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
nodeLinker: node-modules
2+
nmHoistingLimits: workspaces
3+
4+
plugins:
5+
- path: scripts/pod-install.cjs
6+
- path: .yarn/plugins/@yarnpkg/plugin-interactive-tools.cjs
7+
spec: "@yarnpkg/plugin-interactive-tools"
8+
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs
9+
spec: "@yarnpkg/plugin-workspace-tools"
10+
11+
yarnPath: .yarn/releases/yarn-3.6.1.cjs

README.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
The plugin that allows you to embed a UNITY project into the react native as a full-fledged component
44

5+
<span style="color: red; font-size: 20px; font-weight: bold"> ATTENTION! </span>
6+
7+
The plugin now supports the new architecture as well.
8+
For iOS, it is no longer necessary to embed a project created with Unity. Only the built UnityFramework.framework is used. It should be placed in the plugin folder at the path -
9+
```node_modules/@azesmway/react-native-unity/ios/``` or change the path in the ```react-native-unity.podspec``` file.
10+
11+
```
12+
s.vendored_frameworks = ["ios/UnityFramework.framework"].
13+
```
14+
15+
516
# Installation
617

718
## RN
@@ -62,13 +73,12 @@ public class ButtonBehavior : MonoBehaviour
6273

6374
## iOS
6475

65-
1. Build Unity app to `[project_root]/unity/builds/ios`
66-
2. Add `Unity-iPhone.xcodeproj` to your XCode: press the right mouse button in the Left Navigator XCode -> `Add Files to [project_name]...` -> `[project_root]/unity/builds/ios/Unity-iPhone.xcodeproj`
67-
3. Add `UnityFramework.framework` to `General` / section `Frameworks, Libraries, and Embedded Content`
68-
4. Select Data folder and set a checkbox in the "Target Membership" section to "UnityFramework"
69-
5. You need to select the NativeCallProxy.h inside the `Unity-iPhone/Libraries/Plugins/iOS` folder of the Unity-iPhone project and change UnityFramework’s target membership from Project to Public. Don’t forget this step! https://miro.medium.com/max/1400/1*6v9KfxzR6olQNioUp_dFQQ.png
70-
6. In `Build Phases` remove UnityFramework.framework from `Linked Binary With Libraries`
71-
7. In Build Phases move Embedded Frameworks before Compile Sources ( drag and drop )
76+
1. Build Unity app
77+
2. Open the created project in XCode
78+
3. Select Data folder and set a checkbox in the "Target Membership" section to "UnityFramework" ![image info](./docs/step1.jpg)
79+
4. You need to select the NativeCallProxy.h inside the `Unity-iPhone/Libraries/Plugins/iOS` folder of the Unity-iPhone project and change UnityFramework’s target membership from Project to Public. Don’t forget this step! ![image info](./docs/step2.jpg)
80+
5. If required - sign the project ```UnityFramework.framework``` and build a framework ![image info](./docs/step3.jpg)
81+
6. Open the folder with the built framework (by right-clicking) and move it to the plugin folder (```node_modules/@azesmway/react-native-unity/ios/```) ![image info](./docs/step4.jpg)
7282

7383
### Android
7484

0 commit comments

Comments
 (0)