ios - 使用 faSTLane 根据方案/目标自动从 plist 获取包标识符

标签 ios fastlane

我有一个包含多个目标/方案的 Xcode 项目设置,因此我在同一代码库下有多个应用程序。

我在我的 Fastfile 中创建了以下测试 channel ,它为我的每个应用程序运行“sigh”工具:

lane :testing do
  ["First", "Second", "Third", "Fourth"].each do |scheme_name|
      sigh
  end
end

查看 faSTLane 文档,我看到您可以定义 sigh 使用的包标识符。但我需要它自动从每个目标/方案的 plist 中获取当前的包标识符,并将其用于 sigh。这能实现吗?

类似于(伪代码):

bundle_id = get_bundle_id_from_plist
sigh(app_identifier: bundle_id)

我尝试使用这个插件:https://github.com/SiarheiFedartsou/fastlane-plugin-versioning它有一个获取 plist 路径的方法。然后我运行了这段代码:

bundle_id = get_info_plist_value(path: get_info_plist_path(target: scheme_name), key: 'CFBundleIdentifier')
puts bundle_id

输出是 $(PRODUCT_BUNDLE_IDENTIFIER),它实际上是 plist 值中的内容,所以我越来越接近了。但我需要它来返回实际的包 ID,而不仅仅是它指向的变量。

我想使用 sigh 的全部原因是因为每个应用程序/目标都有自己的配置文件,由于 CarPlay 权利,我最初必须手动生成这些配置文件。我希望它在每个目标过期时自动为每个目标创建新的配置文件。

最佳答案

我不知道有任何faSTLane 操作提供这样的功能,但您可以构建一个本地fastlane action ,或创建并分享 fastlane plugin ,它使用 code that updates an info plist using the scheme name 提供 CFBundleIdentifier举个例子。

此代码使用 xcodeproj Ruby gem 从方案中获取 Info.plist 文件。然后它更改 plist 值,然后保存 plist 文件。您可以做类似的事情,只是从 plist 返回 CFBundleIdentifier

如果您不想创建插件,我可以在本周晚些时候创建它,因为我对此很感兴趣。

在我完成插件之前,这段代码应该对你有用:

    # At the top of your Fastfile; you may need to add "gem 'xcodeproj'" to your Gemfile and then do a bundle install
    require 'xcodeproj'

    def product_bundle_id(scheme)
      project = Xcodeproj::Project.open('path/to/your/xcodeproj')
      scheme = project.native_targets.find { |target| target.name == scheme }
      build_configuration = scheme.build_configurations.first
      build_configuration.build_settings['PRODUCT_BUNDLE_IDENTIFIER']
    end

    lane :testing do
      ["First", "Second", "Third", "Fourth"].each do |scheme_name|
        sigh(app_identifier: product_bundle_id(scheme_name))
      end
    end

关于ios - 使用 faSTLane 根据方案/目标自动从 plist 获取包标识符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42590053/

相关文章:

ios - 未加载 Xamarin.Forms iOS 项目

ios - 在 App Store Connect 上找不到编辑版本。尝试使用 '--use_live_version true'

ios - 如果我想确保我返回的 NSMutableArray 仅被视为 NSArray,那么复制我应该使用的是什么? Actor ?

ios - 我可以做类似 ExpressibleByKeyPathLiteral 的东西吗?

ios - XCTest/App 中的开始/结束撤消组导致奇怪的行为

ios - 将私有(private) pod 添加到 podfile 作为依赖项

Jenkins 删除钥匙串(keychain)中的 key

ios - 如何在物理 ios 设备上使用 faSTLane?

continuous-integration - 即使指定了另一种颜色,Frameit 也始终以黑色打印标题/关键字

ios - Xcode 8.3 xcodebuild exportArchive 不工作 "No applicable devices found"错误