cool hit counter ios multi-channel packaging + automation_Intefrankly

ios multi-channel packaging + automation


Currently the company has a requirement that our app should be multi-channel, previously one app but now the customer requires the respective channel package to use the self server address. That is, where there was one packet before, there are now potentially dozens and hundreds of them.

The same set of code, typed out in multiple enterprise packages, which are applied differently as follows.

  • Application Name
  • Bundle id
  • icon
  • launch image
  • The functionality is slightly different, for example, the key of the third-party sdk is different.
  • Different server addresses

If achieved. Currently there are only two ways to package on the internet, one is to package all of them, and the other is to package only one master package and then modify the plist file, icon, launch image

Depending on the business requirements, both packaging methods may be used, and I'll describe both below

All packaged, is the multi-Target way, here on the description, about multi-Target can search for their own related content

#!/bin/sh

echo "~~~~~~~~~~~~~~~~~~~~  Start executing the packing script ~~~~~~~~~~~~~~~~~~~~"

##########################  Basic project information configuration ###########################
# circular array, Name of the channel to be packaged, separated by a space
channelArray=("Channel1" "Channel2")
# Project path
MWBuildDir="Users/Destiny/Desktop/wamingdaqi"
# Project Name
projectName="MeteorologicalMonitoring"
#ExportOptions.plist  trails
exportOptionsPlistPath="/Users/Destiny/Desktop/BuildIpa/BuildShell/ExportOptions.plist"
#Release orDebug
buildConfiguration="Release"
#Ipa Export path
IpaExportPath="/Users/Destiny/Desktop/WamingIpa"


    for ((i=0;i<${#channelArray};i++))
    do
    echo  ${channelArray[$i]}

    targetName=${channelArray[$i]}

    echo  $projectName
    echo  $targetName

    # compile
    xcodebuild archive -workspace ${projectName}.xcworkspace -scheme ${targetName} -configuration ${buildConfiguration} -sdk "iphoneos" clean archive -archivePath ./ArchivePath/${targetName}.xcarchive
    # generateipa
    xcodebuild -exportArchive -archivePath ./ArchivePath/${targetName}.xcarchive -exportOptionsPlist ${exportOptionsPlistPath} -exportPath ${IpaExportPath}


    #xcodebuild archive -workspace MeteorologicalMonitoring.xcworkspace -scheme WamingJinshan -configuration Release -sdk "iphoneos" clean archive -archivePath ./ArchivePath/WamingJinshan.xcarchive

 done

The disadvantage of this type of packaging is slow, if there are 100 channels to play 100 times, the advantage is that the multi-Target approach each channel at a glance.

 Two problems may be encountered
 1.Executing a shell script in the terminal may report an error about not having permissions
 Workaround: chmod +x /path/xxx.sh

 2.What is ExportOptions.plist?
 Please refer to:https://blog.csdn.net/lovechris00/article/details/79141752

The second way is to create a package first and then modify the plist icon

#!/bin/sh

#  Script.sh
#  MPackage
#
#  Created by Destiny on 2018/7/11.
#  Copyright © 2018 year Destiny. All rights reserved.


# 1.Configuration Info

 # Project path needs to be modified
projectDir="/Users/Destiny/Desktop/BuildIpafast"

 # Package generation path needs to be modified
ipaPath="/Users/Destiny/Desktop/WamingIpa"

 # Icon path needs to be modified
iconPath="/Users/Destiny/Desktop/BuildIpafast/AppIcon"

# Project Name
projectName="MeteorologicalMonitoring"

# Scheme Name
schemeName="MeteorologicalMonitoring"

exportOptionsPlistPath="/Users/Destiny/Desktop/BuildIpafast/AutoBuildIpaShell/ExportOptions.plist"

#############

 # Version number
bundleVersion="2.0.0"

# Select the packing serial number  multiple choice then separated by a space  as if("1" "2" "3")
appPackNum=("1")

 # Dandelion distribution parameters No distribution can be ignored Default no distribution The two KEYs below are the default test URLs corresponding to KEY
ISUPLOAD=0
USERKEY="xxx"
APIKEY="xxx"

 # --------------------------- optional If you need to replace the app's icon ---------------------------------

#  configureApp Information arrays  format:"AppName( and in the worksappInfo.Plist corresponds)" "icon"
#Schemes:
#        1.app1 app1Icon
#        2.app2 app2Icon
#        3.app3 app3Icon

# --------------------------------------------------------------------------------------- #

 # of packages
appPackNumLength=${#appPackNum[*]}

appNameInfos=(
    "Channel1Name"
    "Channel2Name"
)

appIconInfos=(
    "AppIcon"
    "AppIconShuangliu"
)

appChannelInfos=(
    "jinshan"
    "shuangliu"
)

appBundleInfos=(
    "com.xxxxx.xxx"
    "com.xxxxx.xxx"
)

appInfosLength=${#appBundleInfos[*]}


 # Generate APP paths
buildDir="build/Release-iphoneos"

 # Start time
beginTime=`date +%s`

 # Create a packing directory
mkdir ${ipaPath}/allChannelIpa

 # Path to local storage of all IPAs
allIPAPackPath="${ipaPath}/allChannelIpa"

 # Clear the cache
rm -rf ${projectDir}/$buildDir

 # Build to generate APP
xcodebuild archive -workspace ${projectName}.xcworkspace -scheme ${schemeName} -configuration Release -sdk iphoneos clean  -archivePath ${projectDir}/build/${schemeName}.xcarchive

if [[ $? = 0 ]]; then
echo "33[31m  compile success
 33[0m"
else
echo "33[31m  compile failures
 33[0m"
fi

 # Create the payload folder first
mkdir ${ipaPath}/Payload
 # Move the compiled app to the Payload folder
cp -Rf ${projectDir}/build/${schemeName}.xcarchive ${ipaPath}/Payload
if [[ $? = 0 ]]; then
echo "33[31m app Mobile Success
 33[0m"
else
echo "33[31m app Failure to move
 33[0m"
fi


 # ---- all packaged ----
for (( i=0; i<appInfosLength; i++ )); do


# App Bundle Name (CFBundleName)
appName=${appNameInfos[${i}]}

# App DisPlay Name
appDisplayName=${appNameInfos[${i}]}

# App Icon Name
appIconName=${appIconInfos[${i}]}

# App Download Name
appChannelName=${appChannelInfos[${i}]}

# App Bundle id
appBundleId=${appBundleInfos[${i}]}


 # Create different app ipa directories
mkdir $allIPAPackPath/${appChannelName}
rm -rf $allIPAPackPath/${appChannelName}}/*

echo "33[31m appName:$appName appIconName:$appIconName appChannelName:$appChannelName bundleID:$appBundleId 
 33[0m"

 # Copy the corresponding icon to the directory of the app to be modified
 # The path to the corresponding Applications file under the .xcarchive file
Applications_Path=$ipaPath/Payload/${schemeName}.xcarchive/Products/Applications
cp -Rf $iconPath/$appIconName/* $Applications_Path/*.app

if [[ $? = 0 ]]; then
echo "33[31m  modify icon  success33[0m"
else
echo "33[31m  modify icon  failures33[0m"
fi

 # Modify Plist
 # plist path
infoPlist_File_Path=$Applications_Path/*.app/info.plist

/usr/libexec/PlistBuddy -c "Set :CFBundleName  $appName" $infoPlist_File_Path
/usr/libexec/PlistBuddy -c "Set :CFBundleDisplayName  $appDisplayName" $infoPlist_File_Path
/usr/libexec/PlistBuddy -c "Set :CFBundleIdentifier  $appBundleId" $infoPlist_File_Path
/usr/libexec/PlistBuddy -c "Set :Channel  $appChannelName" $infoPlist_File_Path


if [[ $? = 0 ]]; then
echo "33[31m  modify Plist  success33[0m"
else
echo "33[31m  modify Plist  failures33[0m"
fi

 # Resignatures
#codesign -f -s "iPhone Distribution: Beijing Waming Environmental Technology Co., Ltd"  --entitlements $exportOptionsPlistPath ${ipaPath}/Payload/${schemeName}.app
#if [[ $? = 0 ]]; then
#echo "33[31m  Signature successful
 33[0m"
#else
#echo "33[31m  Signature failure
 33[0m"
#fi

 # Generate ipa
xcodebuild -exportArchive -archivePath ${ipaPath}/Payload/${schemeName}.xcarchive -exportOptionsPlist ${exportOptionsPlistPath} -exportPath ${allIPAPackPath}/$appChannelName


if [[ $? = 0 ]]; then
echo "33[31m 
  Generate IPA Success 




33[0m"
else
echo "33[31m 
  Generate IPA Failure 




33[0m"
fi


 # Mobile
#mv ${ipaPath}/$appChannelName.ipa ${allIPAPackPath}/$appName


 # 6. Upload the Dandelion distribution platform

if [[ $ISUPLOAD = 1 ]]; then
echo " Uploading dandelion now..."
curl -F "file=@$allIPAPackPath/$appName/$appChannelName.ipa" -F "uKey=$USERKEY" -F "_api_key=$APIKEY" http://www.pgyer.com/apiv1/app/upload

fi

done

 # Clear extraneous documents
rm -rf ${ipaPath}/Payload

 # Ending time
endTime=`date +%s`
echo -e " Wrapping time$[ endTime - beginTime ] second"

There's a problem that needs attention.

xxx.xcarchive Right-click to show what's included,Products->Applications->xxxx-> Right-click to show what's included-> make a copy ofApp Icon documents, To be replacedIcon Follow this nomenclature to

The scripts are very simple and have been tested and packaged without problems, please leave a comment if you have any questions


Recommended>>
1、ES6 minimalist tutorial ES6Tutorial Article Donghai Chen Guangjian ES6 minimalist tutorial ES6Tutorial Kotlin developer community
2、LogEase A Practical Path to IT Operations and Maintenance Analytics and Massive Log Search above
3、Jingdong layout drone flying service is the industry development needs or another plan
4、LongPolling Long Polling Explained
5、Sieve method for prime numbers

    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号