代码拉取完成,页面将自动刷新
#!/usr/bin/env bash
#用法 ./doc/package.md
CORDOVA_PATH=$( cd "$( dirname "$0" )" && pwd -P)
#参数获取
INDEX=0
for param in $*
do
# echo $INDEX "--" $param
array[$INDEX]=$param
INDEX=$[ $INDEX+1 ]
done
PROJECT_PATH=${array[0]}
OBJECT_PATH=${array[1]}
p12=${array[2]}
p12Password=${array[3]}
mobileprovision=${array[4]}
schemeTarget=${array[5]}
keychain=${array[6]}
# # 检测是否存在Podfile
# isHavePodfile=$( ls "$PROJECT_PATH" | grep Podfile )
# if [ -n "$isHavePodfile" ]; then
#
# # 检测是否安装了pod
# isHavePod=$( which pod )
# if [ -z "$isHavePod" ]; then
# echo "pod不存在,请先安装pod"
# exit 1
# fi
#
# isHavePodfileLock=$( ls "$PROJECT_PATH" | grep Podfile.lock )
# cd "$PROJECT_PATH"
# if [ -n "$isHavePodfileLock" ];then
# echo "存在Podfile.lock文件"
# pod update
# else
# echo "不存在Podfile.lock文件"
# #开始安装依赖项
# pod install
# fi
#
# fi
#安装p12
echo "-------------------------------------安装p12证书-------------------------------------------"
if [ -z "$p12" ]; then
echo "请输入p12的地址"
exit 1
else
if [ -z "$p12Password" ]; then
echo "请输入p12的密码"
exit 1
else
echo $p12Password
#创建钥匙链
# security create-keychain -p foreveross foreveross.keychain
#解锁,否则回弹框等待输入密码
#security unlock-keychain -u login.keychain
security unlock-keychain -p '$keychain' /Users/BSL/Library/Keychains/login.keychain
#导入证书到keychain中
security import $p12 -k login.keychain -P "$p12Password" -T /usr/bin/codesign
fi
fi
#安装mobileprovision证书
echo "-------------------------------------安装mobileprovision证书-------------------------------------------"
if [ -n "$mobileprovision" ]; then
echo "mobileprovision: $mobileprovision"
uuid=`grep UUID -A1 -a ${mobileprovision} | grep -io "[-A-Z0-9]\{36\}"`
output=~/Library/MobileDevice/Provisioning\ Profiles/$uuid.mobileprovision
dir=~/Library/MobileDevice/Provisioning\ Profiles
if [ ! -d "$dir" ]; then
echo "新建文件夹:$dir"
cd ~/Library/MobileDevice/
mkdir -p "$dir"
fi
cp "$mobileprovision" "$output"
echo "Found UUID $uuid"
else
echo "请输入mobileprovision的地址"
exit 1
fi
# 查看uuid是否获取
if [ -z "$uuid" ]; then
echo "没有获取到uuid,请查看输入的mobileprovision证书地址是否正确"
exit 1
fi
if [ -z "$schemeTarget" ]; then
echo "如果你的项目为workspace,请输入scheme;如果你的项目为projece,请输入target"
exit 1
fi
"$CORDOVA_PATH/clean" $PROJECT_PATH $schemeTarget
#编译
mkdir "$OBJECT_PATH/archive"
"$CORDOVA_PATH/build" $PROJECT_PATH $schemeTarget --device $uuid|| exit $?
echo "-----------------------------------开始打包-----------------------------------------"
# 判断是否存在workspace 并获取相应的项目信息
if [ ! $( ls "$PROJECT_PATH" | grep .xcworkspace ) ]; then
#项目名称
XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj )
PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
xcodebuild archive -project "$PROJECT_PATH/$PROJECT_NAME.xcodeproj" -scheme "$schemeTarget" -archivePath "$PROJECT_PATH/build/device/$PROJECT_NAME.xcarchive"
xcodebuild -exportArchive -archivePath "$PROJECT_PATH/build/device/$PROJECT_NAME.xcarchive" -exportPath "$OBJECT_PATH/archive/app.ipa" -exportFormat ipa PROVISIONING_PROFILE=$uuid
else
#获取项目空间相应信息
XCWORKSPACE=$( ls "$PROJECT_PATH" | grep .xcworkspace )
XCWORKSPACE_NAME=$(basename "$XCWORKSPACE" .xcworkspace)
xcodebuild archive -workspace "$PROJECT_PATH/$XCWORKSPACE_NAME.xcworkspace" -scheme "$schemeTarget" -archivePath "$PROJECT_PATH/build/device/$XCWORKSPACE_NAME.xcarchive"
xcodebuild -exportArchive -archivePath "$PROJECT_PATH/build/device/$XCWORKSPACE_NAME.xcarchive" -exportPath "$OBJECT_PATH/archive/app.ipa" -exportFormat ipa PROVISIONING_PROFILE=$uuid
fi
# # 判断是否存在workspace 并获取相应的项目信息
# if [ ! $( ls "$PROJECT_PATH" | grep .xcworkspace ) ]; then
# #项目名称
# XCODEPROJ=$( ls "$PROJECT_PATH" | grep .xcodeproj )
# PROJECT_NAME=$(basename "$XCODEPROJ" .xcodeproj)
# exec xcodebuild -xcconfig "$CORDOVA_PATH/build.xcconfig" -project "$PROJECT_NAME.xcodeproj" ARCHS="armv7 armv7s arm64" -target "$schemeTarget" -configuration $CONFIGURATION -sdk iphoneos build VALID_ARCHS="armv7 armv7s arm64" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build/device" PROVISIONING_PROFILE=$uuid
# else
# #获取项目空间相应信息
# XCWORKSPACE=$( ls "$PROJECT_PATH" | grep .xcworkspace )
# XCWORKSPACE_NAME=$(basename "$XCWORKSPACE" .xcworkspace)
# exec xcodebuild -xcconfig "$CORDOVA_PATH/build.xcconfig" -workspace "$XCWORKSPACE_NAME.xcworkspace" ARCHS="armv7 armv7s arm64" -scheme "$schemeTarget" -configuration $CONFIGURATION -sdk iphoneos build VALID_ARCHS="armv7 armv7s arm64" CONFIGURATION_BUILD_DIR="$PROJECT_PATH/build/device" PROVISIONING_PROFILE=$uuid
# fi
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。