SiarheiFedartsou / fastlane-plugin-versioning

Extends fastlane versioning actions. Allows to set/get versions without using agvtool and do some other small tricks.
MIT License
504 stars 60 forks source link

increment_build_number_in_xcodeproj with scheme throws an error #60

Closed seanmalone-redibs closed 2 years ago

seanmalone-redibs commented 3 years ago

When running with the following parameters:

increment_build_number_in_xcodeproj(
      scheme: "Development",
      build_configuration_name: "Development",
      xcodeproj: "myapp.xcodeproj"
    )

I get the following error:

        27: from /usr/local/bin/fastlane:23:in `<main>'
        26: from /usr/local/bin/fastlane:23:in `load'
        25: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/bin/fastlane:23:in `<top (required)>'
        24: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/cli_tools_distributor.rb:119:in `take_off'
        23: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/commands_generator.rb:41:in `start'
        22: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/commands_generator.rb:352:in `run'
        21: from /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/delegates.rb:15:in `run!'
        20: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane_core/lib/fastlane_core/ui/fastlane_runner.rb:76:in `run!'
        19: from /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/runner.rb:476:in `run_active_command'
        18: from /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:153:in `run'
        17: from /Library/Ruby/Gems/2.6.0/gems/commander-fastlane-4.4.6/lib/commander/command.rb:178:in `call'
        16: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/commands_generator.rb:108:in `block (2 levels) in run'
        15: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/command_line_handler.rb:36:in `handle'
        14: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/lane_manager.rb:47:in `cruise_lane'
        13: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/runner.rb:45:in `execute'
        12: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/runner.rb:45:in `chdir'
        11: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/runner.rb:49:in `block in execute'
        10: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/lane.rb:33:in `call'
         9: from Fastfile:21:in `block (2 levels) in parsing_binding'
         8: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/fast_file.rb:159:in `method_missing'
         7: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/runner.rb:157:in `trigger_action_by_name'
         6: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/runner.rb:229:in `execute_action'
         5: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/runner.rb:229:in `chdir'
         4: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/runner.rb:255:in `block in execute_action'
         3: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/actions/actions_helper.rb:69:in `execute_action'
         2: from /Library/Ruby/Gems/2.6.0/gems/fastlane-2.168.0/fastlane/lib/fastlane/runner.rb:263:in `block (2 levels) in execute_action'
         1: from /Library/Ruby/Gems/2.6.0/gems/fastlane-plugin-versioning-0.4.4/lib/fastlane/plugin/versioning/actions/increment_build_number_in_xcodeproj.rb:25:in `run'
/Library/Ruby/Gems/2.6.0/gems/fastlane-plugin-versioning-0.4.4/lib/fastlane/plugin/versioning/actions/increment_build_number_in_xcodeproj.rb:77:in `set_build_number_using_scheme': [!] undefined method `[]=' for nil:NilClass (NoMethodError)

Looking at the source code for set_build_number_using_scheme it has this line: project.build_settings["CURRENT_PROJECT_VERSION"] = next_build_number

It looks like project.build_settings is a getter that returns the value for a given key. Unfortunately, it's not a setter for the build settings.

Please advise and thank you for putting this plugin together.

seanmalone-redibs commented 3 years ago

One additional note: I had to include build_configuration_name; otherwise, scheme was ignored and all schemes are updated. Not sure if this intentional? If so, it seems a bit misleading. If build_configuration_name is required when scheme is provided, can it throw an error instead of falling through to all?

jdouglas-nz commented 3 years ago

Hey @seanmalone-redibs - sorry for a lengthy response. I spent some time looking into this, and was wondering if this 'myapp' / 'Development' input was for a fresh, mostly out-of-the-box xcodeproject or not? I setup a small test locally with the closest thing I could guess was your project (renaming Debug -> Development, same project name), and had the same crash, until I manually set the build and project version by hand through Xcode's UI. After that, everything worked swimmingly. If this is the same for you - I'll make sure to add to the readme so other people aren't caught by this gotcha.

jdouglas-nz commented 3 years ago

@seanmalone-redibs - did this help you with your issue?

seanmalone-redibs commented 3 years ago

@jdouglas-nz Thanks for the reply and sorry for the delayed response. Are you saying that if we need to manually set the build and project version once and then the plugin will update properly from that point on?

jdouglas-nz commented 3 years ago

@seanmalone-redibs it worked for me at least! I don't think I didn't something other that that to get it working. Please give it a go !

seanmalone-redibs commented 3 years ago

Thanks! It works now. I guess I didn't have a default set.