Exclude pod when porting to mac with catalyst

后端 未结 6 1445
陌清茗
陌清茗 2020-12-13 14:32

Porting apps to mac is finally possible thanks to Catalyst, problem is, numerous pods don\'t support AppKit. Most common one would be Crashlytics / Firebase

6条回答
  •  佛祖请我去吃肉
    2020-12-13 15:01

    I have an updated solution that works for me with the following Google pods:

      pod 'FirebaseUI/Auth'
      pod 'FirebaseUI/Phone'
      pod 'FirebaseUI/Email'
      pod 'Firebase/Auth'
      pod 'Firebase/Analytics'
      pod 'Fabric', '~> 1.10.2'
      pod 'Firebase/Crashlytics'
      pod 'Firebase/AdMob'
    
    post_install do |installer|
      installer.pods_project.targets.each do |target|
        if target.name.start_with?("Pods")
            puts "Updating #{target.name} to exclude Crashlytics/Fabric"
          target.build_configurations.each do |config|
            xcconfig_path = config.base_configuration_reference.real_path
            xcconfig = File.read(xcconfig_path)
            xcconfig.sub!('-framework "FirebaseAnalytics"', '')
            xcconfig.sub!('-framework "FIRAnalyticsConnector"', '')
            xcconfig.sub!('-framework "GoogleMobileAds"', '')
            xcconfig.sub!('-framework "Google-Mobile-Ads-SDK"', '')
            xcconfig.sub!('-framework "GoogleAppMeasurement"', '')
            xcconfig.sub!('-framework "Fabric"', '')
            new_xcconfig = xcconfig + 'OTHER_LDFLAGS[sdk=iphone*] = $(inherited) -framework "FirebaseAnalytics"  -framework "FIRAnalyticsConnector"  -framework "GoogleMobileAds" -framework "GoogleAppMeasurement" -framework "GoogleUtilities" "-AppMeasurement" -framework "Fabric"'
            File.open(xcconfig_path, "w") { |file| file << new_xcconfig }
          end
        end
      end
    end
    

提交回复
热议问题