Skip to content

Commit 1c548b9

Browse files
committed
feat: new architecture
1 parent e839920 commit 1c548b9

File tree

84 files changed

+6817
-12741
lines changed

Some content is hidden

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

84 files changed

+6817
-12741
lines changed

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

Lines changed: 0 additions & 541 deletions
This file was deleted.

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

Lines changed: 0 additions & 28 deletions
This file was deleted.

.yarn/releases/yarn-3.6.1.cjs

Lines changed: 0 additions & 874 deletions
This file was deleted.

.yarnrc.yml

Lines changed: 0 additions & 10 deletions
This file was deleted.

CONTRIBUTING.md

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,28 @@ We want this community to be friendly and respectful to each other. Please follo
66

77
## Development workflow
88

9+
This project is a monorepo managed using [Yarn workspaces](https://yarnpkg.com/features/workspaces). It contains the following packages:
10+
11+
- The library package in the root directory.
12+
- An example app in the `example/` directory.
13+
914
To get started with the project, run `yarn` in the root directory to install the required dependencies for each package:
1015

1116
```sh
1217
yarn
1318
```
1419

15-
> While it's possible to use [`npm`](https://github.com/npm/cli), the tooling is built around [`yarn`](https://classic.yarnpkg.com/), so you'll have an easier time if you use `yarn` for development.
20+
> Since the project relies on Yarn workspaces, you cannot use [`npm`](https://github.com/npm/cli) for development.
21+
22+
The [example app](/example/) demonstrates usage of the library. You need to run it to test any changes you make.
23+
24+
It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.
1625

17-
While developing, you can run the [example app](/example/) to test your changes. Any changes you make in your library's JavaScript code will be reflected in the example app without a rebuild. If you change any native code, then you'll need to rebuild the example app.
26+
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/MytrackerExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-mytracker`.
27+
28+
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-mytracker` under `Android`.
29+
30+
You can use various commands from the root directory to work with the project.
1831

1932
To start the packager:
2033

@@ -34,10 +47,18 @@ To run the example app on iOS:
3447
yarn example ios
3548
```
3649

50+
To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:
51+
52+
```sh
53+
Running "MytrackerExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
54+
```
55+
56+
Note the `"fabric":true` and `"concurrentRoot":true` properties.
57+
3758
Make sure your code passes TypeScript and ESLint. Run the following to verify:
3859

3960
```sh
40-
yarn typescript
61+
yarn typecheck
4162
yarn lint
4263
```
4364

@@ -53,11 +74,6 @@ Remember to add tests for your change if possible. Run the unit tests by:
5374
yarn test
5475
```
5576

56-
To edit the Objective-C or Swift files, open `example/ios/MytrackerExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-mytracker`.
57-
58-
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-mytracker` under `Android`.
59-
60-
6177
### Commit message convention
6278

6379
We follow the [conventional commits specification](https://www.conventionalcommits.org/en) for our commit messages:
@@ -93,8 +109,8 @@ yarn release
93109

94110
The `package.json` file contains various scripts for common tasks:
95111

96-
- `yarn bootstrap`: setup project by installing all dependencies and pods.
97-
- `yarn typescript`: type-check files with TypeScript.
112+
- `yarn`: setup project by installing dependencies.
113+
- `yarn typecheck`: type-check files with TypeScript.
98114
- `yarn lint`: lint files with ESLint.
99115
- `yarn test`: run unit tests with Jest.
100116
- `yarn example start`: start the Metro server for the example app.

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Nikita_Kovantsov
3+
Copyright (c) 2025 Nikita Kovantsov
44
Permission is hereby granted, free of charge, to any person obtaining a copy
55
of this software and associated documentation files (the "Software"), to deal
66
in the Software without restriction, including without limitation the rights

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ MyTracker.trackLevelWithLevelWithParams(1, {
101101
param2: 'name2',
102102
});
103103

104-
const instanceId = await MyTracker.getInstanceId();
104+
const instanceId = MyTracker.getInstanceId();
105105
```
106106

107107
## Contributing

android/build.gradle

Lines changed: 45 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,91 @@
11
buildscript {
22
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
3-
def kotlin_version = rootProject.ext.has('kotlinVersion') ? rootProject.ext.get('kotlinVersion') : project.properties['Mytracker_kotlinVersion']
3+
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["Mytracker_kotlinVersion"]
44

55
repositories {
66
google()
77
mavenCentral()
88
}
99

1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.5.3'
11+
classpath "com.android.tools.build:gradle:7.2.1"
1212
// noinspection DifferentKotlinGradleVersion
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414
}
1515
}
1616

17+
def reactNativeArchitectures() {
18+
def value = rootProject.getProperties().get("reactNativeArchitectures")
19+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20+
}
21+
1722
def isNewArchitectureEnabled() {
1823
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
1924
}
2025

21-
apply plugin: 'com.android.library'
22-
apply plugin: 'kotlin-android'
26+
apply plugin: "com.android.library"
27+
apply plugin: "kotlin-android"
2328

2429
if (isNewArchitectureEnabled()) {
25-
apply plugin: 'com.facebook.react'
30+
apply plugin: "com.facebook.react"
2631
}
2732

2833
def getExtOrDefault(name) {
29-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['Mytracker_' + name]
34+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["Mytracker_" + name]
3035
}
3136

3237
def getExtOrIntegerDefault(name) {
33-
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['Mytracker_' + name]).toInteger()
38+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["Mytracker_" + name]).toInteger()
39+
}
40+
41+
def supportsNamespace() {
42+
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
43+
def major = parsed[0].toInteger()
44+
def minor = parsed[1].toInteger()
45+
46+
// Namespace support was added in 7.3.0
47+
return (major == 7 && minor >= 3) || major >= 8
3448
}
3549

3650
android {
37-
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
51+
if (supportsNamespace()) {
52+
namespace "com.mytracker"
53+
54+
sourceSets {
55+
main {
56+
manifest.srcFile "src/main/AndroidManifestNew.xml"
57+
}
58+
}
59+
}
60+
61+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
3862

3963
defaultConfig {
40-
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
41-
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
64+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
65+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
4266
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
67+
4368
}
69+
70+
buildFeatures {
71+
buildConfig true
72+
}
73+
4474
buildTypes {
4575
release {
4676
minifyEnabled false
4777
}
4878
}
4979

5080
lintOptions {
51-
disable 'GradleCompatible'
81+
disable "GradleCompatible"
5282
}
5383

54-
5584
compileOptions {
5685
sourceCompatibility JavaVersion.VERSION_1_8
5786
targetCompatibility JavaVersion.VERSION_1_8
5887
}
5988

60-
6189
sourceSets {
6290
main {
6391
if (isNewArchitectureEnabled()) {
@@ -68,86 +96,22 @@ android {
6896
}
6997
}
7098
}
71-
7299
}
73100

74101
repositories {
75102
mavenCentral()
76103
google()
77-
78-
def found = false
79-
def defaultDir = null
80-
def androidSourcesName = 'React Native sources'
81-
82-
if (rootProject.ext.has('reactNativeAndroidRoot')) {
83-
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
84-
} else {
85-
defaultDir = new File(
86-
projectDir,
87-
'/../../../node_modules/react-native/android'
88-
)
89-
}
90-
91-
if (defaultDir.exists()) {
92-
maven {
93-
url defaultDir.toString()
94-
name androidSourcesName
95-
}
96-
97-
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
98-
found = true
99-
} else {
100-
def parentDir = rootProject.projectDir
101-
102-
1.upto(5, {
103-
if (found) return true
104-
parentDir = parentDir.parentFile
105-
106-
def androidSourcesDir = new File(
107-
parentDir,
108-
'node_modules/react-native'
109-
)
110-
111-
def androidPrebuiltBinaryDir = new File(
112-
parentDir,
113-
'node_modules/react-native/android'
114-
)
115-
116-
if (androidPrebuiltBinaryDir.exists()) {
117-
maven {
118-
url androidPrebuiltBinaryDir.toString()
119-
name androidSourcesName
120-
}
121-
122-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
123-
found = true
124-
} else if (androidSourcesDir.exists()) {
125-
maven {
126-
url androidSourcesDir.toString()
127-
name androidSourcesName
128-
}
129-
130-
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
131-
found = true
132-
}
133-
})
134-
}
135-
136-
if (!found) {
137-
throw new GradleException(
138-
"${project.name}: unable to locate React Native android sources. " +
139-
"Ensure you have you installed React Native as a dependency in your project and try again."
140-
)
141-
}
142104
}
143105

144-
def kotlin_version = getExtOrDefault('kotlinVersion')
106+
def kotlin_version = getExtOrDefault("kotlinVersion")
107+
145108
dependencies {
109+
// For < 0.71, this will be from the local maven repo
110+
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
146111
//noinspection GradleDynamicVersion
147112
implementation "com.facebook.react:react-native:+"
148113
implementation 'com.my.tracker:mytracker-sdk:3.3.2'
149114
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
150-
// From node_modules
151115
}
152116

153117
if (isNewArchitectureEnabled()) {
-15.9 KB
Binary file not shown.
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)