Firebase Analytics与iOS框架开发项目 [英] Firebase Analytics with iOS framework development project

查看:181
本文介绍了Firebase Analytics与iOS框架开发项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用coocapods添加Firebase分析工具,我的Podfile是
$ b

  platform:ios,'8.0'
use_frameworks !

工作区'ProjectWorkspace.xcworkspace'

abstract_target'显示'
pod'SwiftProtobuf',git:'https://github.com/apple/swift -protobuf.git',:tag => '0.9.24'
pod'Firebase / Core'
pod'Firebase / Messaging'

'HostApp'do
项目'HostAppFolder / HostApp.xcodeproj'
$ b $ end b $ b target'HostAppReleaseTarget'do
project'HostAppFolderApp / HostApp.xcodeproj'

end

target'FrameWorkProject '做
项目'FrameworkProjectFolder / FrameWorkProject.xcodeproj'
结束

结束

如果我只将SwiftProtobuf作为依赖项添加,它对于主机应用程序以及Framework项目都可以正常工作。

如果我添加了Firebase依赖项,我得到一个运行时错误,并且应用程序崩溃,并显示错误消息


Class Foo是在HostApplicationPath和FrameworkProjectPath中实现的,其中一个将被使用。哪一个是未定义的。


为Firebase的每个类文件。



当我从框架项目中删除其他的连接器标志$(继承),这是工作正常,但我不能使用firebase到我的框架项目。

我的框架和主机应用程序写在Swfit 3.0和xcode版本是8.x

我的项目结构是
i手动创建了一个工作区并命名为EVAWorkspace.xcworkspace并添加了我的主机应用程序和框架项目到这个工作区,然后我将cocoapods添加到工作区。




Eva是框架项目,EvaApp是宿主应用程序项目。 解决方案

XCode中的清理生成文件夹选项可确保您每次都得到一个干净的构建。如果你真的想确保你可以删除〜/ Library / Developer / Xcode中的 DerivedData 文件夹, code>开始之前(只要确保Xcode在你删除时关闭)

首先,确保你的Pods项目有Build Active Architecture Only在其生成设置中设置为 NO 。然后尝试清理构建文件夹并重建。这可能会解决您的问题,否则请继续阅读。



您所描述问题的最常见原因:架构X的未定义符号是,在你的代码库,但没有正确的链接。



解决这个问题,你应该:


  • 将库添加到 BuildPhases中 链接的框架和库 / strong>

  • 将库的路径添加到生成设置下的 库搜索路径 然后将``l -l {你的图书馆}添加到 其他链接器标志 中。


    如果这不能解决你的问题,可能是链接器没有得到所需的标志,你可以尝试添加$(继承)到 Other Linker Flags生成设置的 部分。



    不要忘记在尝试eac之前清理生成文件夹h这些技术。

    如果在完成所有这些之后,问题仍然存在,请删除项目中所有Cocoapods创建的文件,然后发布 pod install的输出 - 详细这里。


    I am adding Firebase analytics using coocapods, my Podfile is

    platform :ios, '8.0'
    use_frameworks!
    
    workspace 'ProjectWorkspace.xcworkspace'
    
    abstract_target 'Shows' do
        pod 'SwiftProtobuf', git: 'https://github.com/apple/swift-protobuf.git', :tag => '0.9.24'
        pod 'Firebase/Core'
        pod 'Firebase/Messaging'
    
        target 'HostApp' do
            project 'HostAppFolder/HostApp.xcodeproj'
    
        end
        target 'HostAppReleaseTarget' do
            project 'HostAppFolderApp/HostApp.xcodeproj'
    
        end
    
        target 'FrameWorkProject' do
            project 'FrameworkProjectFolder/FrameWorkProject.xcodeproj'
        end
    
    end
    

    if I add SwiftProtobuf only as dependency it's working fine for host application as well as for Framework project.

    If I add Firebase dependency, I get a run-time error and the application crashes with error msg

    Class Foo is implemented in both, HostApplicationPath and FrameworkProjectPath One of the two will be used. Which one is undefined.

    for each class file of Firebase.

    when I remove other linker flags $(inherited) from framework project, it's work fine, but I can not use firebase into my framework project.

    My framework and Host application is written in Swfit 3.0 and xcode version is 8.x

    My Project structure is i have created a workspace manually and named it "EVAWorkspace.xcworkspace" and added my host application and framework project into this workspace and then i am adding cocoapods to workspace.

    Eva is framework project and EvaApp is host application project.

    解决方案

    Before trying each of the following, use the "Clean Build Folder" option in XCode to ensure you're getting a clean build each time. If you want to be really sure, you can delete the DerivedData folder in ~/Library/Developer/Xcode before starting (just make sure Xcode is closed when you delete it)

    First of all, ensure that your Pods project has "Build Active Architecture Only" set to NO in its Build settings. Then try cleaning the build folder and rebuilding. This might solve your issue, otherwise read on.

    The most common reason for the problem you have described: "Undefined symbols for architecture X" is that you've imported a library in your code but have not linked against it correctly.

    to solve this, you should either:

    • Add the library to "Linked Frameworks and Libraries" in your "BuildPhases"

    • Add the library's path to "Library Search Paths" under Build Settings, and then add `"-l{your library} to "Other Linker Flags".

    If this does not solve your problem, it might be that the linker is not getting the required flags. You could try adding $(inherited) back to the "Other Linker Flags" section of Build Settings.

    Don't forget to clean your build folder before trying each of these techniques.

    If after doing all this your problem still persists, please delete all Cocoapods created files in your project and then post the output of pod install --verbose here.

    这篇关于Firebase Analytics与iOS框架开发项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆