【问题标题】:Use of unresolved identifier 'FirebaseApp', only while creating a build仅在创建构建时使用未解析的标识符“FirebaseApp”
【发布时间】:2020-01-23 18:01:57
【问题描述】:

我正在尝试使用 Firebase 进行分析,但是当我在 AppDelegate 的 didFinishLaunchingWithOptions 中添加 FirebaseApp.configure() 时。

Xcode 提供使用未解析的标识符“FirebaseApp”。

奇怪的是,如果我在模拟器中构建代码,它会安装,但只有当我尝试使用通用 iOS 设备存档时才会生成错误。

为了解决这个问题,我尝试用 FireApp.configure() 替换它,它可以创建构建,但在通过 TestFlight 安装时会崩溃。

应用的部署版本为 10.0,Swift 版本为 4。

它与最新版本的 Cocoapods 兼容。

尝试将 FirebaseApp.configure() 替换为 FireApp.configure()

使用未解析的标识符“FirebaseApp”

Podfile如下

workspace 'Main.xcworkspace'
platform :ios, '10.0'
use_frameworks!

project 'A'
project 'B'
project 'C'
project 'D'

def common_pods
    pod 'Whisper', '~> 5.1.0'
    pod 'Gifu', '~> 2.0'
    pod 'Alamofire', '~> 4.0'
    pod 'SwiftyJSON'
    pod 'UIColor_Hex_Swift', '~> 3.0.2'
    pod 'DKImagePickerController', '~> 4.0.4'
    pod 'ReachabilitySwift', '~> 3'
    pod 'HueKit'
    pod 'HanekeSwift', :git => 'https://github.com/Haneke/HanekeSwift.git'
    pod 'PKHUD', '~> 4.0'
    pod 'MZFormSheetPresentationController'
    pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift4'
    pod 'Locksmith'
    pod 'Google/SignIn'
    pod 'DeviceKit', '~> 1.0'
    pod 'Amplitude-iOS', '~> 3.7.0'
    pod 'Firebase'
    pod 'Fabric'
    pod 'Crashlytics'
    pod 'Firebase/Analytics'
    pod 'TOCropViewController'
    pod 'Hero'
    pod 'Socket.IO-Client-Swift', '~> 14.0.0'
    pod 'NewPopMenu', '~> 2.0'
    pod "QRCode"
    pod 'VVCircleProgressBar'
    pod 'PMAlertController'
    pod 'SwiftMessages', :git => 'https://github.com/SwiftKickMobile/SwiftMessages', :commit => '2e4381b61648a0451a7852b57bb0b4a82a4e6ce2'
    pod 'MaterialShowcase'  
end

target 'C' do
    project 'C/C.xcodeproj'
    pod 'Alamofire', '~> 4.0'
    pod 'SwiftyJSON'
    pod 'Locksmith'
end

target 'B' do
    project 'B/B.xcodeproj'
    pod 'SwiftyJSON'
    pod 'Gifu', '~> 2.0'
    pod 'UIColor_Hex_Swift', '~> 3.0.2'
    pod 'DKImagePickerController', '~> 4.0.4'
    pod 'ReachabilitySwift', '~> 3'
    pod 'HanekeSwift', :git => 'https://github.com/Haneke/HanekeSwift.git'
    pod 'PKHUD', '~> 4.0'
    pod 'MZFormSheetPresentationController'
    pod 'DeviceKit', '~> 1.0'
    pod 'Amplitude-iOS', '~> 3.7.0'
    pod 'Spring', :git => 'https://github.com/MengTo/Spring.git', :branch => 'swift4'
    pod 'TOCropViewController'
    pod 'Alamofire', '~> 4.0'
    pod 'Whisper', '~> 5.1.0'
end

target 'Main' do
    project 'Main.xcodeproj'
    common_pods
end

target 'D' do
    project 'D/D.xcodeproj'
    common_pods
end


post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
      config.build_settings['SWIFT_VERSION'] = '4.0'
      config.build_settings['SWIFT_OPTIMIZATION_LEVEL'] = '-Onone'
    end
  end
end

【问题讨论】:

  • 你能分享你的 podfile 吗?
  • 使用 pod 文件编辑

标签: swift xcode firebase


【解决方案1】:

我添加了import FirebaseCore 然后问题解决了

【讨论】:

  • 太棒了!真烦人的问题
【解决方案2】:

我在主项目中添加了 Firebase pod。

【讨论】:

    【解决方案3】:

    您是否正在将 Firebase 导入您的班级?试试import Firebase。

    由于您有很多目标,可能与它们有关。您正在归档哪些目标?

    【讨论】:

    • 奇怪的是,如果我在模拟器中构建代码,它会安装,但只有当我尝试使用通用 iOS 设备存档时才会生成错误。它会抛出一个错误如果未导入 Firebase,请致电 FirebaseApp.configure()
    • 我正在归档主要目标
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多