### Workaround for: 
###     CDN trunk URL couldn't be downloaded: •.podspec.json
###     Response: Error in the HTTP2 framing layer
### https://github.com/CocoaPods/CocoaPods/issues/12574
### https://github.com/CocoaPods/cdn.cocoapods.org/issues/6
source 'https://github.com/CocoaPods/Specs.git'

### Set minimum supported iOS version
#platform :ios, '12.4'
platform :ios, '15.1'

target 'DailyDozen' do
  ### Comment out the next line to *not*use* dynamic frameworks
  use_frameworks!

  ### Pods for DailyDozen
  ##pod 'Charts', '~> 4.1.0'
  pod 'DGCharts', '~> 5.1.0'
  pod 'FSCalendar', '~> 2.8.4'
  ##pod 'RealmSwift', '~> 4.4.1'
  ##pod 'RealmSwift', '~> 10.40.2'
  ##pod 'RealmSwift', '~> 10.44.0'
  ##pod 'RealmSwift', '~> 10.46.0'
  ##pod 'RealmSwift', '~> 10.44.0' no longer available. rolled back to 10.42.4
  pod 'RealmSwift', '~> 10.42.4'
  pod 'SimpleAnimation', '~> 0.4.2'
  
  ## https://github.com/firebase/firebase-ios-sdk
  ##
  ## Original
  ## Firebase (8.14.0)
  ## FirebaseAnalytics (8.14.0)
  ## FirebaseCore (8.14.0)
  ## FirebaseCoreDiagnostics (8.14.0)
  ## FirebaseInstallations (8.14.0)
  ## GoogleAppMeasurement (8.14.0)
  ## GoogleDataTransport (9.1.2)
  ## GoogleUtilities (7.7.0)
  ## PromisesObjC (2.1.0)
  ## nanopb (2.30908.0)
  
  #### Update
  ## Firebase 10.11.0
  ## FirebaseAnalytics 10.11.0
  ## FirebaseCore 10.11.0
  ## FirebaseCoreInternal 10.11.0
  ## FirebaseInstallations 10.11.0
  ## GoogleAppMeasurement 10.11.0
  ## GoogleUtilities 7.11.1
  ## PromisesObjC 2.2.0
  ## SwiftAlgorithms (1.0.0)
  ## nanopb 2.30909.0

  ## > pod update
  ## Update all pods
  ## Updating local specs repositories
  ## Analyzing dependencies
  ## Downloading dependencies
  ## Installing Charts 4.1.0
  ## Installing FSCalendar 2.8.4
  ## Installing Firebase 10.11.0
  ## Installing FirebaseAnalytics 10.11.0
  ## Installing FirebaseCore 10.11.0
  ## Installing FirebaseCoreInternal 10.11.0
  ## Installing FirebaseInstallations 10.11.0
  ## Installing GoogleAppMeasurement 10.11.0
  ## Installing GoogleUtilities 7.11.1
  ## Installing PromisesObjC 2.2.0
  ## Installing Realm 10.40.2 (was 4.4.1)
  ## Installing RealmSwift 10.40.2 (was 4.4.1)
  ## Installing SimpleAnimation 0.4.2
  ## Installing SwiftAlgorithms 1.0.0
  ## Installing nanopb 2.30909.0

  ##
  ### For Analytics WITH IDFA collection capability
  ##pod 'Firebase/Analytics'
  ### For Analytics WITHOUT IDFA collection capability
  ##pod 'Firebase/AnalyticsWithoutAdIdSupport', '~> 10.20.0' no longer available
  pod 'Firebase/AnalyticsWithoutAdIdSupport'
  ### Resulting install
  ### Installing Firebase (10.15.0)
  ### Installing FirebaseAnalytics (10.15.0)
  ### Installing FirebaseCore (10.15.0)
  ### Installing FirebaseCoreInternal (10.15.0)
  ### Installing FirebaseInstallations (10.15.0)
  ### Installing GoogleAppMeasurement (10.15.0)
  ### Installing GoogleUtilities (7.11.5)
  ### Installing PromisesObjC (2.3.1)
  ### Installing Realm (10.42.4)
  ### Installing RealmSwift (10.42.4)
  ### Installing SwiftAlgorithms (1.0.0)
  ### Installing nanopb (2.30909.0)
  
  target 'DailyDozenTests' do
    inherit! :search_paths
    # Pods for testing
  end
  
  target 'DailyDozenUITests' do
    # Pods for testing
  end
  
end

### Firebase issue 
### DT_TOOLCHAIN_DIR cannot be used to evaluate LIBRARY_SEARCH_PATHS, use TOOLCHAIN_DIR instead
post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
        ### Exclude building for arm64 simulator (M1 chipset).
        ### Note: Revisit `EXCLUDED_ARCHS` after removing RealmSwift
        ### Apple XCFrameworks are needed to support this properly, future work.
        #config.build_settings['EXCLUDED_ARCHS[sdk=iphonesimulator*]'] = 'arm64'
        #config.build_settings['ONLY_ACTIVE_ARCH'] = 'YES'
        
        #config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.4'
        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.1'
                
        #config.build_settings['ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES'] = '$(inherited)'
        
        ### Toggle Mac (Designed for iPhone/iPad); Vision (Designed for iPhone/iPad) destinations.
        #config.build_settings['SUPPORTS_MAC_DESIGNED_FOR_IPHONE_IPAD'] = 'NO'
        config.build_settings['SUPPORTS_MACCATALYST'] = 'NO'
        config.build_settings['SUPPORTS_XR_DESIGNED_FOR_IPHONE_IPAD'] = 'NO'
        
        ### other: `SDKROOT` iOS
        ### other: `ARCHS` = $(ARCHS_STANDARD)  --> for iPhone: (arm64)
        
        ### other: `ONLY_ACTIVE_ARCH` = YES <-- for Debug, DebugOSS only
        if config.name.include?("Debug")
            config.build_settings["ONLY_ACTIVE_ARCH"] = "NO"
        end
        
        ### other: `CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER` 'NO'
        ### not specified 'SWIFT_VERSION'
        
        ### :ADD: for Firebase issue
        xcconfig_path = config.base_configuration_reference.real_path
        xcconfig = File.read(xcconfig_path)
        xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
        File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }
        ###
    end
  end
end
