def build_settings(key: nil, optional: true)
      unless @build_settings
        if is_workspace
          if schemes.count == 0
            UI.user_error!("Could not find any schemes for Xcode workspace at path '#{self.path}'. Please make sure that the schemes you want to use are marked as `Shared` from Xcode.")
          end
          options[:scheme] ||= schemes.first
        end

        command = build_xcodebuild_showbuildsettings_command

        # Xcode might hang here and retrying fixes the problem, see fastlane#4059
        begin
          timeout = FastlaneCore::Project.xcode_build_settings_timeout
          retries = FastlaneCore::Project.xcode_build_settings_retries
          @build_settings = FastlaneCore::Project.run_command(command, timeout: timeout, retries: retries, print: !self.xcodebuild_list_silent)
          if @build_settings.empty?
            UI.error("Could not read build settings. Make sure that the scheme \"#{options[:scheme]}\" is configured for running by going to Product → Scheme → Edit Scheme…, selecting the \"Build\" section, checking the \"Run\" checkbox and closing the scheme window.")
          end
        rescue Timeout::Error
          raise FastlaneCore::Interface::FastlaneDependencyCausedException.new, "xcodebuild -showBuildSettings timed out after #{retries + 1} retries with a base timeout of #{timeout}." \
            " You can override the base timeout value with the environment variable FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT," \
            " and the number of retries with the environment variable FASTLANE_XCODEBUILD_SETTINGS_RETRIES ".red
        end
      end

      begin
        result = @build_settings.split("\n").find do |c|
          sp = c.split(" = ")
          next if sp.length == 0
          sp.first.strip == key
        end
        return result.split(" = ").last
      rescue => ex
        return nil if optional # an optional value, we really don't care if something goes wrong

        UI.error(caller.join("\n\t"))
        UI.error("Could not fetch #{key} from project file: #{ex}")
      end

      nil
    end
def build_settings(key: nil, optional: true)
      unless @build_settings
        if is_workspace
          if schemes.count == 0
            UI.user_error!("Could not find any schemes for Xcode workspace at path '#{self.path}'. Please make sure that the schemes you want to use are marked as `Shared` from Xcode.")
          end
          options[:scheme] ||= schemes.first
        end

        command = build_xcodebuild_showbuildsettings_command

        # Xcode might hang here and retrying fixes the problem, see fastlane#4059
        begin
          timeout = FastlaneCore::Project.xcode_build_settings_timeout
          retries = FastlaneCore::Project.xcode_build_settings_retries
          @build_settings = FastlaneCore::Project.run_command(command, timeout: timeout, retries: retries, print: !self.xcodebuild_list_silent)
          if @build_settings.empty?
            UI.error("Could not read build settings. Make sure that the scheme \"#{options[:scheme]}\" is configured for running by going to Product → Scheme → Edit Scheme…, selecting the \"Build\" section, checking the \"Run\" checkbox and closing the scheme window.")
          end
        rescue Timeout::Error
          raise FastlaneCore::Interface::FastlaneDependencyCausedException.new, "xcodebuild -showBuildSettings timed out after #{retries + 1} retries with a base timeout of #{timeout}." \
            " You can override the base timeout value with the environment variable FASTLANE_XCODEBUILD_SETTINGS_TIMEOUT," \
            " and the number of retries with the environment variable FASTLANE_XCODEBUILD_SETTINGS_RETRIES ".red
        end
      end

      begin
        result = @build_settings.split("\n").find do |c|
          sp = c.split(" = ")
          next if sp.length == 0
          sp.first.strip == key
        end
        return result.split(" = ").last
      rescue => ex
        return nil if optional # an optional value, we really don't care if something goes wrong

        UI.error(caller.join("\n\t"))
        UI.error("Could not fetch #{key} from project file: #{ex}")
      end

      nil
    end
Get the build settings for our project
 e.g. to properly get the DerivedData folder
 @param [String] The key of which we want the value for (e.g. "PRODUCT_NAME")