6

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

在 fastfile 中,我有我的 AppStore 通道,只有在这种情况下,我才想更改MY_VARIABLE.

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

4

2 回答 2

5

经过一番研究,我找到了解决方案。
xcargsgym行动中使用,如:

gym(
  scheme: "MyScheme",
  configuration: "Release",
  use_legacy_build_api: 1,
  xcargs: "MY_VARIABLE=appStoreValue"
)
于 2016-07-12T14:08:56.013 回答
0

感谢https://stackoverflow.com/a/56179405/5790492https://nshipster.com/xcconfig/
我已经创建了xcconfig文件,将其添加到信息选项卡中的项目中。对于 fastlane 添加了插件以与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

在此处输入图像描述

于 2021-10-13T09:21:52.960 回答