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

# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!

# ignore all warnings from all pods
inhibit_all_warnings!

post_install do |installer|

    # Strip Bitcode from framewords after Xcode 16.0
    bitcode_strip_path = `xcrun --find bitcode_strip`.chop!
    
    def strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
        framework_path = File.join(Dir.pwd, framework_relative_path)
        command = "#{bitcode_strip_path} #{framework_path} -r -o #{framework_path}"
        puts "Stripping bitcode: #{command}"
        system(command)
    end

    framework_paths = [
        "Pods/GoogleAds-IMA-iOS-SDK/GoogleInteractiveMediaAds.framework/GoogleInteractiveMediaAds",
        "Pods/SAKSDK/SAKSDK.xcframework/ios-arm64_armv7/SAKSDK.framework/SAKSDK",
        "Pods/SnapSDK/SCSDKCoreKit.xcframework/ios-arm64_armv7_armv7s/SCSDKCoreKit.framework/SCSDKCoreKit",
        "Pods/SnapSDK/SCSDKCreativeKit.xcframework/ios-arm64_armv7_armv7s/SCSDKCreativeKit.framework/SCSDKCreativeKit"
    ]

    #framework_paths.each do |framework_relative_path|
    #    strip_bitcode_from_framework(bitcode_strip_path, framework_relative_path)
    #end
    # EOF Strip Bitcode from framewords after Xcode 16.0

    installer.pods_project.targets.each do |target|
        target.build_configurations.each do |config|
            # Global build settings adjustments
            config.build_settings['INHIBIT_ALL_WARNINGS'] = "YES"
            config.build_settings['CODE_SIGNING_ALLOWED'] = "NO"
            config.build_settings['CODE_SIGNING_REQUIRED'] = "NO"
            config.build_settings['EXPANDED_CODE_SIGN_IDENTITY'] = ""
            config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.0'

            # Disable User Script Sandboxing (Xcode 15+/16 compatibility)
            config.build_settings['ENABLE_USER_SCRIPT_SANDBOXING'] = 'NO'

            # Ensure EXCLUDED_ARCHS is consistent across all simulator builds
            #config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64"
        end
    end
end

workspace 'Nabd'

def main_pods
  
  #pod 'Nabd_Support', :path => 'Submodules/NabdSupport'

  pod 'FirebaseAnalytics', '12.16.0'
  pod 'FirebaseCrashlytics', '12.16.0'

  pod 'GoogleSignIn', '9.2.0'
  
  pod 'TrustKit', '3.0.7'

  pod 'PersonalizedAdConsent', '1.0.5'
  
  pod 'AppsFlyerFramework', '6.18.1'
  pod 'SnapSDK', '2.5.0', :subspecs => ['SCSDKCreativeKit']

  pod 'FBSDKCoreKit', '18.1.0'
  pod 'FBSDKLoginKit', '18.1.0'
  pod 'FBSDKShareKit', '18.1.0'

  pod 'OpenSSL-Universal', '3.6.2000'
end

def ads_pods

  pod 'GoogleAds-IMA-iOS-SDK', '3.18.5'

  pod 'Google-Mobile-Ads-SDK', '13.3.0'

  # Removed by Google: https://developers.google.com/admob/ios/mediation/snap
  # pod 'GoogleMobileAdsMediationSnap', '2.1.0.1'
  pod 'GoogleMobileAdsMediationAppLovin', '13.6.2.0'
  pod 'GoogleMobileAdsMediationPangle', '7.9.1.1.0'
  pod 'GoogleMobileAdsMediationVungle', '7.7.2.0'
  pod 'GoogleMobileAdsMediationMintegral', '8.1.3.0'
  pod 'GoogleMobileAdsMediationUnity', '4.17.0.0'

  pod 'SAKSDK', '2.1.0'

  pod 'AppLovinSDK', '13.6.2'
  pod 'AppLovinMediationGoogleAdManagerAdapter', '13.3.0.0'
  pod 'AppLovinMediationGoogleAdapter', '13.3.0.0'
  
  pod 'FBAudienceNetwork', '6.21.1'
  pod 'GoogleMobileAdsMediationFacebook', '6.21.1.0'
  pod 'AppLovinMediationFacebookAdapter', '6.21.1.0'

  #pod 'AppLovinMediationSnapAdapter', '2.0.0.1' #manually-added

  pod 'AmazonPublisherServicesSDK', '5.6.1'
  pod 'AmazonPublisherServicesAdMobAdapter', '5.0.0'
end

target 'Nabd' do
  main_pods
  ads_pods
end

target 'Nabiz' do
  main_pods
  ads_pods
end

target 'WLAds' do
  project 'Submodules/WLAds/WLAds.xcodeproj'
  ads_pods
end

target 'WLReels' do
  project 'Submodules/Reels/WLReels.xcodeproj'
  ads_pods
end

target 'WLStoreKit' do
  project 'Submodules/WLStoreKit/WLStoreKit.xcodeproj'
  
  #pod 'Nabd_Support', :path => 'Submodules/NabdSupport'
  pod 'OpenSSL-Universal', '3.6.2000'
end
