簡體   English   中英

如何在單個項目中處理多個環境支持和不同目標?

[英]How to handle multiple environment support and different targets in a single project?

我有一個有兩個目標的項目:A 和 B。A 是主要應用程序目標,B 是共享擴展。

我有 4 個應用環境,即調試、開發、UAT 和發布。

另一方面,當應用程序在調試模式下運行時,它工作正常。 但是,當我切換到 Dev 方案時 - 它會遇到錯誤,例如無法為 Dev 找到 dev.xconfig 文件,而 Uat 環境也會發生同樣的情況。

所以我更新了 B 中與 pod 相關的鍵的構建設置: 在此處輸入圖像描述

但是,該應用程序再次遇到與某些或其他 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 install 上,我也有類似的警告: [.] 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. [.] 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 的 taget 'B' 中添加$(inherited)代碼,但再次遇到錯誤。

如果我在這里得到一些幫助,那將有很大幫助。

我已經按照如下說明在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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM