Skip to content

Commit

Permalink
fix(android, jcenter): remove jcenter dependency / update example (#500)
Browse files Browse the repository at this point in the history
* fix(jcenter): remove jcenter
+ fixed example - don't work, because one '/../' was deleted (fab577d)
+ fixed eslint configures
+ fixed jest configures
* test(jest-expo): fix jest.config.js
upgrade react-native-web because gets error's on tests
* refactor(android): move example source into dir suitable package name
* return peerDependencies for "react-native": ">=0.59" and minSdkVersion=16
* pin android buildTools to api30, add ndkVersion pin
* chore: improve react-native.config.js
fix:
- applicationId for react-native run-android.
- update podfile for new react-native
- refactoring react-native.config.js for better developer experience
* fix(ios, example): ios example works now

Co-authored-by: bibazavr <lebedevki@lad24.ru>
Co-authored-by: Mike Hardy <github@mikehardy.net>
  • Loading branch information
3 people committed Oct 22, 2021
1 parent 8ee14bb commit 94c5398
Show file tree
Hide file tree
Showing 30 changed files with 5,964 additions and 3,069 deletions.
19 changes: 8 additions & 11 deletions .eslintrc.js
Expand Up @@ -7,22 +7,19 @@
* @format
*/

const typescriptEslintRecommended = require('@typescript-eslint/eslint-plugin/dist/configs/recommended.json');
const typescriptEslintPrettier = require('eslint-config-prettier/@typescript-eslint');

module.exports = {
extends: ['@react-native-community'],
extends: [
'@react-native-community',
'plugin:@typescript-eslint/recommended',
'prettier',
],
overrides: [
{
files: ['*.ts', '*.tsx'],
// Apply the recommended Typescript defaults and the prettier overrides to all Typescript files
rules: Object.assign(
typescriptEslintRecommended.rules,
typescriptEslintPrettier.rules,
{
'@typescript-eslint/explicit-member-accessibility': 'off',
},
),
rules: {
'@typescript-eslint/explicit-member-accessibility': 'off',
},
},
{
files: ['example/**/*.ts', 'example/**/*.tsx'],
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -44,7 +44,8 @@ android/.project
# BUCK
buck-out/
\.buckd/
debug.keystore
*.keystore
!debug.keystore

# Editor config
.vscode
Expand Down
4 changes: 2 additions & 2 deletions android/build.gradle
Expand Up @@ -5,7 +5,7 @@ buildscript {
if (project == rootProject) {
repositories {
google()
jcenter()
mavenCentral()
}

dependencies {
Expand Down Expand Up @@ -46,7 +46,7 @@ repositories {
url "$rootDir/../node_modules/react-native/android"
}
google()
jcenter()
mavenLocal()
mavenCentral()
}

Expand Down
3 changes: 2 additions & 1 deletion example/.gitignore
Expand Up @@ -39,7 +39,8 @@ yarn-error.log
# BUCK
buck-out/
\.buckd/
debug.keystore
*.keystore
!debug.keystore

# fastlane
#
Expand Down
5 changes: 4 additions & 1 deletion example/ConnectionInfoCurrent.tsx
Expand Up @@ -15,7 +15,10 @@ interface State {
connectionInfo: NetInfoState | null;
}

export default class ConnectionInfoCurrent extends React.Component<{}, State> {
export default class ConnectionInfoCurrent extends React.Component<
Record<string, unknown>,
State
> {
_subscription: NetInfoSubscription | null = null;

state = {
Expand Down
5 changes: 4 additions & 1 deletion example/ConnectionInfoFetch.tsx
Expand Up @@ -15,7 +15,10 @@ interface State {
connectionInfo: string;
}

export default class ConnectionInfoCurrent extends React.Component<{}, State> {
export default class ConnectionInfoCurrent extends React.Component<
Record<string, unknown>,
State
> {
state = {
connectionInfo: 'Tap to get current state',
};
Expand Down
2 changes: 1 addition & 1 deletion example/ConnectionInfoSubscription.tsx
Expand Up @@ -16,7 +16,7 @@ interface State {
}

export default class ConnectionInfoSubscription extends React.Component<
{},
Record<string, unknown>,
State
> {
_subscription: NetInfoSubscription | null = null;
Expand Down
5 changes: 4 additions & 1 deletion example/IsConnected.tsx
Expand Up @@ -15,7 +15,10 @@ interface State {
isConnected: boolean | null;
}

export default class IsConnected extends React.Component<{}, State> {
export default class IsConnected extends React.Component<
Record<string, unknown>,
State
> {
_subscription: NetInfoSubscription | null = null;

state = {
Expand Down
9 changes: 5 additions & 4 deletions example/android/app/build.gradle
Expand Up @@ -76,12 +76,13 @@ import com.android.build.OutputFile
*/

project.ext.react = [
cliPath: "../../../node_modules/react-native/local-cli/cli.js",
entryFile: "example/index.tsx",
root: "../../../",
enableHermes: false, // clean and rebuild if changing
]

apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../../node_modules/react-native/react.gradle"

/**
* Set this to true to create two separate APKs instead of one:
Expand Down Expand Up @@ -129,7 +130,7 @@ android {
}

defaultConfig {
applicationId "com.netinfoexample"
applicationId "com.reactnativecommunity.netinfo.example"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down Expand Up @@ -194,7 +195,7 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
def hermesPath = "../../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
Expand All @@ -211,4 +212,4 @@ task copyDownloadableDepsToLibs(type: Copy) {
into 'libs'
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Binary file added example/android/app/debug.keystore
Binary file not shown.
19 changes: 10 additions & 9 deletions example/android/build.gradle
Expand Up @@ -2,19 +2,20 @@

buildscript {
ext {
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
buildToolsVersion = "30.0.2"
ndkVersion = "21.4.7075529"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
androidXVersion = "1.+" // Default AndroidX dependency
androidXCore = "1.0.2"

// e2e
kotlinVersion = '1.3.0'
kotlinVersion = '1.5.10'
}
repositories {
google()
jcenter()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:3.4.2")
Expand All @@ -28,17 +29,17 @@ buildscript {
allprojects {
repositories {
mavenLocal()
mavenCentral()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
url("$rootDir/../../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
url("$rootDir/../../node_modules/jsc-android/dist")
}

google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
4 changes: 2 additions & 2 deletions example/android/settings.gradle
@@ -1,9 +1,9 @@
rootProject.name = 'NetInfoExample'

apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)

include ':app'
// You will not need to manual link like this. This is a quirk of the example project
include ':react-native-netinfo'
project(':react-native-netinfo').projectDir = new File(rootProject.projectDir, '../../android')

include ':app'
4 changes: 2 additions & 2 deletions example/index.tsx
Expand Up @@ -117,8 +117,8 @@ interface State {
activeTestCase: Example | null;
}

class ExampleApp extends React.Component<{}, State> {
constructor(props: {}) {
class ExampleApp extends React.Component<Record<string, unknown>, State> {
constructor(props: Record<string, unknown>) {
super(props);

this.state = {
Expand Down
21 changes: 21 additions & 0 deletions example/ios/NetInfoExample.xcodeproj/project.pbxproj
Expand Up @@ -127,6 +127,7 @@
13B07F8C1A680F5B00A75B9A /* Frameworks */,
13B07F8E1A680F5B00A75B9A /* Resources */,
00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
A3BE519D0F4F677288B66D34 /* [CP] Copy Pods Resources */,
);
buildRules = (
);
Expand Down Expand Up @@ -219,6 +220,24 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
A3BE519D0F4F677288B66D34 /* [CP] Copy Pods Resources */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
"${PODS_ROOT}/Target Support Files/Pods-NetInfoExample/Pods-NetInfoExample-resources.sh",
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/AccessibilityResources.bundle",
);
name = "[CP] Copy Pods Resources";
outputPaths = (
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/AccessibilityResources.bundle",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-NetInfoExample/Pods-NetInfoExample-resources.sh\"\n";
showEnvVarsInLog = 0;
};
FD10A7F022414F080027D42C /* Start Packager */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
Expand Down Expand Up @@ -337,6 +356,7 @@
COPY_PHASE_STRIP = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
Expand Down Expand Up @@ -390,6 +410,7 @@
COPY_PHASE_STRIP = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "arm64 ";
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
Expand Down
44 changes: 12 additions & 32 deletions example/ios/Podfile
@@ -1,41 +1,21 @@
platform :ios, '9.0'
platform :ios, '11.0'
require_relative '../../node_modules/react-native/scripts/react_native_pods'
require_relative '../../node_modules/@react-native-community/cli-platform-ios/native_modules'

target 'NetInfoExample' do
# Pods for NetInfoExample
pod 'FBLazyVector', :path => "../../node_modules/react-native/Libraries/FBLazyVector"
pod 'FBReactNativeSpec', :path => "../../node_modules/react-native/Libraries/FBReactNativeSpec"
pod 'RCTRequired', :path => "../../node_modules/react-native/Libraries/RCTRequired"
pod 'RCTTypeSafety', :path => "../../node_modules/react-native/Libraries/TypeSafety"
pod 'React', :path => '../../node_modules/react-native/'
pod 'React-Core', :path => '../../node_modules/react-native/'
pod 'React-CoreModules', :path => '../../node_modules/react-native/React/CoreModules'
pod 'React-Core/DevSupport', :path => '../../node_modules/react-native/'
pod 'React-RCTActionSheet', :path => '../../node_modules/react-native/Libraries/ActionSheetIOS'
pod 'React-RCTAnimation', :path => '../../node_modules/react-native/Libraries/NativeAnimation'
pod 'React-RCTBlob', :path => '../../node_modules/react-native/Libraries/Blob'
pod 'React-RCTImage', :path => '../../node_modules/react-native/Libraries/Image'
pod 'React-RCTLinking', :path => '../../node_modules/react-native/Libraries/LinkingIOS'
pod 'React-RCTNetwork', :path => '../../node_modules/react-native/Libraries/Network'
pod 'React-RCTSettings', :path => '../../node_modules/react-native/Libraries/Settings'
pod 'React-RCTText', :path => '../../node_modules/react-native/Libraries/Text'
pod 'React-RCTVibration', :path => '../../node_modules/react-native/Libraries/Vibration'
pod 'React-Core/RCTWebSocket', :path => '../../node_modules/react-native/'
config = use_native_modules!

pod 'React-cxxreact', :path => '../../node_modules/react-native/ReactCommon/cxxreact'
pod 'React-jsi', :path => '../../node_modules/react-native/ReactCommon/jsi'
pod 'React-jsiexecutor', :path => '../../node_modules/react-native/ReactCommon/jsiexecutor'
pod 'React-jsinspector', :path => '../../node_modules/react-native/ReactCommon/jsinspector'
pod 'ReactCommon/jscallinvoker', :path => "../../node_modules/react-native/ReactCommon"
pod 'ReactCommon/turbomodule/core', :path => "../../node_modules/react-native/ReactCommon"
pod 'Yoga', :path => '../../node_modules/react-native/ReactCommon/yoga'
use_react_native!(
# This path to react-native is non-standard, it is a quirk of the example project here.
:path => '../../node_modules/react-native',
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => false
)

pod 'DoubleConversion', :podspec => '../../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
pod 'glog', :podspec => '../../node_modules/react-native/third-party-podspecs/glog.podspec'
pod 'Folly', :podspec => '../../node_modules/react-native/third-party-podspecs/Folly.podspec'

# You should not need to manually link in your Podfile like this, this is a quirk of the example project
pod 'react-native-netinfo', :path => '../../'

use_native_modules!(root = "../..")
post_install do |installer|
react_native_post_install(installer)
end
end

0 comments on commit 94c5398

Please sign in to comment.