Skip to content
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

Updates package build #198

Merged
merged 5 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from 4 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
24 changes: 17 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.2.2'
classpath("com.android.tools.build:gradle:7.2.2")
}
}

Expand All @@ -47,6 +47,13 @@ def reactNativeArchitectures() {
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
}

def resolveBuildType() {
Gradle gradle = getGradle()
String tskReqStr = gradle.getStartParameter().getTaskRequests()['args'].toString()

return tskReqStr.contains('Release') ? 'release' : 'debug'
}

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

Expand Down Expand Up @@ -83,6 +90,7 @@ android {
}

packagingOptions {
doNotStrip resolveBuildType() == 'debug' ? "**/**/*.so" : ''
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should prevent stripping of debug symbols while not in release mode. I'm guessing it will shave disk space, but more importantly, I wonder if there is some sort of performance penalty for not stripping the symbols.

excludes = [
"**/libc++_shared.so",
"**/libfbjni.so",
Expand All @@ -91,9 +99,12 @@ android {
"**/libreact_nativemodule_core.so",
"**/libturbomodulejsijni.so",
"**/MANIFEST.MF",
""
]
doNotStrip '**/*.so'
// Should prevent clashes with other libraries that use OpenSSL
pickFirst '**/x86/libcrypto.so'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should prevent conflicts when other libraries also generate libcrypto.so like flipper or op-sqlcipher

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea I mean it's kinda unsafe here but that's the developers fault if he includes two libs with different major versions imo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Transitive dependencies are a bitch

pickFirst '**/x86_64/libcrypto.so'
pickFirst '**/armeabi-v7a/libcrypto.so'
pickFirst '**/arm64-v8a/libcrypto.so'
}

buildTypes {
Expand Down Expand Up @@ -130,9 +141,8 @@ repositories {
}

dependencies {
//noinspection GradleDynamicVersion
implementation 'com.facebook.react:react-android:+'
// https://mvnrepository.com/artifact/com.android.ndk.thirdparty/openssl
implementation 'com.android.ndk.thirdparty:openssl:1.1.1l-beta-1'

implementation "com.facebook.react:react-android:"
implementation "com.facebook.react:hermes-android:"
implementation 'com.android.ndk.thirdparty:openssl:1.1.1q-beta-1'
}
4 changes: 3 additions & 1 deletion example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
{}
{
"prefer_split_fsevents_watcher": true
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gets rid of the annoying re-crawled message when metro starts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That always annoyed me, lol. I wonder why that bugs tho

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tzvetan mentioned something about macos not being their default platform, so fsevents is kinda just duck-taped in

}
2 changes: 0 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,6 @@ dependencies {
} else {
implementation jscFlavor
}

implementation project(':reactnativequickcrypto')
}

apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ protected List<ReactPackage> getPackages() {
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new QuickCryptoPackage());
// packages.add(new QuickCryptoPackage());
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember why we did this, it seems we were not correctly linking the dependency. This is no longer necessary

return packages;
}

Expand Down
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:7.3.1")
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
}
}
6 changes: 2 additions & 4 deletions example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
rootProject.name = 'QuickCryptoExample'

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

include ':reactnativequickcrypto'
project(':reactnativequickcrypto').projectDir = new File(rootProject.projectDir, '../../android')
includeBuild('../node_modules/@react-native/gradle-plugin')
3 changes: 2 additions & 1 deletion example/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const crypto = require('crypto');
const quickCrypto = require('react-native-quick-crypto');
// const quickCrypto = require('react-native-quick-crypto');
import quickCrypto from 'react-native-quick-crypto';
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed so that metro correctly resolves the dependency now


crypto.publicEncrypt = quickCrypto.publicEncrypt;
crypto.privateDecrypt = quickCrypto.privateDecrypt;
Expand Down
26 changes: 2 additions & 24 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@ require_relative '../node_modules/@react-native-community/cli-platform-ios/nativ
platform :ios, min_ios_version_supported
prepare_react_native_project!

# If you are using a `react-native-flipper` your iOS build will fail when `NO_FLIPPER=1` is set.
# because `react-native-flipper` depends on (FlipperKit,...) that will be excluded
#
# To fix this you can also exclude `react-native-flipper` using a `react-native.config.js`
# ```js
# module.exports = {
# dependencies: {
# ...(process.env.NO_FLIPPER ? { 'react-native-flipper': { platforms: { ios: null } } } : {}),
# ```
flipper_config = ENV['NO_FLIPPER'] == "1" ? FlipperConfiguration.disabled : FlipperConfiguration.enabled

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
Expand All @@ -29,32 +18,21 @@ target 'QuickCryptoExample' do

use_react_native!(
:path => config[:reactNativePath],
# Hermes is now enabled by default. Disable by setting this flag to false.
# Upcoming versions of React Native may rely on get_default_flags(), but
# we make it explicit here to aid in the React Native upgrade process.
:hermes_enabled => flags[:hermes_enabled],
:fabric_enabled => flags[:fabric_enabled],
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
:flipper_configuration => flipper_config,
# An absolute path to your application root.
:app_path => "#{Pod::Config.instance.installation_root}/.."
)

pod 'react-native-quick-crypto', :path => '../..'

target 'QuickCryptoExampleTests' do
inherit! :complete
# Pods for testing
end

post_install do |installer|
# https://github.com/facebook/react-native/blob/main/packages/react-native/scripts/react_native_pods.rb#L197-L202
react_native_post_install(
installer,
# Set `mac_catalyst_enabled` to `true` in order to apply patches
# necessary for Mac Catalyst builds
config[:reactNativePath],
:mac_catalyst_enabled => false
)
__apply_Xcode_12_5_M1_post_install_workaround(installer)
Expand Down
Loading
Loading