fastlane / fastlane

🚀 The easiest way to automate building and releasing your iOS and Android apps
https://fastlane.tools
MIT License
39.5k stars 5.7k forks source link

increment_build_number does not work for multiple targets #8601

Closed mortenholmgaard closed 7 years ago

mortenholmgaard commented 7 years ago

New Issue Checklist

Issue Description

When I use increment_build_number first I do not have the option to specify the target that i want to increment. Next when I run it, it can't find all the info.plist files - perhaps because of a space in the path? Please fix the two issues. https://docs.fastlane.tools/actions/#increment_build_number

Complete output when running fastlane, including the stack trace and command used

20:03:16: --- Step: increment_build_number ---

20:03:16: $ cd /Users/mortenholmgaard/Code/MyEvent && agvtool next-version -all && cd - [20:03:21]: ▸ Setting version of project MyEvent to: [20:03:21]: ▸ 3. [20:03:21]: ▸ Also setting CFBundleVersion key (assuming it exists) [20:03:21]: ▸ Updating CFBundleVersion in Info.plist(s)... [20:03:21]: ▸ $(SRCROOT)/MyEvent/Supporting Files/AaFestival-Info.plist [20:03:21]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/AaFestival-Info.plist" [20:03:21]: ▸ $(SRCROOT)/MyEvent/Supporting Files/Development-Info.plist [20:03:21]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/Development-Info.plist" [20:03:21]: ▸ $(SRCROOT)/MyEvent/Supporting Files/Discipeltraef-Info.plist [20:03:21]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/Discipeltraef-Info.plist" [20:03:21]: ▸ $(SRCROOT)/MyEvent/Supporting Files/Event-Info.plist [20:03:21]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/Event-Info.plist" [20:03:21]: ▸ $(SRCROOT)/MyEvent/Supporting Files/Hjallerup-Info.plist [20:03:21]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/Hjallerup-Info.plist" [20:03:22]: ▸ $(SRCROOT)/MyEvent/Supporting Files/Konnekt-Info.plist [20:03:22]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/Konnekt-Info.plist" [20:03:22]: ▸ $(SRCROOT)/MyEvent/Supporting Files/MTC-Info.plist [20:03:22]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/MTC-Info.plist" [20:03:22]: ▸ $(SRCROOT)/MyEvent/Supporting Files/MyEvent-Info.plist [20:03:22]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/MyEvent-Info.plist" [20:03:22]: ▸ $(SRCROOT)/MyEvent/Supporting Files/Paaskelejr-Info.plist [20:03:22]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/Paaskelejr-Info.plist" [20:03:22]: ▸ $(SRCROOT)/MyEvent/Supporting Files/SE-Info.plist [20:03:22]: ▸ Cannot find "$(SRCROOT)/MyEvent/Supporting Files/SE-Info.plist" [20:03:22]: ▸ Updated CFBundleVersion in "MyEvent.xcodeproj/../UI_TEST_AaFestival/Info.plist" to 3 [20:03:22]: ▸ Updated CFBundleVersion in "MyEvent.xcodeproj/../UI_TEST_Discipeltraef/Info.plist" to 3 [20:03:22]: ▸ Updated CFBundleVersion in "MyEvent.xcodeproj/../UI_TEST_Event/Info.plist" to 3 [20:03:23]: ▸ Updated CFBundleVersion in "MyEvent.xcodeproj/../UI_TEST_Hjallerup/Info.plist" to 3 [20:03:23]: ▸ Updated CFBundleVersion in "MyEvent.xcodeproj/../UI_TEST_Konnekt/Info.plist" to 3 [20:03:23]: ▸ Updated CFBundleVersion in "MyEvent.xcodeproj/../UI_TEST_MTC/Info.plist" to 3 [20:03:23]: ▸ Updated CFBundleVersion in "MyEvent.xcodeproj/../UI_TEST_Paaskelejr/Info.plist" to 3

Environment

✅ fastlane environment ✅ ### Stack | Key | Value | | --------------------------- | ------------------------------------------- | | OS | 10.12.3 | | Ruby | 2.3.1 | | Bundler? | false | | Git | git version 2.10.1 (Apple Git-78) | | Installation Source | ~/.rbenv/versions/2.3.1/bin/fastlane | | Host | Mac OS X 10.12.3 (16D32) | | Ruby Lib Dir | ~/.rbenv/versions/2.3.1/lib | | OpenSSL Version | OpenSSL 1.0.2j 26 Sep 2016 | | Is contained | false | | Is homebrew | false | | Is installed via Fabric.app | false | | Xcode Path | /Applications/Xcode.app/Contents/Developer/ | | Xcode Version | 8.2.1 | ### System Locale | Variable | Value | | | -------- | ----------- | - | | LANG | da_DK.UTF-8 | ✅ | | LC_ALL | | | | LANGUAGE | | | ### fastlane files:
`./fastlane/Fastfile` ```ruby load 'ParsePush.rb' # Customise this file, documentation can be found here: # https://github.com/KrauseFx/fastlane/tree/master/docs # All available actions: https://github.com/KrauseFx/fastlane/blob/master/docs/Actions.md # can also be listed using the `fastlane actions` command # Change the syntax highlighting to Ruby # To update fastlane run: # sudo gem update fastlane before_all do set_context end after_all do |lane| # if all lanes were successful end error do |lane, exception| say exception.message end desc "Create or Update App for Dev" lane :create_app_for_dev do xcode_target = ENV["TARGET"] set_app_identifier(ENV["APP_IDENTIFIER"] + ".test") ENV["APP_TITLE"] = ENV["APP_TITLE"] + " test" cert(development: true, output_path: "./fastlane/#{xcode_target}/") produce_app(false) #produce must be before sigh to make sure appId is created sigh( development: true, output_path: "./fastlane/#{xcode_target}/") push_certificates(true) #create_or_update_parse_app() #The problem is that it create a app for test!! end desc "Create or Update App for App Store" lane :create_app_for_app_store do #Works! xcode_target = ENV["TARGET"] skip_upload_or_remove_screenshots = should_skip_screenshots() update_version_number() cert(output_path: "./fastlane/#{xcode_target}/") produce_app(true) #produce must be before sigh to make sure appId is created sigh(output_path: "./fastlane/#{xcode_target}/") push_certificates(false) deliver(submit_for_review: false, skip_screenshots: skip_upload_or_remove_screenshots) end desc "Download existing screenshots" lane :download_existing_screenshots do puts "Downloads existing screenshots and puts them in the folder delivery. Move them to the apps folder to be used." appIdentifier = ENV["APP_IDENTIFIER"] sh "deliver download_screenshots -a #{appIdentifier} -u mortenholmgaardmh@hotmail.com -k #{ENV["FASTLANE_ITC_TEAM_ID"]} -w test" end desc "Take screenshots" lane :screenshots do #Works! ENV["SNAPSHOT_BREAK_ON_FIRST_ERROR"] = "1" # ENV["SNAPSHOT_SKIP_UNINSTALL"] = "1" # ENV["SNAPSHOT_SKIP_OPEN_SUMMARY"] = "0" snapshot end desc "Preload with app installed" #Works! lane :preload_with_app_installed do target = ENV["TARGET"] if not ENV["APP_IDENTIFIER"].include? ".test" set_app_identifier(ENV["APP_IDENTIFIER"] + ".test") end appIdentifier = ENV["APP_IDENTIFIER"] sh "./Preload.sh #{target} #{appIdentifier}" #Might need to run 'chmod -R 755 *' in the terminal first to grant access end desc "Preload" #Works! lane :preload do target = ENV["TARGET"] set_app_identifier(ENV["APP_IDENTIFIER"] + ".test") appIdentifier = ENV["APP_IDENTIFIER"] ENV["APP_TITLE"] = ENV["APP_TITLE"] + " test" cert(development: true, output_path: "./fastlane/#{target}/") sigh(development: true, output_path: "./fastlane/#{target}/") # NOTE: Set provisioning profile in xcode to Automatic gym( scheme: target, configuration: "Debug", silent: true, clean: false, xcargs: "PRELOAD=1", output_directory: "./fastlane/#{target}/", output_name: "preload.ipa") sh "./ExtractInstall.sh #{target} #{appIdentifier}" #Might need to run 'chmod -R 755 *' in the terminal first to grant access preload_with_app_installed end desc "Deploy a new version to the App Store" lane :deploy_store do #Works! target = ENV["TARGET"] skip_upload_or_remove_screenshots = should_skip_screenshots() increment_build_number(xcodeproj: "./MyEvent.xcodeproj") cert(output_path: "./fastlane/#{target}/") produce_app(true) sigh(output_path: "./fastlane/#{target}/") push_certificates(false) build_app("Release") deliver(submit_for_review: true, skip_screenshots: skip_upload_or_remove_screenshots) currentVersionNumber = get_version_short_string File.expand_path(File.join(ENV['PWD'], "MyEvent/Supporting\\ Files/#{target}-Info.plist")) currentBuildNumber = get_build_number() sh "git add -A" sh "git commit -m \"#{target} version: #{currentVersionNumber}_#{currentBuildNumber}\" || echo \"No changes to commit\"" add_git_tag(tag: "#{target}_#{currentVersionNumber}", force: true) push_to_git_remote end desc "Tag after manuel App Store deployment" lane :after_manuel_deploy_store do target = ENV["TARGET"] currentVersionNumber = get_version_short_string File.expand_path(File.join(ENV['PWD'], "MyEvent/Supporting\\ Files/#{target}-Info.plist")) currentBuildNumber = get_build_number() say currentVersionNumber sh "git add -A" sh "git commit -m \"#{target} version: #{currentVersionNumber}_#{currentBuildNumber}\" || echo \"No changes to commit\"" add_git_tag(tag: "#{target}_#{currentVersionNumber}", force: true) push_to_git_remote end desc "Frame screenshots" lane :frame_screenshots do frameit end desc "Check for advertising identifier" lane :checkForAdvertisingIdentifier do sh "fgrep -R advertisingIdentifier ../." end desc "Update fastlane" lane :updatefastlane do update_fastlane # https://github.com/fastlane/fastlane/blob/master/docs/Actions.md#update_fastlane # Create .bash_profile in root folder (~/) with contents of above link # Create a .gems folder # Run the lane end def produce_app(create_itc) produce( username: ENV["APPLE_ID"], app_identifier: ENV["APP_IDENTIFIER"], app_name: ENV["APP_TITLE"], language: "Danish", app_version: ENV["APP_VERSION_NUMBER"], sku: ENV["APP_IDENTIFIER"], skip_itc: !create_itc ) end def push_certificates(development) xcode_target = ENV["TARGET"] pem( save_private_key: true, generate_p12:true, development: development, new_profile: Proc.new do |profile_path| file_name = profile_path.split('/').last File.rename profile_path, "./fastlane/#{xcode_target}/#{file_name}" p12_file_name = file_name.clone.sub! 'pem', 'p12' File.rename "./#{p12_file_name}", "./fastlane/#{xcode_target}/#{p12_file_name}" key_file_name = file_name.clone.sub! 'pem', 'pkey' File.rename "./#{key_file_name}", "./fastlane/#{xcode_target}/#{key_file_name}" end ) end def create_or_update_parse_app() appName = ENV["APP_TITLE"] app = createParseApp(appName) if app == nil app = loadParseAppPushKeys(appName) end updateAppSettings(app, ENV["MY_EVENT_APP_ID"]) end def build_app(configuration) target = ENV["TARGET"] gym( scheme: target, configuration: configuration, silent: true, clean: true, output_directory: "./fastlane/#{target}/", output_name: "#{configuration}") end def update_version_number() currentVersion = get_version_number(xcodeproj: "MyEvent.xcodeproj") puts "Current version number: #{currentVersion}" bumpType = "" case prompt(text: "Bump version number? \n1. major\n2. minor\n3. patch\n4. no change") when "1" bumpType = 'major' when "2" bumpType = 'minor' when "3" bumpType = 'patch' when "4" else raise 'Invalid option selected. It has to be a number between 1 and 4' end if bumpType.length > 0 increment_version_number(bump_type: bumpType, xcodeproj: "MyEvent.xcodeproj") end end def set_context apps = JSON.parse(open("http://appservices.purposeit.dk/rest/publish/apps?format=json").read) i = 1 puts "Select app:" apps.each do |app| title = app["Title"] puts "#{i}) #{title}" i += 1 end app_index = gets.chomp app = apps.at(app_index.to_i()-1) team_id app["DeveloperTeamId"] ENV["FASTLANE_ITC_TEAM_ID"] = app["ItunesConnectTeamId"] set_app_identifier(app["AppPublishId"]) ENV["TARGET"] = app["XcodeTarget"] ENV["APPLE_ID"] = app["AppleId"] ENV["MY_EVENT_APP_ID"] = app["Id"].to_s() ENV["APP_TITLE"] = app["Title"] ENV["DELIVER_USER"] = ENV["APPLE_ID"] ENV["SIGH_USERNAME"] = ENV["APPLE_ID"] ENV["CERT_USERNAME"] = ENV["APPLE_ID"] xcode_target = ENV["TARGET"] begin plist_version = get_version_short_string File.expand_path(File.join(ENV['PWD'], "MyEvent/Supporting\\ Files/#{xcode_target}-Info.plist")) # plist_version = get_version_number(target: xcode_target) #does not work: https://github.com/fastlane/fastlane/issues/5388 puts "App version: #{plist_version}" ENV["APP_VERSION_NUMBER"] = plist_version rescue puts "App version: NOT FOUND (setting to 1.0.0) (Target not yet created in Xcode: #{xcode_target})" ENV["APP_VERSION_NUMBER"] = "1.0.0" end #create output directory if not exist directory_path = "./#{xcode_target}/" if !File.directory?(directory_path) FileUtils.mkdir_p(directory_path) end #ENV["GYM_PROVISIONING_PROFILE_PATH"] = "#{directory_path}" # Do NOT set this path title = app["Title"] puts "Acount context for #{title} set with success" end def set_app_identifier(identifier) ENV["APP_IDENTIFIER"] = identifier ENV["SIGH_APP_IDENTIFIER"] = identifier ENV["PEM_APP_IDENTIFIER"] = identifier end def should_skip_screenshots() puts "\nSkip upload/remove screenshots? (y/n)" skip_upload_or_remove_screenshots = gets.chomp puts "Will #{skip_upload_or_remove_screenshots == "y" ? "" : "not "}skip upload/remove screenshots" return skip_upload_or_remove_screenshots == "y" ? true : false end # Parses JSON output of `plutil` def info_plist_to_hash(path) require 'json' JSON.parse! %x[plutil -convert json -o - #{path}] end # Hack to read app version from Info.plist def get_version_short_string(path) plist_hash = info_plist_to_hash path plist_hash['CFBundleShortVersionString'] end # Print all ENV's def print_envs puts "All environment variables:" @result = {} count = 1 ENV.each do |k,v| @result[count.to_s] = { "key" => k, "value" => v } puts "[#{count.to_s}]: #{k}: #{v}" count += 1 end end ```
**No Appfile found** ### fastlane gems | Gem | Version | Update-Status | | -------- | ------- | ------------- | | fastlane | 2.22.0 | ✅ Up-To-Date | ### Loaded fastlane plugins: **No plugins Loaded**
Loaded gems | Gem | Version | | ------------------------- | ------------ | | did_you_mean | 1.0.0 | | slack-notifier | 1.5.1 | | i18n | 0.7.0 | | json | 1.8.3 | | thread_safe | 0.3.5 | | tzinfo | 1.2.2 | | minitest | 5.8.3 | | activesupport | 4.2.7.1 | | CFPropertyList | 2.3.3 | | claide | 1.0.1 | | colored | 1.2 | | nanaimo | 0.2.2 | | xcodeproj | 1.4.1 | | rouge | 1.11.1 | | xcpretty | 0.2.4 | | terminal-notifier | 1.7.1 | | terminal-table | 1.4.5 | | plist | 3.1.0 | | public_suffix | 2.0.3 | | addressable | 2.5.0 | | multipart-post | 2.0.0 | | word_wrap | 1.0.0 | | tty-screen | 0.5.0 | | babosa | 1.0.2 | | highline | 1.7.8 | | commander | 4.4.0 | | excon | 0.54.0 | | faraday | 0.9.2 | | unf_ext | 0.0.7.2 | | unf | 0.1.4 | | domain_name | 0.5.20161021 | | http-cookie | 1.0.3 | | faraday-cookie_jar | 0.0.6 | | fastimage | 1.6.8 | | gh_inspector | 1.0.2 | | uber | 0.0.15 | | representable | 2.3.0 | | retriable | 2.1.0 | | mime-types-data | 3.2016.0521 | | mime-types | 3.1 | | hurley | 0.2 | | little-plugger | 1.1.4 | | multi_json | 1.12.1 | | logging | 2.1.0 | | jwt | 1.5.6 | | memoist | 0.15.0 | | os | 0.9.6 | | signet | 0.7.3 | | googleauth | 0.5.1 | | httpclient | 2.8.2.4 | | google-api-client | 0.9.19 | | mini_magick | 4.5.1 | | multi_xml | 0.5.5 | | rubyzip | 1.1.7 | | security | 0.1.3 | | xcpretty-travis-formatter | 0.0.4 | | dotenv | 2.1.1 | | bundler | 1.13.6 | | faraday_middleware | 0.10.0 | | io-console | 0.4.5 |
*generated on:* **2017-03-21**
fastlane-bot commented 7 years ago

It seems like this issue might be related to code signing :no_entry_sign:

Have you seen our new Code Signing Troubleshooting Guide? It will help you resolve the most common code signing issues :+1:

mortenholmgaard commented 7 years ago

Any one please look at this..

alwindeep commented 7 years ago

I am facing same issue as i have multiple targets as well.

For now i am using set_info_plist_value(path: info_plist_path, key: "CFBundleVersion", value: build_number) as a workaround.

taquitos commented 7 years ago

increment_build_number is just shelling out to agvtool. I'm not sure how that behaves with multiple targets, but I'd think it would increment it for all targets. Is there anything non-standard about your setup? Spaces were mentioned earlier, have you tried removing them?

davidfrasch commented 7 years ago

You should try this plugin: https://github.com/SiarheiFedartsou/fastlane-plugin-versioning

To get started: fastlane add_plugin versioning

Then you can do it like this:

increment_build_number_in_plist(target: 'appName')
increment_version_number_in_plist(target: 'appName')
txaiwieser commented 7 years ago

I like there's a plugin option, but shouldn't this be an option inche default increment_build_number action?

Also would be great to have get_version_number with Target/Scheme options

Thanks!