-
Notifications
You must be signed in to change notification settings - Fork 0
/
initReactNativeSampleApp.sh
executable file
·104 lines (79 loc) · 3.12 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
#!/bin/bash
blink_card_plugin_path=`pwd`/BlinkCard
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 blinkcard-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_card_plugin_path
npm install --save microblink-blinkcard-react-native-2.10.1.tgz
#pushd node_modules
#ln -s $blinkcard_plugin_path blinkcard-react-native
#popd
else
# download npm package
echo "Downloading blinkcard-react-native module"
npm install --save @microblink/blinkcard-react-native
fi
# react-native-image-picker plugin needed only for sample application with DirectAPI to get the card 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
# 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: open $appName/ios/$appName.xcworkspace; set your development team; add Privacy - Camera Usage Description and Privacy - Photo Library Usage Description keys to your info.plist file and press run"