fastlane
修改ruby 源
gem sources --add https://gems.ruby-china.org/ --remove https://rubygems.org/
安装fastlane
sudo gem install fastlane
编写Fastlane文件
# Customise this file, documentation can be found here: # https://github.com/fastlane/fastlane/tree/master/fastlane/docs # All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md # can also be listed using the `fastlane actions` command # Change the syntax highlighting to Ruby # All lines starting with a # are ignored when running `fastlane` # If you want to automatically update fastlane if a new version is available: # update_fastlane # This is the minimum version number required. # Update this, if you use features of a newer version fastlane_version "1.101.0" default_platform :ios platform :ios do before_all do end desc "Deploy a new version to the App Store" desc "This will also make sure the profile is up to date" lane :appstore do deploy="appstore" now=Time.now.strftime("%Y%m%d%H%M%S") current_user="jenkins" scheme="xxx" configuration="Distribution" version=get_info_plist_value( path: 'xxx/xxx-Info.plist', key: 'CFBundleShortVersionString' ) provision="fastlane/provision/#{deploy}.mobileprovision" output_path="/Users/#{current_user}/Desktop/#{deploy}/#{version}/#{now}" codesign="iPhone Distribution: xxxxx" archive_path="#{output_path}/#{version}.xcarchive" ipa_path="#{version}.ipa" app_name="xxxxx" #CFBundleDisplayName update_info_plist( xcodeproj: "xxxx.xcodeproj", plist_path: 'xxx/xxx-Info.plist', block: lambda { |plist| plist["CFBundleDisplayName"] = "#{app_name}" } ) gym( scheme: scheme, output_directory: output_path, use_legacy_build_api: true, archive_path: archive_path, codesigning_identity: codesign, clean: true, output_name: ipa_path, provisioning_profile_path: provision ) end desc "Deploy a new Ad-hoc version" lane :adhoc do deploy="adhoc" now=Time.now.strftime("%Y%m%d%H%M%S") current_user="jenkins" scheme="xxxxx" configuration="Distribution" version=get_info_plist_value( path: 'xxx/xxx-Info.plist', key: 'CFBundleShortVersionString' ) provision="fastlane/provision/#{deploy}.mobileprovision" output_path="/Users/#{current_user}/Desktop/#{deploy}/#{version}/#{now}" codesign="iPhone Distribution: xxxxxx" archive_path="#{output_path}/#{version}.xcarchive" ipa_path="#{version}.ipa" app_identifier="xxxx" app_name="xxxx" app_group="group.#{app_identifier}" #app bundle id update_app_identifier( xcodeproj: "xxx.xcodeproj", plist_path: 'xxx/xxxx-Info.plist', app_identifier: "#{app_identifier}" # The App Identifier ) #NSExtension update_info_plist( xcodeproj: "xxxx.xcodeproj", plist_path: 'xxxx/Info.plist', block: lambda { |plist| NSExtension = plist["NSExtension"] NSExtensionAttributes = NSExtension["NSExtensionAttributes"] NSExtensionAttributes["WKAppBundleIdentifier"] = "#{app_identifier}.watchkitapp" puts NSExtension } ) #today update_app_identifier( xcodeproj: "xxxx.xcodeproj", plist_path: 'today/Info.plist', app_identifier: "#{app_identifier}.today" # The App Identifier ) update_app_group_identifiers( entitlements_file: 'xxxx/xxxx.entitlements', app_group_identifiers: [app_group] ) #CFBundleDisplayName update_info_plist( xcodeproj: "xxxx.xcodeproj", plist_path: 'xxxx/xxxx-Info.plist', block: lambda { |plist| plist["CFBundleDisplayName"] = "#{app_name}" } ) gym( scheme: scheme, output_directory: output_path, use_legacy_build_api: true, archive_path: archive_path, codesigning_identity: codesign, clean: true, output_name: ipa_path, provisioning_profile_path: provision ) end # You can define as many lanes as you want after_all do |lane| # This block is called, only if the executed lane was successful # slack( # message: "Successfully deployed new App Update." # ) end error do |lane, exception| # slack( # message: exception.message, # success: false # ) end end # More information about multiple platforms in fastlane: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Platforms.md # All available actions: https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Actions.md # fastlane reports which actions are used # No personal data is recorded. Learn more at https://github.com/fastlane/enhancer
- Demo
更多
fastlane actions fastlane action xxx