如何在单个项目中处理多个环境支持和不同目标?

时间:2021-02-03 15:21:51

标签: ios swift xcode cocoapods

我有一个项目有两个目标:A 和 B。 A是主应用目标,B是共享扩展。

我有 4 个应用环境,即调试、开发、UAT 和发布。

另一方面,当应用在调试模式下运行时,它工作正常。但是,当我切换到 Dev 方案时 - 它会遇到错误,例如无法为 Dev 找到 dev.xconfig 文件,并且在 Uat 环境中也会发生同样的情况。

所以我更新了 B 中与 pod 相关的键的构建设置: enter image description here

但是,应用程序再次遇到一些或其他与 pod 相关的导入错误,因为“不存在此类文件”

应用程序 podfile 如下所示:

# platform :ios, '9.0'

target 'A' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for A

  pod 'Alamofire'
  pod 'Firebase/Core'
  pod 'Firebase/Analytics'
  pod 'Firebase/Messaging'
  pod 'GooglePlaces'
  pod 'SwiftyChrono'
  pod 'Highcharts'
  pod 'SDWebImage'
  pod 'GoogleSignIn'
  pod 'GoogleAPIClientForREST/Drive'
  pod 'Giphy', :podspec => 'https://s3.amazonaws.com/sdk.mobile.giphy.com/SDK/2.0.1/Giphy.podspec'
  pod 'WSTagsField'  
  pod 'NewRelicAgent'
end


  target 'B' do
    # Comment the next line if you don't want to use dynamic frameworks
    use_frameworks!
    # Pods for 'B'
    pod 'NewRelicAgent'

end


post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
    end
  end
end

在安装 pod 时,我也会收到如下警告: [!] The `A [Debug UAT]` target overrides the `PODS_PODFILE_DIR_PATH` build setting defined in `Pods/Target Support Files/Pods-A/Pods-A.debug uat.xcconfig'. This can lead to problems with the CocoaPods installation - Use the `$(inherited)` flag, or - Remove the build settings from the target.

我尝试在 podfile 的目标“B”中添加 $(inherited) 代码,但再次遇到错误。

如果我在这里得到一些帮助,这将有很大帮助。

1 个答案:

答案 0 :(得分:0)

我已按照如下在 target 'B' 的构建设置中更新 pod 设置的说明解决了该问题,并且对我有用。 PODS_CONFIGURATION_BUILD_DIR , PODS_PODFILE_DIR_PATH, PODS_ROOT, USE_RECURSIVE_SCRIPT_INPUTS_IN_SCRIPT_PHASES, PODS_BUILD_DIR = $(inhertied)

    # Uncomment the next line to define a global platform for your project
  platform :ios, '11.0'

target 'A' do
  # Comment the next line if you don't want to use dynamic frameworks
  use_frameworks!

  # Pods for A

  pod 'Alamofire', '~> 4.9.1'
  pod 'Firebase/Core'
  pod 'Firebase/Analytics', '~> 6.14'
  pod 'Firebase/Messaging', '~> 6.14'
  pod 'GooglePlaces'
  pod 'SwiftyChrono'
  pod 'Highcharts' #, '~> 7.0.1'
  pod 'SDWebImage'
  pod 'GoogleSignIn'
  pod 'GoogleAPIClientForREST/Drive', '~> 1.3.7'
  pod 'Giphy', :podspec => 'https://s3.amazonaws.com/sdk.mobile.giphy.com/SDK/2.0.1/Giphy.podspec'
  pod 'WSTagsField'
  pod 'NewRelicAgent', '~> 5.14.2'
  
  target 'B' do
     # Comment the next line if you don't want to use dynamic frameworks
     use_frameworks!
   end

end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['APPLICATION_EXTENSION_API_ONLY'] = 'NO'
    end
  end
end
相关问题