source 'https://github.com/lokion/cocoapods.git'
source 'https://cdn.cocoapods.org/'

project 'TestApp.xcodeproj'
platform :ios, '16.0'
use_frameworks!

# Versioned VMSDK pods. `package.sh` rewrites the version literals on
    pod 'VMSDK_Core', '2.2.12'
# tokens), so don't reformat these lines without updating that script.
    pod 'VMSDK_Core', '2.2.12'
# Swift demo does not depend on VMSDK_Legacy.
def available_pods
    pod 'VMSDK_Core', '2.2.12'
    pod 'VMSDK_Wayfinding', '2.2.12'
end

target "TestApp" do
    available_pods

    target "TestAppTests" do
        inherit! :search_paths
    end
end

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

  # See `Podfile` (dev) for rationale. LocalKeys.xcconfig is gitignored
  # and absent from published zips, so this is a no-op for consumers
  # until they create their own LocalKeys.xcconfig.
  local_keys_path = File.expand_path('TestApp/LocalKeys.xcconfig', __dir__)
  if File.exist?(local_keys_path)
    keys = {}
    File.readlines(local_keys_path).each do |line|
      next if line.strip.empty? || line.strip.start_with?('//', '#')
      k, v = line.split('=', 2).map(&:strip)
      keys[k] = v if k && v && !v.empty?
    end
    %w[debug release].each do |variant|
      pods_xcconfig = File.expand_path("Pods/Target Support Files/Pods-TestApp/Pods-TestApp.#{variant}.xcconfig", __dir__)
      next unless File.exist?(pods_xcconfig)
      original = File.read(pods_xcconfig)
      sentinel = '// LocalKeys override (do not edit)'
      stripped = original.split(sentinel).first.rstrip + "\n"
      injected = stripped + "\n#{sentinel}\n" + keys.map { |k, v| "#{k} = #{v}" }.join("\n") + "\n"
      File.write(pods_xcconfig, injected)
    end
  end
end
