CocoaPods Crashes When Installing Firebase on Multiple Targets

Asked 2 years ago, Updated 2 years ago, 86 views

Currently, Embedded Framework is developing multiple targets.
Installing Firebase on multiple targets with CocoaPods crashes after bootup.

 objc [97307]: Class FIRMessagingLog is implemented in both / Users / yuto / Library / Developer / Xcode / DerivedData / App-bgkajtjdcnvxnxexzeimikirwu / Build / Products / Release-iphonesimulator / App.fabricated10/Uploads) / 039/Urules64-425F-A316-9303BD252618/App.app/App (0x1020f43b0).One of the two will be used.Which one is undefined.
objc[97307]: Class VCWeakObjectHolder is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AVConference.framework/Frameworks/ViceroyTrace.framework/ViceroyTrace (0x12556c4d0) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/AVConference.framework of the AVConference.framework of the 3812 (AVCourse)
2018-06-28 10:58:37.719414+0900 App [97307:3379853] 5.3.0 - [Firebase/Core] [I-COR000005] No app has been configured yet.

The Podfile is as follows:

abstract_target'Top'do
  # Uncomment the next line to define a global platform for your project
  platform:ios, '10.0'

  pod 'Firebase/Core'
  pod 'Firebase/Auth'

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

    # Pods for App

    target 'AppTests' do
      inherit!:search_paths
      # Pods for testing
    end

  end

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

    # Pods for AppExtension

  end

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

    # Pods for AppFlux

  end

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

    # Pods for AppKit

  end

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

    # Pods for AppUI

  end
end

Environment
Xcode:9.4.1
CocoaPods:5.0.1

I have referred to the following, but I am having trouble finding a specific solution.
- https://teratail.com/questions/87567
- https://github.com/firebase/quickstart-ios/issues/231

I would be very happy if you could reply.
Thank you for your cooperation.

swift ios xcode firebase cocoapods

2022-09-30 13:50

1 Answers

Firebase takes on the appearance of Framework, but it's actually a Static Library.When linked to multiple frameworks, multiple symbols are linked.
Also, due to the current use of CocoaPods, even if you link to a single target, the link flag is configured for all targets, which eventually causes the same problem.
There are many solutions, but basically you should link to one target and import that framework from other targets.
So the specific thing to do with CocoaPods is
Configure Podfile to link to only one target, and then add

platform:ios, '10.0'

use_frameworks!

pod 'SwiftGen'
pod 'SwiftLint'
pod 'LicensePlist'

target'XXXApp'do
  pod 'Shimmer', inhibit_warnings: true

  target'XXXAppTests'do
    inherit!:search_paths
    pod 'Mockingjay', inhibit_warnings: true
    pod 'iOSSnapshotTestCase', inhibit_warnings: true
  end

  target'XXXAppUITests' do
    inherit!:search_paths
  end
end

target'Foo'do
  pod 'GoogleTagManager', inhibit_warnings: true

  target 'FootTests' do
    inherit!:search_paths
    pod 'Mockingjay', inhibit_warnings: true
  end
end

post_install do | installer |
    installer.aggregate_targets.each do | aggregate_target |
        puts aggregate_target.name
        if aggregate_target.name == 'Pods-XXXApp'
            aggregate_target.xcconfigs.each do | config_name, config_file |
                config_file.libraries.delete('GoogleAnalytics')

                config_file.frameworks.delete('FirebaseAnalytics')
                config_file.frameworks.delete('FirebaseCore')
                config_file.frameworks.delete('FirebaseCoreDiagnostics')
                config_file.frameworks.delete('FirebaseInstanceID')
                config_file.frameworks.delete('FirebaseNanoPB')
                config_file.frameworks.delete('GoogleSymbolUtilities')
                config_file.frameworks.delete('GoogleTagManager')
                config_file.frameworks.delete('GoogleToolboxForMac')
                config_file.frameworks.delete('GoogleUtilities')
                config_file.frameworks.delete('nanopb')

                xcconfig_path=aggregate_target.xcconfig_path(config_name)
                config_file.save_as(xcconfig_path)
            end
        end
    end
end

^ As mentioned above, I think the easiest solution is to remove the link flag from the library related to Firebase from the target that does not link.
In this example, XXXApp and Foo are targets, and Foo is Embedded Framework.Firebase links only to Foo.
(GoogleTagManager relies on FirebaseAnalytics.)
However, CocoaPods also set up a link flag for XXXApp, so I removed the link flag from the Firebase related library from XXXApp.
Even if you have more targets, the logic is the same.


2022-09-30 13:50

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.