Skip to content

Commit

Permalink
fix(notifee-demo): forward port notifee-demo to RN68
Browse files Browse the repository at this point in the history
@johnf noticed it wasn't working while trying to reproduce invertase/notifee#334
Thanks John!
  • Loading branch information
mikehardy committed Mar 8, 2022
1 parent df95300 commit 31ad7c9
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions notifee-demo.sh
Expand Up @@ -4,23 +4,23 @@ set -e
# Basic template create, notifee install, link
\rm -fr notifeedemo

RNVERSION=0.67.1
RNVERSION=0.68.0-rc.2

echo "Testing react-native $RNVERSION + notifee current"
npm_config_yes=true npx react-native init notifeedemo --version=$RNVERSION --skip-install
cd notifeedemo

# New versions of react-native include a Gemfile, and it specifies a concrete ruby version. Alter it to >=
# New versions of react-native include annoying Ruby stuff that forces use of old rubies. Obliterate.
if [ -f Gemfile ]; then
sed -i -e $'s/ruby \'2.7.4\'/ruby \'>= 2.7.4\'/' Gemfile
rm -f Gemfile* .ruby*
fi

# Now run our initial dependency install
yarn
pushd ios && pod install && popd
npm_config_yes=true npx pod-install

# Notifee requires minimum sdk of 20
sed -i -e $'s/minSdkVersion = 16/minSdkVersion = 20/' android/build.gradle
sed -i -e $'s/minSdkVersion = 16/minSdkVersion = 21/' android/build.gradle
rm -f android/build.gradle??

# Notifee requires Android12, bump up our compile and target versions on android as needed
Expand All @@ -31,13 +31,14 @@ sed -i -e $'s/targetSdkVersion = 29/targetSdkVersion = 31/' android/build.gradle
sed -i -e $'s/compileSdkVersion = 30/compileSdkVersion = 31/' android/build.gradle
sed -i -e $'s/targetSdkVersion = 30/targetSdkVersion = 31/' android/build.gradle
rm -f android/build.gradle??

# Android 12 does require a tweak to the stock template AndroidManifest for compliance - TODO, not needed in RN67+, add if check
sed -i -e $'s/android:launchMode/android:exported="true"\\\n android:launchMode/' android/app/src/main/AndroidManifest.xml
rm -f android/app/src/main/AndroidManifest.xml??
#sed -i -e $'s/android:launchMode/android:exported="true"\\\n android:launchMode/' android/app/src/main/AndroidManifest.xml
#rm -f android/app/src/main/AndroidManifest.xml??

# Notifee requires iOS minimum of 10
sed -i -e $'s/platform :ios, \'9.0\'/platform :ios, \'10.0\'/' ios/Podfile
rm -f ios/Podfile??
# Notifee requires iOS minimum of 10 - not needed in react-native >=67 (68 uses 11 already)
#sed -i -e $'s/platform :ios, \'9.0\'/platform :ios, \'10.0\'/' ios/Podfile
#rm -f ios/Podfile??

# old versions of metro has a problem with babel. Visible in really old react-native like 0.61.2
MRNBP_VERSION=`npm_config_yes=true npx json -f package.json 'devDependencies.metro-react-native-babel-preset'`
Expand All @@ -52,9 +53,9 @@ yarn add "@notifee/react-native"
sed -i -e $'s/google()/google()\\\n maven \{ url "$rootDir\/..\/node_modules\/@notifee\/react-native\/android\/libs" \}/' android/build.gradle
rm -f android/build.gradle??

# A general react-native Java build tweak - or gradle runs out of memory sometimes
echo "Increasing memory available to gradle for android java build"
echo "org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" >> android/gradle.properties
# A general react-native Java build tweak - or gradle runs out of memory sometimes - not needed with RN68+
#echo "Increasing memory available to gradle for android java build"
#echo "org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8" >> android/gradle.properties

# A quirk of this example, sometimes we have local example-specific patches
echo "Running any patches necessary to compile successfully"
Expand All @@ -71,10 +72,13 @@ rm ./App.js && cp ../NotifeeApp.js ./App.js
sed -i -e $'s/react_native_post_install(installer)/react_native_post_install(installer)\\\n\\\n installer.pods_project.targets.each do |target|\\\n target.build_configurations.each do |config|\\\n config.build_settings["CC"] = "clang"\\\n config.build_settings["LD"] = "clang"\\\n config.build_settings["CXX"] = "clang++"\\\n config.build_settings["LDPLUSPLUS"] = "clang++"\\\n end\\\n end/' ios/Podfile
rm -f ios/Podfile??

# This makes the iOS build much quieter. In particular libevent dependency, pulled in by react core / flipper items is ridiculously noisy.
sed -i -e $'s/react_native_post_install(installer)/react_native_post_install(installer)\\\n \\\n installer.pods_project.targets.each do |target|\\\n target.build_configurations.each do |config|\\\n config.build_settings["GCC_WARN_INHIBIT_ALL_WARNINGS"] = "YES"\\\n end\\\n end/' ios/Podfile

# Run the thing for iOS
if [ "$(uname)" == "Darwin" ]; then
echo "Installing pods and running iOS app"
npx pod-install
npm_config_yes=true npx pod-install

npx react-native run-ios

Expand Down

0 comments on commit 31ad7c9

Please sign in to comment.