Created
November 1, 2018 01:41
-
-
Save SunXiaoShan/5ca1fd9c8592b8d4dd08880ea481b819 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check tool | |
if test "x$(which mobiledevice)" = "x"; then | |
echo "install mobiledevice" | |
brew install mobiledevice | |
fi | |
# query mobile list then pick up the first one | |
MOBILE_UUID=$( bash <<EOF | |
/usr/local/bin/mobiledevice list_devices -n 1 | |
EOF | |
) | |
if [[ ! ${MOBILE_UUID} ]]; then | |
exit | |
fi | |
read -p 'Project name: ' PROJECT_NAME | |
PlistPath="Info.plist" | |
# function | |
Build_Mobile_App(){ | |
# set up initial value | |
APP_NAME=$1 | |
URL_SCHEME="$APP_NAME" | |
APP_PATH="./build/Release-iphoneos/$APP_NAME.app" | |
# set up | |
URL_SCHEME_VALUE="Add CFBundleURLTypes:0:CFBundleURLSchemes:0 string $URL_SCHEME" | |
cd "$PROJECT_NAME" | |
/usr/libexec/PlistBuddy -c "Delete CFBundleURLTypes:0:CFBundleURLSchemes" "$PlistPath" | |
/usr/libexec/PlistBuddy -c 'Add CFBundleURLTypes:0:CFBundleURLSchemes array' "$PlistPath" | |
/usr/libexec/PlistBuddy -c "$URL_SCHEME_VALUE" "$PlistPath" | |
cd .. | |
# build code | |
xcodebuild PRODUCT_NAME="$APP_NAME" PRODUCT_BUNDLE_IDENTIFIER="$APP_NAME" build | |
# install app into mobile | |
mobiledevice install_app -u $MOBILE_UUID $APP_PATH | |
} | |
for i in {1..3}; | |
do | |
app_name="Test$i" | |
result=$(Build_Mobile_App $app_name) | |
echo $app_name | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment