Skip to content

Local network permission #874

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
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
268 changes: 114 additions & 154 deletions README.md

Large diffs are not rendered by default.

53 changes: 36 additions & 17 deletions RNPermissions.podspec
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
require "json"
require 'json'
package = JSON.parse(File.read('./package.json'))

package = JSON.parse(File.read(File.join(__dir__, "package.json")))
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'

Pod::Spec.new do |s|
s.name = "RNPermissions"
s.name = "RNPermissions"

s.version = package["version"]
s.license = package["license"]
s.summary = package["description"]
s.author = package["author"]
s.homepage = package["homepage"]
s.version = package["version"]
s.license = package["license"]
s.summary = package["description"]
s.authors = package["author"]
s.homepage = package["homepage"]

s.platforms = { :ios => "12.4", :tvos => "12.4" }
s.requires_arc = true
s.ios.deployment_target = "10.0"
s.tvos.deployment_target = "11.0"
s.requires_arc = true

s.source = { :git => package["repository"]["url"], :tag => s.version }
s.source_files = "ios/*.{h,mm}"
# s.frameworks = <frameworks>
# s.resource_bundles = <resource_bundles>
s.source = { :git => package["repository"]["url"], :tag => s.version }
s.source_files = "ios/*.{h,m,mm}"

if ENV['RCT_NEW_ARCH_ENABLED'] == "1" then
install_modules_dependencies(s)
if fabric_enabled
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'

s.pod_target_xcconfig = {
'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly"',
'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
}

s.platforms = { ios: '11.0', tvos: '11.0' }
s.compiler_flags = folly_compiler_flags + ' -DRCT_NEW_ARCH_ENABLED'

s.dependency "React"
s.dependency "React-RCTFabric" # This is for fabric component
s.dependency "React-Codegen"
s.dependency "RCT-Folly"
s.dependency "RCTRequired"
s.dependency "RCTTypeSafety"
s.dependency "ReactCommon/turbomodule/core"
else
s.dependency "React-Core"
s.platforms = { :ios => "9.0", :tvos => "9.0" }

s.dependency "React-Core"
end

end
108 changes: 74 additions & 34 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,71 +1,111 @@
def safeExtGet(prop, fallback) {
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
}

buildscript {
ext.safeExtGet = {prop, fallback ->
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
// The Android Gradle plugin is only required when opening the android folder stand-alone.
// This avoids unnecessary downloads and potential conflicts when the library is included as a
// module dependency in an application project.
if (project == rootProject) {
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
}
}
repositories {
google()
gradlePluginPortal()
}

apply plugin: "com.android.library"

def resolveReactNativeDirectory() {
// monorepo workaround (react-native can be hoisted or in project's own node_modules)
def reactNativeFromProjectNodeModules = file("${rootProject.projectDir}/../node_modules/react-native")
if (reactNativeFromProjectNodeModules.exists()) {
return reactNativeFromProjectNodeModules
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")

def reactNativeFromNodeModulesWithLibrary = file("${projectDir}/../../react-native")
if (reactNativeFromNodeModulesWithLibrary.exists()) {
return reactNativeFromNodeModulesWithLibrary
}

throw new Exception(
"[react-native-permissions] Unable to resolve react-native location in " +
"node_modules. You should add project extension property (in app/build.gradle) " +
"`REACT_NATIVE_NODE_MODULES_DIR` with path to react-native."
)
}

def REACT_NATIVE_DIR = resolveReactNativeDirectory()

def reactProperties = new Properties()
file("$REACT_NATIVE_DIR/ReactAndroid/gradle.properties").withInputStream { reactProperties.load(it) }

def REACT_NATIVE_VERSION = reactProperties.getProperty("VERSION_NAME")
def REACT_NATIVE_MINOR_VERSION = REACT_NATIVE_VERSION.startsWith("0.0.0-") ? 1000 : REACT_NATIVE_VERSION.split("\\.")[1].toInteger()

def isNewArchitectureEnabled() {
// To opt-in for the New Architecture, you can either:
// - Set `newArchEnabled` to true inside the `gradle.properties` file
// - Invoke gradle with `-newArchEnabled=true`
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
}

apply plugin: "com.android.library"

if (isNewArchitectureEnabled()) {
apply plugin: "com.facebook.react"
}

android {
buildToolsVersion safeExtGet("buildToolsVersion", "33.0.0")
compileSdkVersion safeExtGet("compileSdkVersion", 33)

if (project.android.hasProperty("namespace")) {
namespace "com.zoontek.rnpermissions"

buildFeatures {
buildConfig true
}
sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestNew.xml"
}
}
// Used to override the NDK path/version on internal CI or by allowing
// users to customize the NDK path/version from their root project (e.g. for M1 support)
if (rootProject.hasProperty("ndkPath")) {
ndkPath rootProject.ext.ndkPath
}
if (rootProject.hasProperty("ndkVersion")) {
ndkVersion rootProject.ext.ndkVersion
}

compileSdkVersion safeExtGet("compileSdkVersion", 33)
buildToolsVersion safeExtGet("buildToolsVersion", "33.0.0")
defaultConfig {
buildConfigField("boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString())
minSdkVersion safeExtGet("minSdkVersion", 21)
targetSdkVersion safeExtGet("targetSdkVersion", 33)
}
lintOptions {
abortOnError false
}
sourceSets {
main {
if (isNewArchitectureEnabled()) {
java.srcDirs += ["src/newarch"]
} else {
java.srcDirs += ["src/oldarch"]

sourceSets.main {
java {
if (!isNewArchitectureEnabled()) {
srcDirs += 'src/paper/java'
}
}
}
}

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"
}
mavenCentral()
google()
}

dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
if (isNewArchitectureEnabled() && REACT_NATIVE_MINOR_VERSION < 71) {
implementation project(":ReactAndroid")
} else {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-native:+'
}
}
4 changes: 3 additions & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.zoontek.rnpermissions">
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.zoontek.rnpermissions">
</manifest>
3 changes: 0 additions & 3 deletions android/src/main/AndroidManifestNew.xml

This file was deleted.

Loading