forked from mikehardy/rnfbdemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notifee-demo.sh
executable file
·131 lines (105 loc) · 6.21 KB
/
notifee-demo.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/bash
set -e
# Basic template create, notifee install, link
\rm -fr notifeedemo notifeewebdemo
echo "Testing react-native $RNVERSION + notifee current"
RNVERSION=0.68.2
npm_config_yes=true npx react-native init notifeedemo --version=$RNVERSION --skip-install
cd notifeedemo
# New versions of react-native include annoying Ruby stuff that forces use of old rubies. Obliterate.
if [ -f Gemfile ]; then
rm -f Gemfile* .ruby*
fi
# Now run our initial dependency install
yarn
npm_config_yes=true npx pod-install
# Notifee requires minimum sdk of 20
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
sed -i -e $'s/compileSdkVersion = 28/compileSdkVersion = 31/' android/build.gradle
sed -i -e $'s/targetSdkVersion = 28/targetSdkVersion = 31/' android/build.gradle
sed -i -e $'s/compileSdkVersion = 29/compileSdkVersion = 31/' android/build.gradle
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??
# 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')
if [ "$MRNBP_VERSION" == '^0.51.1' ]; then
echo "Bumping old metro-react-native-babel-preset version to something that works with modern babel."
yarn add metro-react-native-babel-preset@^0.59 --dev
fi
# This is the most basic integration - adding the package - local maven repo not needed with modern notifee
echo "Adding Notifee app package"
yarn add "@notifee/react-native"
# 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"
cp -rv ../patches .
npm_config_yes=true npx patch-package
# Copy in our demonstrator App.js
echo "Copying demonstrator App.js"
rm ./App.js && cp ../NotifeeApp.js ./App.js
# This is just a speed optimization, very optional, but asks xcodebuild to use clang and clang++ without the fully-qualified path
# That means that you can then make a symlink in your path with clang or clang++ and have it use a different binary
# In that way you can install ccache or buildcache and get much faster compiles...
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"
npm_config_yes=true npx pod-install
npx react-native run-ios
# Example-specific path workaround for poorly setup Android SDK environments
USER=$(whoami)
echo "sdk.dir=/Users/$USER/Library/Android/sdk" > android/local.properties
fi
# Example-specific build tweaks so we really exercise the module in release mode
echo "Configuring Android release build for ABI splits and code shrinking"
sed -i -e $'s/def enableSeparateBuildPerCPUArchitecture = false/def enableSeparateBuildPerCPUArchitecture = true/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/def enableProguardInReleaseBuilds = false/def enableProguardInReleaseBuilds = true/' android/app/build.gradle
rm -f android/app/build.gradle??
sed -i -e $'s/universalApk false/universalApk true/' android/app/build.gradle
rm -f android/app/build.gradle??
# Run it for Android (assumes you have an android emulator running)
echo "Running android app in release mode"
pushd android
./gradlew uninstallRelease
popd
npx react-native run-android --variant release --no-jetifier
# Let it start up, then uninstall it (otherwise ABI-split-generated version codes will prevent debug from installing)
sleep 10
pushd android
./gradlew uninstallRelease
popd
# may or may not be commented out, depending on if have an emulator available
# I run it manually in testing when I have one, comment if you like
echo "Running android app in debug mode"
npx react-native run-android --no-jetifier
cd ..
# Test web
echo "Running android app in web mode"
npm_config_yes=true npx react-native init notifeewebdemo --template criszz77/luna --skip-install
cd notifeewebdemo
yarn
yarn add @notifee/react-native
# A quirk of this example, sometimes we have local example-specific patches
echo "Running any patches necessary to compile successfully"
cp -rv ../patches .
npm_config_yes=true npx patch-package
# Copy in our demonstrator App.js
echo "Copying demonstrator App.js"
rm -f ./src/App.tsx && cp ../NotifeeApp.js ./src/App.tsx
yarn web