背景
安装 fastlane
安装fastlane brew install fastlane
切记及时更新 brew upgrade fastlane
,否则可能会出现无法使用的情况 终端切换到ios工程目录中 fastlane init
,项目中会生成fastlane文件夹 配置文件夹中的各个文件 Appfile Fastfile Pluginfile report.xml
Appfile
app_identifier "com.alex.luan"
apple_id "apple@alex.org"
itc_team_id "---"
team_id "----"
for_platform :ios do
team_id '----'
for_lane :enterprise_lane do
app_identifier 'com.alex.luan'
apple_id 'apple@alex.org'
end
end
Pluginfile
gem 'fastlane-plugin-versioning'
gem 'fastlane-plugin-firim'
gem 'fastlane-plugin-firim'
Fastfile
fastlane_version "2.46.1"
default_platform( :ios )
platform :ios do
before_all do
ENV [ "FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT" ] = "120"
ENV [ "FASTLANE_XCODEBUILD_SETTINGS_RETRIES" ] = "10"
ENV [ "FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD" ] = "utxu-qjuy-naod-cjzb"
ENV [ "FASTLANE_SESSION" ] = '---\n- !ruby/object:HTTP::Cookie\n name: DES5dfb75937bfd0785ae220bd99a538a2d3\n value: HSARMTKNSRVXWFlaDFXOojeRi4mcyoDMT7RqoN+1mMyhff6DMF3shWx5R7fnBbBXQ3hjWyhW5gb/UOPhvY1TuJ3blI/c5yfuJF6Lw6ATJyrhjC0KX1HCaJmCwYwZcRsVISdlHsg=SRVX\n domain: idmsa.apple.com\n for_domain: true\n path: "/"\n secure: true\n httponly: true\n expires: \n max_age: 2592000\n created_at: &1 2020-07-02 13:31:13.758967000 +08:00\n accessed_at: *1\n- !ruby/object:HTTP::Cookie\n name: myacinfo\n value: DAWTKNV255b0fa2057b29c130c58a5ebe33ad360312d10e68281dcc91c7422c47d003008c81182a6c34624a90a1697e9e5c5871730e173a9c77d78cfe2aa9f095a5d3b0d109b231b116158195469a8c5f607dc5728e059778e38d4d2d4b0f9b8fe2f4661d5654a761e50737f6e194c36fc720025e16d25910e3fbc11e70524cbc957a5eb15043dff18a3a11783673b9eb82964fc84cd793f96f083e06692380cebfef11c9efc1d13faffc7b4b35bf8c2b4b51d5b4c2a63ed2b904c6e11a46e430693042f13d2352c1173eed15bc062607d0d5513e1068f69468472ffec5b20119c08f38f946e3c97900f6401aeb2fbc672e10a667e53b003ef477913328dcac82a4c7fa2f75f58ac155083b0e611831436a6da7943024f01634513e1a7d1dcc87163ae7cb9ba3fddc3e0b548f88ab2cbd50893731237055ffdbe522de490e42ea8490dc4b4704ed771ded345ab646f8ddd4b0407169a526cc41012fcb6fc6f6df9da06c3e62eec2fd061089faed17023cd1f5eb7c0eafe5907a06f69b9c869af62405a174534da267a2b44b5e615f4f97f37a902469979036b8d5386de632b57391446cd4de4adcb67156b87b7bf308865624b231ebd18d3fa7d3cc35b3c3c7110ccaec49c341a7968d3873f832b019183c86712973bf712fee80c10ff901984abeafdc97e34a93843dc43b9acbcf5251e1064d78cecbcb0cedbbe58457af903e2424668e24c438274740ca3c810814afd58f26361346334376364643037643636376637333238326131313239666635363930356263313435306230MVRYV2\n domain: apple.com\n for_domain: true\n path: "/"\n secure: true\n httponly: true\n expires: \n max_age: \n created_at: 2020-07-02 13:31:13.759140000 +08:00\n accessed_at: 2020-07-02 13:31:13.766133000 +08:00\n- !ruby/object:HTTP::Cookie\n name: dqsid\n value: eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE1OTM2Njc4NzQsImp0aSI6IlAyVTA4OEY0cGl4QjlrOU1XamFkRUEifQ.jPri0PXSYXWLsBHMXwqUUp2yux-KtO8pMX1609EyUIU\n domain: appstoreconnect.apple.com\n for_domain: false\n path: "/"\n secure: true\n httponly: true\n expires: \n max_age: 1800\n created_at: &2 2020-07-02 13:31:15.819130000 +08:00\n accessed_at: *2\n'
end
def updateProjectBuildNumber
currentTime = Time . new . strftime( "%Y%m%d%H%M%S" )
build = get_build_number( )
if build. include ? "#{ currentTime} ."
lastStr = build[ build. length- 2. . build. length- 1 ]
lastNum = lastStr. to_i
lastNum = lastNum + 1
lastStr = lastNum. to_s
if lastNum < 10
lastStr = lastStr. insert( 0 , "0" )
end
build = "#{ currentTime} .#{ lastStr} "
else
build = "#{ currentTime} "
end
puts( "*************| 更新build #{ build} |*************" )
increment_build_number(
build_number: "#{ build} "
)
end
scheme= "scheme"
platform :ios do
update_app_identifier(
app_identifier: "com.alex.luan" ,
plist_path: "iosproject/Info.plist" ,
)
ENV [ "EXPORTOPTIONSPLIST" ] = "/Users/xxxxx/.jenkins/workspace/WillJob/ExportOptions.plist"
def sendEmail ( title, content)
puts( "will send email title: #{ title} content: #{ content} " )
system "python ../sendemail.py '#{ title} ' '#{ content} '"
end
lane :test do | options|
puts options
updateProjectBuildNumber
sendEmail "ios [#{ scheme} _#{ get_build_number( ) } ] 发包成功" , "#{ get_build_number( ) } " end
lane :development_build do | options|
branch = options[ :branch ]
puts "开始打development ipa"
updateProjectBuildNumber
gym(
scheme: "*****" ,
output_name: "#{ scheme} _#{ get_build_number( ) } " ,
clean:true ,
configuration: "Release" ,
export_method: "enterprise" ,
export_xcargs: "-allowProvisioningUpdates" ,
export_options: { iCloudContainerEnvironment: "Production" } ,
output_directory: "./fastlane/build" ,
)
firim( firim_api_token: "******" )
sendEmail "ios [#{ scheme} _#{ get_build_number( ) } ] 发包成功" , "#{ get_build_number( ) } " end
end
lane :uploadfir do | options|
firim( firim_api_token: "*****" )
end
lane :development_buildtf do | options|
puts "开始打development_buildtf"
gym(
scheme: "****" ,
output_name: "#{ scheme} _#{ get_build_number( ) } " ,
clean: true ,
configuration: "Release" ,
export_method: "enterprise" ,
output_directory: "./fastlane/build" ,
export_options: { iCloudContainerEnvironment: "Production" } ,
)
upload_to_testflight(
skip_waiting_for_build_processing: true
)
end
end
end
您的一举一动都是对我的莫大支持