Before using Fastlane to add PGYER automatic packaging, recently found that there are always problems with the update, so I had the idea of making a shell of my own. Less code, but very useful.

  • packaging
  • The export of ipa
  • Upload pgyer

Package automatically upload PGYER

#! /bin/bash
#xcodebuild archive -project 'test.xcodeproj' -configuration 'Debug' -scheme 'BLTSZY' -archivePath './app.xcarchive' LIBRARY_SEARCH_PATHS="./Pods/../build/**  ./BLTSZY/**"
proName='your project name'
proURL="your project path"#like /Users/Jerry/Desktop/ios_afu
api_key=' '#pgyer api_key
configuration='Debug' #Release 
autoPlus(){
path=${proURL}/${proName}/${proName}/Info.plist
number=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${path}")
BundleVersion=$(( $number + 1 ))
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $BundleVersion" "${path}"
}
# packaged
arch() {echo 'Start compiling Pods'
    xcodebuild -project Pods/Pods.xcodeproj build
    echo 'Start compiling project'

xcodebuild -archivePath "./build/${proName}.xcarchive" -workspace $proName.xcworkspace -sdk iphoneos -scheme $proName -configuration $configuration archive
autoPlus
}
# export of ipa
exportIPA() {echo 'Start exporting IPA'
    xcodebuild -exportArchive -archivePath "./build/${proName}.xcarchive" -exportPath './app' -exportOptionsPlist './ExportOptions.plist'
}
# Upload IPA to Dandelion
upload() {if [ -e "${proURL}/app/${proName}.ipa" ]
then
    echo 'Start uploading IPA/APK to Dandelion'
    curl -F "file=@${proURL}/app/${proName}.ipa" -F "_api_key=${api_key}" 'http://www.pgyer.com/apiv2/app/upload'
else
    echo "In the contents:${proURL}/app/${proName}. Ipa does not exist"
fi
}
startarch(){
    arch
    if(($? = = 0))then
        echo 'archive success 🍺'
        startExportIPA
    else
        echo 'archive faild ❌'
    fi
}
startExportIPA() {exportIPA
    if(($? = = 0))then
        echo 'exportIPA success 🍺 🍺'
        startUPLoadIPA
    else
        echo 'exportIPA faild ❌'
    fi
}
startUPLoadIPA(){
    upload
    if(($? = = 0))then
        echo 'uploadIPA success'
    else
        echo 'uploadIPA faild ❌'
    fi
}


if (($#= = 0))#then
# startarch
#elif (($# == 1))
then
        while :
        do
        echo '🍺 🍺 🍺 * * * * * * * * * * * * * * * * * * * * * * * 🍺 🍺 🍺'
        echo  "Enter numbers between 1 and 4 :"
        echo  "Enter 1: Compile package from start to finish"
        echo  "Input 2: Start from export IPA to end"
        echo  "Enter 3: Start to finish uploading IPA"
        echo  "Enter 4: Exit"
        read a
        case $a in
            1)startarch
            break;;
            2)startExportIPA
            break;;
            3)startUPLoadIPA
            break;;
            4) break;;
        esac
        done
fi

Copy the code

Drag the file and plis to the project directory and configure the PLIS file:

<? xml version="1.0" encoding="UTF-8"? > <! DOCTYPE plist PUBLIC"- / / / / DTD PLIST Apple 1.0 / / EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>compileBitcode</key>
	<false/>
	<key>method</key>
	<string>ad-hoc</string>
	<key>provisioningProfiles</key>
	<dict>
		<key>your bundle id</key>
		<string>your .mobileprovsion</string>
	</dict>
	<key>signingCertificate</key>
	<string>iPhone Distribution</string>
	<key>signingStyle</key>
	<string>manual</string>
	<key>stripSwiftSymbols</key>
	<true/> <key>teamID</key> <string>your_team_id</string> <key>thinning</key> <string>&lt; none&gt; </string> </dict> </plist>Copy the code

Download setup.sh and drag it into the project folder, then run./setup.sh to complete the upload to the PGYER website. See the source code download page for detailed configuration properties. View the source code