在Podfile上添加环境变量的可能性

是否可以在podfile上添加环境变量而不必创建自定义的shell脚本来替换podfile中的字符串?

示例:

platform :ios,'10.0'
source 'https://github.com/Cocoapods/Specs.git'
source 'https://<username>@bitbucket.org/awesometeamname/ios-private-specs.git'
use_modular_headers!

target 'a-generic-app-name' do
  use_frameworks!

  pod 'MaybeFirebase'
  pod 'AnotherSDK'
  pod 'AlamofireOfCourse'
  pod 'WhoUsesRxSwiftAnyway'

end

其背后的原因是,我们正在使用通过ssh连接到的私有pod spec存储库,开发人员将必须始终Push或手动忽略Pushing用户名,是否可以通过命令行进行设置?

我目前的解决方案是,我有一个脚本而不是调用pod install来执行以下操作:

brewbrew 回答:在Podfile上添加环境变量的可能性

是的,有可能。请记住,您仍然可以在Podfile中使用ruby语法。假设您将用户名保留在名为REPO_USERNAME的环境变量中。然后您的文件将如下所示:

platform :ios,'10.0'
source 'https://github.com/CocoaPods/Specs.git'
source 'https://' + ENV['REPO_USERNAME'] + '@bitbucket.org/awesometeamname/ios-private-specs.git'
use_modular_headers!

target 'a-generic-app-name' do
  use_frameworks!

  pod 'MaybeFirebase'
  pod 'AnotherSDK'
  pod 'AlamofireOfCourse'
  pod 'WhoUsesRxSwiftAnyway'

end

奖金

针对您的问题的IMO清洁器解决方案是使用SSH访问而不是HTTPS。然后,您可以为您的团队创建共享的SSH密钥,或将队友的SSH公共密钥添加到存储库中,以便他们所有人都可以访问。在这种情况下,您将对源使用以下行:

source 'git@github.com/CocoaPods/Specs.git'
source 'git@bitbucket.org/awesometeamname/ios-private-specs.git'

如果您认为这对您有用,则只需浏览Bitbucket的文档,以了解如何在存储库中使用SSH密钥。

干杯!

本文链接:https://www.f2er.com/3126416.html

大家都在问