【问题标题】:Change user-defined variable from fastlane从 fastlane 更改用户定义的变量
【发布时间】:2016-11-14 16:37:57
【问题描述】:

我的 Xcode 项目中有一个用户定义的变量 - MY_VARIABLE:
我也在我的 .plist 文件中链接了MY_VARIABLE
然后我在我的代码中使用它:
NSString *myVariable = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"MY_VARIABLE"];

在快速文件中,我有我的 AppStore 通道,只有在这种情况下,我才想更改 MY_VARIABLE 的值。

我目前正在使用:
ENV["MY_VARIABLE"] = "appStoreValue"
但这不起作用。

【问题讨论】:

    标签: xcode fastlane


    【解决方案1】:

    经过一番研究,我找到了解决方案。
    我在gym 操作中使用xcargs,例如:

    gym(
      scheme: "MyScheme",
      configuration: "Release",
      use_legacy_build_api: 1,
      xcargs: "MY_VARIABLE=appStoreValue"
    )
    
    【解决方案2】:

    感谢https://stackoverflow.com/a/56179405/5790492https://nshipster.com/xcconfig/
    我创建了 xcconfig 文件,将其添加到 Info 选项卡中的项目中。为 fastlane 添加了 this 插件以使用 xcconfig。现在它看起来像:

    def bumpMinorVersionNumber
        currentVersion = get_xcconfig_value(path: 'fastlane/VersionsConfig.xcconfig',
                                            name: 'FC_VERSION')
        versionArray = currentVersion.split(".").map(&:to_i)
        versionArray[2] = (versionArray[2] || 0) + 1
        newVersion = versionArray.join(".")
        update_xcconfig_value(path: 'fastlane/VersionsConfig.xcconfig',
                              name: 'FC_VERSION',
                              value: newVersion.to_s)
        UI.important("Old version: #{currentVersion}. Version bumped to: #{newVersion}")
    end
    
    def bumpBuildNumber
        currentBuildNumber = get_xcconfig_value(path: 'fastlane/VersionsConfig.xcconfig',
                                                name: 'FC_BUILD')
        newBuildNumber = currentBuildNumber.to_i + 1
        update_xcconfig_value(path: 'fastlane/VersionsConfig.xcconfig',
                              name: 'FC_BUILD',
                              value: newBuildNumber.to_s)
        UI.important("Old build number: #{currentBuildNumber}. Build number bumped to: #{newBuildNumber}")
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-01
      • 2018-02-08
      相关资源
      最近更新 更多