【问题标题】:Build error. Installing Firebase in Xcode iOS app with multiple targets and NotificationServiceExtensions构建错误。在具有多个目标和 NotificationServiceExtensions 的 Xcode iOS 应用程序中安装 Firebase
【发布时间】:2020-05-11 13:18:13
【问题描述】:

我正在尝试将 Firebase(用于动态链接)集成到我当前的 Xcode iOS 项目中,但我在构建中遇到了错误问题(遵循此文档:https://firebase.google.com/docs/dynamic-links/ios/receive)。

我的 Podfile 看起来像这样:

# Uncomment the next line...
# platform :ios, '9.0'


target 'AppName1' do
    # Comment the next line if you don't want to use dynamic frameworks

    use_frameworks!


    # Pods for AppName1
    pod 'Firebase/Analytics'
    pod 'Firebase/DynamicLinks'
end


target 'NotificationServiceExtension' do
    # Comment the next line if you don't want to use dynamic frameworks

    use_frameworks!


    # Pods for NotificationServiceExtension
    pod 'Firebase/Analytics'
    pod 'Firebase/DynamicLinks'end


(... With more targets ...)

测试1。当我尝试编译 App 目标时,这是我得到的错误:

Error1 Image

'FirebaseCore/FirebaseCore.h' file not found
Firebase.h
While building module 'Firebase' imported from */AppDelegate.h:1.1:
In file included from <module-includes>:1:

Could not build module 'Firebase'
AppDelegate.h
In the file included from */ViewControllerLogin.m:9:
In the file included from */ViewControllerLogin.h:10:

测试2。如果我从 NotificationServiceExtensions 中删除“pod 'Firebase/ ...”行,我会收到以下错误:

Error2 Image

'sharedApplication' is unavailable: not available on iOS (App Extension) - Use view controller based solutions where appropriate instead.

'openURL:' is unavailable: not available on iOS (App Extension)

测试1。如果我评论“use_frameworks!”使用#,我再次遇到第一个错误。

测试2。如果我评论目标 NotificationServiceExtensions 中的所有内容,我会得到:

Library not found for -lFirebaseCore

对于我再次执行“pod deintegrate”和“pod install”的每个测试,打开 PROJECT-NAME.xcworkspace,清理并构建。

我不知道还有什么可以尝试或我做错了什么......(与android的集成非常容易......)

谢谢。

【问题讨论】:

    标签: ios firebase


    【解决方案1】:

    试试这个:

    target 'AppName1' do
    # Comment the next line if you don't want to use dynamic frameworks
    
    use_frameworks!
    
    
    # Pods for AppName1
    pod 'Firebase/Analytics'
    pod 'Firebase/DynamicLinks'
    
    target 'NotificationServiceExtension' do
    # Comment the next line if you don't want to use dynamic frameworks
    
    use_frameworks!
    
    
    # Pods for NotificationServiceExtension
    pod 'Firebase/Analytics'
    pod 'Firebase/DynamicLinks'
    
      end
    end
    
    post_install do |installer|
       installer.pods_project.targets.each do |target|
        puts target.name
     end
    end
    

    CocoaPods docs

    【讨论】:

    • 它不起作用,我从问题中得到了 Error2。我怀疑这与扩展程序与 Firebase 无法正常工作有关 (stackoverflow.com/questions/50592585/…) 但我不知道该怎么办。
    • 我得到 Error2 仅将目标设置为 NO(仅需要将 App-Extension-Safe Api 设置为 NO)。如果将 Pod 上的所有内容设置为 NO,我会收到一个新错误:“ld: framework not found Pods_AppName1 clang: error: linker command failed with exit code 1 (use -v to see invocation)”。我也尝试了多种变体,但没有运气......
    【解决方案2】:

    扩展程序目前不支持 Firebase 动态链接。

    在https://github.com/firebase/firebase-ios-sdk 提出问题以请求考虑。

    【讨论】:

      【解决方案3】:

      问题与 xcode 未使用 app 目标构建 pods 目标有关。

      pods 文件中的正确配置是仅在目标应用中而不是在目标扩展中包含“pod 'Firebase/Analytics' pod 'Firebase/DynamicLinks'”(问题中的 TEST2)。

      执行“pod update”或“pod install”并打开正确的“your-project.xcworkspace”后,答案是转到 Pods 父 Target 的 Build Settings 并设置设置“Build Active Architecture Only ”到“No”(每次更新 pod,在 Debug 模式下,此设置都会返回“Yes”)。这样,Pod Target 就与 App Target 一起构建。

      【讨论】:

      • 但这一次却引发了很多“未定义符号”的错误。
      猜你喜欢
      • 1970-01-01
      • 2018-12-24
      • 1970-01-01
      • 2012-08-04
      • 2018-05-04
      • 2015-12-15
      • 2021-03-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多