添加本地动态框架后,Cocoapods Mach-O链接器错误

时间:2017-04-21 20:45:24

标签: ios swift firebase cocoapods

我最近通过添加项目屏幕上的+按钮将我的数据模型对象移动到他们自己的框架。我移动了所有文件,并将目标成员资格更改为AppCore,而不是App。该项目纯粹是在斯威夫特。

我将podfile更新为以下内容:

platform :ios, '10.0'
inhibit_all_warnings!

target 'App' do
    use_frameworks!
    pod 'Firebase/Core'
    pod 'Firebase/Auth'
    pod 'Firebase/Database'
    pod 'Firebase/Crash'
    pod 'Firebase/Storage'
    pod 'FBSDKCoreKit'
    pod 'FBSDKLoginKit'
    pod 'FBSDKShareKit'

    target 'AppCore' do
        inherit! :search_paths
    end
end

每当我尝试构建时,我都会遇到4个错误:

Undefined symbols for architecture arm64: "_OBJC_CLASS_$_FIRDataSnapshot", referenced from: objc-class-ref in SSWorkout.o "_OBJC_CLASS_$_FIRDatabase", referenced from: objc-class-ref in SSReference.o objc-class-ref in SSReferrable.o "_OBJC_CLASS_$_FIRAuth", referenced from: objc-class-ref in SSUser.o "_OBJC_CLASS_$_FIRDatabaseReference", referenced from: objc-class-ref in SSOperation.o ld: symbol(s) not found for architecture arm64 clang: error: linker command failed with exit code 1 (use -v to see invocation)

我已经解组并重新安装了pod,清理了项目,清理了构建文件夹,删除了派生数据等,我无法编译它。

您可以在演示项目中重现这一点,运行pod install并尝试构建。

https://github.com/Raesu/Demo-Proj

2 个答案:

答案 0 :(得分:1)

Firebase的pod中的库目前构建为静态库。将静态库链接到动态库框架是不可能的 -  你的例子中的DemoCore。

答案 1 :(得分:0)

尝试在Xcode构建设置中启用bitcode并进行干净构建,这有助于我解决问题

#define _WIN32_WINNT _WIN32_IE_WIN8
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>

int main()
{
    DWORD dwPid      = 0;

    BOOL found       = FALSE;
    BOOL wow64       = FALSE;

    HANDLE hProcess  = NULL;
    HANDLE hThread   = NULL;
    HANDLE hSnapshot = INVALID_HANDLE_VALUE;

    THREADENTRY32 th32;

    WOW64_CONTEXT wow64ctxt = {0};

    printf("PID: ");
    scanf("%lu", &dwPid);

    hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPid);

    if(hProcess == NULL)
    {
        printf("Error getting handle to process: %lu\n", GetLastError());
        return 1;
    }

    if(!IsWow64Process(hProcess, &wow64))
    {
        printf("Error determining bitness of process: %lu\n", GetLastError());
        return 1;
    }

    if(!wow64)
    {
        printf("Error, not a 32-bit process... closing program\n");
        return 1;
    }

    hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, dwPid);

    if(hSnapshot == INVALID_HANDLE_VALUE)
    {
        printf("Error getting thread snapshot: %lu\n", GetLastError());
        return 1;
    }

    th32.dwSize = sizeof(THREADENTRY32);

    if(!Thread32First(hSnapshot, &th32))
    {
        printf("Error Thread32First: %lu\n", GetLastError());
        return 1;
    }

    while(Thread32Next(hSnapshot, &th32))
    {
        if(th32.th32OwnerProcessID == dwPid)
        {
            found = TRUE;
            break;
        }
    }

    if(!found)
    {
        printf("Thread could not be found\n");
        return 1;
    }

    hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, th32.th32ThreadID);

    if(hThread == NULL)
    {
        printf("Error getting a handle to thread %lu: %lu\n", th32.th32ThreadID, GetLastError());
        return 1;
    }

    if(Wow64SuspendThread(hThread) == -1)
    {
        printf("Error suspending thread: %lu\n", GetLastError());
        return 1;
    }

    wow64ctxt.ContextFlags = WOW64_CONTEXT_FULL;

    if(!Wow64GetThreadContext(hThread, &wow64ctxt))
    {
        printf("Error getting thread context: %lu\n", GetLastError());
    }

    ResumeThread(hThread);

    printf("EAX: %lu\n", wow64ctxt.Eax);
    printf("EBP: %lu\n", wow64ctxt.Ebp);
    printf("EIP: %lu\n", wow64ctxt.Eip);

    return 0;
}