-
Notifications
You must be signed in to change notification settings - Fork 59
/
initReactNativeSampleApp.sh
executable file
·111 lines (85 loc) · 3.18 KB
/
initReactNativeSampleApp.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
#!/bin/bash
blink_id_plugin_path=`pwd`/BlinkID
appName=Sample
# remove any existing code
rm -rf $appName
# create a sample application
# https://github.com/react-native-community/cli#using-npx-recommended
npx @react-native-community/cli init $appName --version="0.75" || exit 1
# enter into demo project folder
pushd $appName || exit 1
IS_LOCAL_BUILD=false || exit 1
if [ "$IS_LOCAL_BUILD" = true ]; then
echo "Using blinkid-react-native from this repo instead from NPM"
# use directly source code from this repo instead of npm package
# from RN 0.57 symlink does not work any more
npm pack $blink_id_plugin_path
npm install --save blinkid-react-native-6.12.0.tgz
#pushd node_modules
#ln -s $blink_id_plugin_path blinkid-react-native
#popd
else
# download npm package
echo "Downloading blinkid-react-native module"
npm install --save blinkid-react-native
fi
# react-native-image-picker plugin needed only for sample application with DirectAPI to get the document images
npm install react-native-image-picker
# Auto-linking is done in 0.6 versions
# enter into android project folder
pushd android || exit 1
# patch the build.gradle to add "maven { url https://maven.microblink.com }"" repository
perl -i~ -pe "BEGIN{$/ = undef;} s/maven \{/maven \{ url 'https:\\/\\/maven.microblink.com' }\n maven {/" build.gradle
# change package name
# adb uninstall "com.microblink.sample"
mkdir -p app/src/main/java/com/microblink/sample
mkdir -p app/src/debug/java/com/microblink/sample
mv app/src/main/java/com/sample/* app/src/main/java/com/microblink/sample/
mv app/src/debug/java/com/sample/* app/src/debug/java/com/microblink/sample/
rmdir app/src/main/java/com/sample
rmdir app/src/debug/java/com/sample
grep -rl com.sample . | xargs sed -i '' s/com.sample/com.microblink.sample/g
./gradlew clean
# return from android project folder
popd
# enter into ios project folder
pushd ios || exit 1
#Force minimal iOS version
#sed -i '' "s/platform :ios, min_ios_version_supported/platform :ios, '13.0'/" Podfile
# install pod
pod install
# if [ "$IS_LOCAL_BUILD" = true ]; then
# echo "Replace pod with custom dev version of BlinkID framework"
# replace pod with custom dev version of BlinkID framework
# pushd Pods/PPBlinkID || exit 1
# rm -rf Microblink.bundle
# rm -rf Microblink.framework
# cp -r ~/Downloads/blinkid-ios/Microblink.framework ./
# popd
# fi
# change bundle id
sed -i '' s/\$\(PRODUCT_BUNDLE_IDENTIFIER\)/com.microblink.sample/g $appName/Info.plist
#Disable Flipper since it spams console with errors
export NO_FLIPPER=1
pod install
# return from ios project folder
popd
# remove index.js
rm -f index.js
# remove index.ios.js
rm -f index.ios.js
# remove index.android.js
rm -f index.android.js
cp ../sample_files/index.js ./
# use the same index.js file for Android and iOS
cp index.js index.ios.js
cp index.js index.android.js
# return to root folder
popd
echo "Go to React Native project folder: cd $appName"
echo "To run on Android execute: npx react-native run-android"
echo "To run on iOS:
1. Open $appName/ios/$appName.xcworkspace
2. Set your development team
3. Add the NSCameraUsageDescription & NSPhotoLibraryUsageDescription keys to your Info.plist file
4. Press run"