importos
importsys
importtime
importhashlib
importargparse
importsubprocess
importrequests
fromemailimportencoders
fromemail.headerimportHeader
fromemail.mime.textimportMIMEText
fromemail.utilsimportparseaddr, formataddr
importsmtplib
# configuration for pgyer
PGYER_UPLOAD_URL ="https://qiniu-storage.pgyer.com/apiv1/app/upload"
USER_KEY ="da93ac1c4ae3f9ad0a7ca304de08e211"
API_KEY ="6b505388748ebc3c6d66432fb95cba2c"
# 項(xiàng)目根目錄
project_path ="/Users/user/Desktop/cornerstone/TncObj"
# 編譯成功后.app所在目錄
app_path ="/Users/user/Desktop/cornerstone/TncObj/build/Release-iphoneos/TncObj.app"
# 指定項(xiàng)目下編譯目錄
build_path ="build"
# 打包后ipa存儲(chǔ)目錄
targerIPA_parth ="/Users/user/Desktop"
# 清理項(xiàng)目 創(chuàng)建build目錄
defclean_project_mkdir_build():
os.system('cd %s;xcodebuild clean'% project_path)# clean 項(xiàng)目
os.system('cd %s;mkdir build'% project_path)
defbuild_project():
print("build release start")
# os.system ('cd %s;xcodebuild -list'%project_path)
print("2")
os.system ('cd %s;xcodebuild -project TncObj.xcodeproj -target TncObj -configuration Release'% (project_path))
print("3")
defbuild_ipa():
globalipa_filename
ipa_filename = time.strftime('TncObj_%Y-%m-%d-%H-%M-%S.ipa',time.localtime(time.time()))
os.system ('xcrun -sdk iphoneos PackageApplication -v %s -o %s/%s'% (app_path,targerIPA_parth,ipa_filename))
defuploadIpaToPgyer():
globalipaPath
ipaPath = ('/Users/user/Desktop/TncObj_2017-09-22-16-59-24.ipa')
# ipaPath = open("ipaPath","r", encoding="utf-8")
print(ipaPath)
os.system('curl -F "file=@%s"\
-F "uKey=%s"\
-F "_api_key=%s"\
-F "appType=1"\
%s'% (ipaPath,USER_KEY,API_KEY,PGYER_UPLOAD_URL))
defmain():
# 清理并創(chuàng)建build目錄
clean_project_mkdir_build()
# 編譯coocaPods項(xiàng)目文件并 執(zhí)行編譯目錄
? build_project()
# 打包ipa 并制定到桌面
build_ipa()
uploadIpaToPgyer()
# 執(zhí)行
main()
具體可參考蒲公英提供的API:飛機(jī)票