Skip to content

Commit d8e1ffb

Browse files
authored
Merge pull request #50 from bugfender/feature/react-native-0.7
Feature/react native 0.7
2 parents 8a4f653 + 1afae04 commit d8e1ffb

74 files changed

Lines changed: 5126 additions & 3918 deletions

File tree

Some content is hidden

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

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2.1
33
executors:
44
default:
55
docker:
6-
- image: circleci/node:10
6+
- image: circleci/node:16
77
working_directory: ~/project
88

99
commands:

.husky/.npmignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.husky/commit-msg

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

.husky/pre-commit

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

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.17
1+
16

.ruby-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2.7.4

.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

DEVELOPMENT.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Bugfender React Native Development
2+
3+
## Setting up the environment
4+
5+
Please follow the guide located in [React Native Environment Setup](https://reactnative.dev/docs/environment-setup) "React Native CLI Quickstart" tab. The following is an overview of the needed tooling.
6+
7+
Basic tooling:
8+
9+
- NodeJS and [Yarn](https://yarnpkg.com)
10+
- [Watchman](https://github.com/facebook/watchman)
11+
12+
For Android, install:
13+
14+
- Java Development Kit
15+
- Android Studio with Android SDK
16+
17+
For iOS, install:
18+
19+
- XCode with Command Line Tools
20+
- [Cocoapods](https://cocoapods.org)
21+
22+
**Once all the tooling is ready**:
23+
24+
- On the `example` folder:
25+
- `bundle install`: install required Ruby gems
26+
- On the root folder:
27+
- `yarn`: this will install dependencies for the library & `/example`
28+
- Add Bugfender app key in `example` project:
29+
- `cd example/src`
30+
- `cp bugfenderKey.json.example bugfenderKey.json`
31+
- Edit `bugfenderKey.json` & add the key
32+
33+
## Running the example
34+
35+
On a terminal window:
36+
37+
- `cd example`: enter the `example` folder
38+
- `yarn start`: start React Native "server"
39+
- Open a new terminal to run the specific example
40+
41+
For Android:
42+
43+
- Open Android Studio and run an emulator
44+
- `cd example`: enter the `example` folder
45+
- `yarn android`: run in Android
46+
47+
For iOS:
48+
49+
- `cd example`: enter the `example` folder
50+
- `yarn ios`: run in iOS
51+
52+
For Web:
53+
54+
- Please use [this private project](https://bitbucket.org/bugfender/rn-bugfender-development) and execute `yarn web`
55+
56+
## Upgrade React Native version
57+
58+
Try with the official react native upgrade command:
59+
60+
```bash
61+
npx react-native upgrade
62+
```
63+
64+
If it does not work you can create a new updated library from scratch:
65+
66+
1. Using [create-react-native-library tool](https://reactnative.dev/docs/native-modules-setup)
67+
2. Be sure to select a Native library using Java & Objective-C
68+
3. Add the following lines to the `package.json` of the newly created library (be sure to use the latest version):
69+
70+
```json
71+
"dependencies": {
72+
"@bugfender/common": "1.0.0-alpha.5",
73+
"@bugfender/sdk": "^2.1.0"
74+
}
75+
```
76+
77+
4. Add "dom" into the "lib" object on `tsconfig.json`:
78+
79+
```json
80+
"lib": [
81+
"esnext",
82+
"dom"
83+
],
84+
```
85+
86+
5. On **android/src/build.gradle** add the following to the dependencies:
87+
88+
```gradle
89+
implementation 'com.bugfender.sdk:android:3.+'
90+
```
91+
92+
6. Copy `RnBugfenderModule.java` and `RnBufgenerPackage.java` to **android/src/main/java/com.bugfender.react**.
93+
7. Add the Bugfender dependency to the podspec on the **root** folder
94+
95+
```ruby
96+
s.dependency 'BugfenderSDK', '~> 1.10.5'
97+
```
98+
99+
8. Copy `RnBugefnder.h` && `RnBugefnder.mm` to **ios/**
100+
9. Copy `App.tsx` & add `bugfenderKey.json` into **example/src/**, see `bugfenderKey.json` format below:
101+
102+
```json
103+
{
104+
"bugfenderKey": "<your Bugfdender key>"
105+
}
106+
```
107+
108+
10. Run `pod install` under **example/ios/**
109+
11. You should be ready to run the example using `yarn android` & `yarn ios`

RnBugfender.podspec

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
require "json"
22

33
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
45

56
Pod::Spec.new do |s|
67
s.name = "RnBugfender"
@@ -18,4 +19,18 @@ Pod::Spec.new do |s|
1819
s.dependency "React-Core"
1920
s.dependency 'BugfenderSDK', '~> 1.10.5'
2021

22+
# Don't install the dependencies when we run `pod install` in the old architecture.
23+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
24+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
25+
s.pod_target_xcconfig = {
26+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
27+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
28+
}
29+
30+
s.dependency "React-Codegen"
31+
s.dependency "RCT-Folly"
32+
s.dependency "RCTRequired"
33+
s.dependency "RCTTypeSafety"
34+
s.dependency "ReactCommon/turbomodule/core"
35+
end
2136
end

android/build.gradle

Lines changed: 117 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,138 @@
11
buildscript {
2-
if (project == rootProject) {
3-
repositories {
4-
google()
5-
mavenCentral()
6-
jcenter()
7-
}
2+
repositories {
3+
google()
4+
mavenCentral()
5+
}
86

9-
dependencies {
10-
classpath 'com.android.tools.build:gradle:3.5.3'
11-
}
12-
}
7+
dependencies {
8+
classpath 'com.android.tools.build:gradle:3.5.3'
9+
}
10+
}
11+
12+
def isNewArchitectureEnabled() {
13+
return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
1314
}
1415

1516
apply plugin: 'com.android.library'
1617

17-
def safeExtGet(prop, fallback) {
18-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
18+
if (isNewArchitectureEnabled()) {
19+
apply plugin: 'com.facebook.react'
20+
}
21+
22+
def getExtOrDefault(name) {
23+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['RnBugfender_' + name]
24+
}
25+
26+
def getExtOrIntegerDefault(name) {
27+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['RnBugfender_' + name]).toInteger()
1928
}
2029

2130
android {
22-
compileSdkVersion safeExtGet('RnBugfender_compileSdkVersion', 29)
23-
defaultConfig {
24-
minSdkVersion safeExtGet('RnBugfender_minSdkVersion', 16)
25-
targetSdkVersion safeExtGet('RnBugfender_targetSdkVersion', 29)
26-
versionCode 1
27-
versionName "1.0"
31+
compileSdkVersion getExtOrIntegerDefault('compileSdkVersion')
2832

33+
defaultConfig {
34+
minSdkVersion getExtOrIntegerDefault('minSdkVersion')
35+
targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
36+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
37+
}
38+
buildTypes {
39+
release {
40+
minifyEnabled false
2941
}
42+
}
3043

31-
buildTypes {
32-
release {
33-
minifyEnabled false
34-
}
35-
}
36-
lintOptions {
37-
disable 'GradleCompatible'
38-
}
39-
compileOptions {
40-
sourceCompatibility JavaVersion.VERSION_1_8
41-
targetCompatibility JavaVersion.VERSION_1_8
42-
}
44+
lintOptions {
45+
disable 'GradleCompatible'
46+
}
47+
48+
compileOptions {
49+
sourceCompatibility JavaVersion.VERSION_1_8
50+
targetCompatibility JavaVersion.VERSION_1_8
51+
}
4352
}
4453

4554
repositories {
46-
mavenLocal()
55+
mavenCentral()
56+
google()
57+
58+
def found = false
59+
def defaultDir = null
60+
def androidSourcesName = 'React Native sources'
61+
62+
if (rootProject.ext.has('reactNativeAndroidRoot')) {
63+
defaultDir = rootProject.ext.get('reactNativeAndroidRoot')
64+
} else {
65+
defaultDir = new File(
66+
projectDir,
67+
'/../../../node_modules/react-native/android'
68+
)
69+
}
70+
71+
if (defaultDir.exists()) {
4772
maven {
48-
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
49-
url("$rootDir/../node_modules/react-native/android")
73+
url defaultDir.toString()
74+
name androidSourcesName
5075
}
51-
google()
52-
mavenCentral()
53-
jcenter()
76+
77+
logger.info(":${project.name}:reactNativeAndroidRoot ${defaultDir.canonicalPath}")
78+
found = true
79+
} else {
80+
def parentDir = rootProject.projectDir
81+
82+
1.upto(5, {
83+
if (found) return true
84+
parentDir = parentDir.parentFile
85+
86+
def androidSourcesDir = new File(
87+
parentDir,
88+
'node_modules/react-native'
89+
)
90+
91+
def androidPrebuiltBinaryDir = new File(
92+
parentDir,
93+
'node_modules/react-native/android'
94+
)
95+
96+
if (androidPrebuiltBinaryDir.exists()) {
97+
maven {
98+
url androidPrebuiltBinaryDir.toString()
99+
name androidSourcesName
100+
}
101+
102+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidPrebuiltBinaryDir.canonicalPath}")
103+
found = true
104+
} else if (androidSourcesDir.exists()) {
105+
maven {
106+
url androidSourcesDir.toString()
107+
name androidSourcesName
108+
}
109+
110+
logger.info(":${project.name}:reactNativeAndroidRoot ${androidSourcesDir.canonicalPath}")
111+
found = true
112+
}
113+
})
114+
}
115+
116+
if (!found) {
117+
throw new GradleException(
118+
"${project.name}: unable to locate React Native android sources. " +
119+
"Ensure you have you installed React Native as a dependency in your project and try again."
120+
)
121+
}
54122
}
55123

124+
56125
dependencies {
57-
//noinspection GradleDynamicVersion
58-
implementation "com.facebook.react:react-native:+" // From node_modules
59-
//noinspection GradleDynamicVersion
60-
implementation 'com.bugfender.sdk:android:3.+'
126+
//noinspection GradleDynamicVersion
127+
implementation "com.facebook.react:react-native:+"
128+
//noinspection GradleDynamicVersion
129+
implementation 'com.bugfender.sdk:android:3.+'
130+
}
131+
132+
if (isNewArchitectureEnabled()) {
133+
react {
134+
jsRootDir = file("../src/")
135+
libraryName = "RnBugfender"
136+
codegenJavaPackageName = "com.bugfenderrnbugfender"
137+
}
61138
}

0 commit comments

Comments
 (0)