Flutter project in XCode: "Multiple commands produce...FBSDKCoreKit.framework"
Asked Answered
R

3

6

I after upgrading my iOS to 16.4.1, which required me to upgrade my XCode to 14.3, which required me to upgrade my mac os from 12 to 13, I get this error when trying to build my iOS Flutter app:


Multiple commands produce '/Users//Library/Developer/Xcode/DerivedData/Runner-bczatismiambuefczuntppsiskse/Build/Products/Debug-iphoneos/Runner.app/Frameworks/FBSDKCoreKit.framework'

Target 'Runner' (project 'Runner') has copy command from '/Users//Documents/AndroidStudioProjects//ios/Pods/FBSDKCoreKit/XCFrameworks/FBSDKCoreKit.xcframework/ios-arm64/FBSDKCoreKit.framework' to '/Users/<my-name/Library/Developer/Xcode/DerivedData/Runner-bczatismiambuefczuntppsiskse/Build/Products/Debug-iphoneos/Runner.app/Frameworks/FBSDKCoreKit.framework'

That command depends on command in Target 'Runner' (project 'Runner'): script phase “[CP] Embed Pods Frameworks”


I have NOT added any new packages, pods, plugins whatever... it's just after my iOS and Mac OS (and XCode) updates, that I get this error.

I have checked this stackoverflow question, which didn't help me.

The error messages mention “[CP] Embed Pods Frameworks” so here's a screenshot of that under Build Phases in XCode:

enter image description here

And here's a screenshot of the "Build Phases" > "Copy Bundle Resources" section in my XCode, if that matters. (no Info.plist in there)

enter image description here


My Podfile:

# Uncomment this line to define a global platform for your project
platform :ios, '13.0'

# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
  'Debug' => :debug,
  'Profile' => :release,
  'Release' => :release,
}

def flutter_root
  generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__)
  unless File.exist?(generated_xcode_build_settings_path)
    raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first"
  end

  File.foreach(generated_xcode_build_settings_path) do |line|
    matches = line.match(/FLUTTER_ROOT\=(.*)/)
    return matches[1].strip if matches
  end
  raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get"
end

require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root)

flutter_ios_podfile_setup

#install! 'cocoapods', :disable_input_output_paths => true #didn't work from https://github.com/flutter/flutter/issues/20685

target 'Runner' do
  use_frameworks!
  use_modular_headers!

  flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
  
  
  # pods for firebase: //firebase: https://firebase.google.com/docs/ios/setup?authuser=0#available-pods
  # Add the Firebase pod for Google Analytics
  pod 'FirebaseAnalytics'

  # For Analytics without IDFA collection capability, use this pod instead
  # pod ‘Firebase/AnalyticsWithoutAdIdSupport’

  # Add the pods for any other Firebase products you want to use in your app
  # For example, to use Firebase Authentication and Cloud Firestore
  pod 'FirebaseAuth'
  pod 'GoogleSignIn'
  pod 'FBSDKCoreKit' # https://mcmap.net/q/1254124/-no-such-module-39-facebookcore-39-in-swift-5#answer-61751523
  pod 'FBSDKLoginKit' #<- only this one is mentioned in the docs: https://developers.facebook.com/apps/828723188239449/fb-login/quickstart/?sdk=cocoapods
  pod 'FirebaseFirestore'
  pod 'FirebaseFunctions'
  pod 'FirebaseAppCheck'
  
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
  end
  
#  installer.generated_projects.each do |project|
#    project.targets.each do |target|
#      target.build_configurations.each do |config|
#          config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
#       end
#    end
#  end

#  post_install do |installer|
#    installer.pods_project.targets.each do |target|
#      target.build_configurations.each do |config|
#        # drop deployment target so it works with ios14
#        config.build_settings.delete 'IPHONEOS_DEPLOYMENT_TARGET'
#      end
#    end
#  end
  
#  post_install do |installer|
#    installer.pods_project.targets.each do |target|
#      flutter_additional_ios_build_settings(target)
#      target.build_configurations.each do |config|
#        config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '13.0'
#      end
#    end
#  end

end

My AppDelegate.swift file:

import UIKit
import Flutter

//firebase: https://firebase.google.com/docs/ios/setup?authuser=0#available-pods
import FirebaseCore

import FirebaseAnalytics

import FirebaseAuth
//OAuth:
import GoogleSignIn
//import FacebookCore //from the official docs: https://developers.facebook.com/docs/facebook-login/ios#delegate
import FBSDKCoreKit //correction: https://mcmap.net/q/1254124/-no-such-module-39-facebookcore-39-in-swift-5#answer-61751523
import FBSDKLoginKit

import FirebaseFirestore
import FirebaseFunctions

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
      
      //from https://firebase.google.com/docs/app-check/flutter/debug-provider?authuser=0&hl=en#apple_platforms
#if DEBUG
    let providerFactory = AppCheckDebugProviderFactory()
    AppCheck.setAppCheckProviderFactory(providerFactory)
#endif
      
    GeneratedPluginRegistrant.register(with: self)
    
    // Use Firebase library to configure APIs
//    FirebaseApp.configure() //-> Exception: Thread 1: "Default app has already been configured."
    if (FirebaseApp.app()==nil){
      FirebaseApp.configure()
    }
    
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

Edit: I added additional screenshots showing every file named "Info.plist" within my project (searched via Mac OS Finder).

This first screenshot shows THE main Info.plist file. enter image description here


In this second screenshot, you can see 9 Info.plist files within the same project, but they are all inside Pods:

  • FBSDKCoreKit
  • Google-Mobile-Ads-SDK
  • FBSDKLoginKit
  • GoogleUserMessagingPlatform
  • FBAEMKit
  • FirebaseAnalytics
  • GoogleAppMeasurement
  • FBSDKCoreKit_Basics
  • GoogleAppMeasurement (inside another folder as 2 lines above)

enter image description here

my flutter doctor output:

enter image description here

Rist answered 11/4, 2023 at 18:41 Comment(4)
Did Your issue solve? @RistContractor
asked the same question on apple developer forums: developer.apple.com/forums/thread/729378 and on Meta for Developers Community Forum: developers.facebook.com/community/threads/242673138418156/… and added an issue in the github repository for the flutter_facebook_auth plugin: github.com/darwin-morocho/flutter-facebook-auth/issues/340Rist
I upgraded my Flutter version and suddenly everything works againRist
@Rist can you please give me your flutter version, facebook plugin version and x code version. Bucuse i have upgrade flutter version but still not work. And you have other suggetion please give me. Thanks a lot....Gorgerin
W
3

First step to debug is to open xcode and open PODS this PODS to be exact enter image description here

you will be able to see the duplicated file when you see the duplicated file you can usually delete it and re-run.

BUT

If you're using an extra package say notifications and you're getting this error

enter image description here

Go to the NotificationService>Build Settings then search for 'IPHONEOS_DEPLOYMENT_TARGET' there's a very big chance that it's build number is different from that of Runner and making pod generate 2 different files causing this duplicate error in the first place.

In my case I have duplicate pods pointing to 13 and 17.2 which caused this error.

So make sure it matches with your runner, then after that re-run

pod install

Then you can try building again

Walkup answered 28/2 at 7:11 Comment(1)
This made it work to me, thanks so muchSolutrean
S
0

First, try to clean the pod:

flutter clean
rm -Rf ios/Pods
rm -Rf ios/.symlinks
rm -Rf ios/Flutter/Flutter.framework
rm -Rf ios/Flutter/Flutter.podspec
rm ios/Podfile
flutter run
Stormy answered 25/4, 2023 at 15:10 Comment(2)
Also i would try with the most recent stable Flutter version - which is 3.7.12 at the moment.Hysteresis
@Hysteresis upgrading Flutter did it for me 🤦 thanksRist
P
0

Open your project in xcode then go to General in your project Targets, scroll down to Frameworks, Libraries, and Embedded Content then change the FBSDKCoreKit.xcframework from 'Embed & Sign' to 'Do Not Embed' and that should resolve the issue.

Pelargonium answered 8/1 at 9:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.