简体   繁体   English

用于iOS的FacebookSDK iOS Mach-O链接器错误-未定义的符号_iosLogin,

[英]FacebookSDK for Unity iOS Mach-O linker error - undefined symbols _iosLogin,

I've added FacebookSDK into my Unity project according to tutorial here https://developers.facebook.com/docs/unity/getting-started/canvas/ . 我已根据此处https://developers.facebook.com/docs/unity/getting-started/canvas/的教程将FacebookSDK添加到我的Unity项目中。

It means that I've downloaded the SDK .unitypackage, imported it into Unity project and set application name and ID in configuration settings inspector. 这意味着我已经下载了SDK .unitypackage,将其导入Unity项目并在配置设置检查器中设置了应用程序名称和ID。

When I try to build for device, Xcode build hangs on following Mach-O linker error: 当我尝试为设备构建时,Xcode构建会因以下Mach-O链接器错误而挂起:

Undefined symbols for architecture armv7:
  "_iosLogin", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosLogout", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosInit", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosSetShareDialogMode", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosFeedRequest", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosAppRequest", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosFBSettingsPublishInstall", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosFBAppEventsSetLimitEventUsage", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosGetDeepLink", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosFBAppEventsLogPurchase", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
  "_iosFBAppEventsLogEvent", referenced from:
      RegisterMonoModules() in RegisterMonoModules.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It looks like Unity, Xcode or me forgot to include some library, search path or source file somewhere. 好像Unity,Xcode或我忘记在某个地方包含一些库,搜索路径或源文件。 Can you help me to find out what happened wrong? 您能帮我找出问题出在哪里吗? Do you know in which file this symbols should be or how to setup linker? 您知道该符号应该在哪个文件中,或者如何设置链接器?

Unity 4.3.0f4 (also tried 4.2.?)
Facebook SDK 4.3.4 (also tried 4.3.3)
Xcode 5.0.2, deployment target 4.0 (also tried 6.1)

Those symbols are exported from FacebookSDK.a, which should be getting included into your Xcode project by the [PostProcessBuild] step in /Assets/Facebook/Editor/FacebookPostprocess.cs. 这些符号是从FacebookSDK.a导出的,应该通过/Assets/Facebook/Editor/FacebookPostprocess.cs中的[PostProcessBuild]步骤将其包含到Xcode项目中。 That file actually spins through all of the files in your project that end with ".projmods" in their filename and applies them as transformations to your xcode project. 该文件实际上遍历项目中所有文件名中以“ .projmods”结尾的文件,并将它们作为转换应用于您的xcode项目。 I've seen 2 things go wrong here when having this kind of problem: 当遇到这种问题时,我发现这里有2处出错:

  1. I had removed either FacebookPostprocess.cs or some of the ".projmods" files from my project accidentally. 我不小心从项目中删除了FacebookPostprocess.cs或某些“ .projmods”文件。 Check that both exist. 检查两者是否都存在。 The specific projmods file in this case should be at /Assets/Facebook/Editor/iOS. 在这种情况下,特定的projmods文件应位于/ Assets / Facebook / Editor / iOS。
  2. You have your own [PostProcessBuild] steps that clobber Facebook's changes. 您有自己的[PostProcessBuild]步骤来破坏Facebook的更改。 You can fix this by applying the optional "order" parameter to the PostProcessBuild attribute. 您可以通过将可选的“ order”参数应用于PostProcessBuild属性来解决此问题。

You can also check in Xcode that FacebookSDK.a is, indeed, in the /Libraries group of the project and that under "Build Phases" it is included as a binary to link with. 您还可以在Xcode中检查FacebookSDK.a确实位于项目的/ Libraries组中,并且在“ Build Phases”下将其包含为要链接的二进制文件。

Also look carefully at the log output from Unity when you build. 在构建时,还要仔细查看Unity的日志输出。 Sometimes the projmods postprocessor will complain about files not found, etc. 有时projmods后处理器会抱怨找不到文件等。

One other potential cause of this: the Facebook SDK uses a third-party library XCode-Editor-for-Unity to do it's XCode project postprocessing. 另一个潜在原因是:Facebook SDK使用第三方库XCode-Editor-for-Unity进行XCode项目后处理。 If any other middleware in your project uses this as well, you'll potentially have duplicate instances of it. 如果项目中的任何其他中间件也使用了此中间件,则可能会有重复的实例。

In our case, the SponsorPay api also had a copy of this library, and when importing the Facebook API it was overwriting SponsorPay's implementation of it (which had some modifications from the original library). 在我们的案例中,SponsorPay api也拥有该库的副本,并且在导入Facebook API时,它正在覆盖SponsorPay对其的实现(对原始库进行了一些修改)。

This took a few steps to fix: 这采取了一些步骤来解决:

First, move each instance to its own namespace, and fix the references to them: 首先,将每个实例移至其自己的名称空间,并修复对其的引用:

in Facebook/Editor/iOS/XCodeEditor-for-Unity/*.cs: 在Facebook / Editor / iOS / XCodeEditor-for-Unity / *。cs中:

namespace UnityEditor.XCodeEditor.Facebook
{
    ...
}

and in Facebook/Editor/FacebookPostprocess.cs: 并在Facebook / Editor / FacebookPostprocess.cs中:

// our 'XCProject' is now in the UnityEditor.XCodeEditor.Facebook namespace
UnityEditor.XCodeEditor.Facebook.XCProject project =
    new UnityEditor.XCodeEditor.Facebook.XCProject(path);

... And do the same for the other library. ...并对其他库执行相同的操作。


Once we had this fixed, we ran into one last problem: Each library's Postprocess script was walking over the entire project to find .projmods files, which meant each of these files got processed twice (once by the wrong implementation, which triggered another crash). 修复此问题后,我们遇到了最后一个问题:每个库的Postprocess脚本都在整个项目中.projmods以查找.projmods文件,这意味着每个文件都被处理了两次(一旦执行错误,就会引发另一次崩溃) 。

So, one last step, make sure each of the libraries is postprocessing only its own path: 因此,最后一步,请确保每个库仅对其自己的路径进行后处理:

// Find and run through all projmods files to patch the project

// Set this to your project's Facebook API location:
string sdkPath = "Facebook/Editor/iOS";
string projModPath = System.IO.Path.Combine(Application.dataPath, sdkPath)
var files = System.IO.Directory.GetFiles(projModPath, "*.projmods", System.IO.SearchOption.AllDirectories);

foreach (var file in files)
{
    project.ApplyMod(Application.dataPath, file);
}
project.Save();

and again, doublecheck this for the other library as well. 再次对其他库再次进行检查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 FacebookSDK 3.0 - Apple Mach-O链接器错误 - FacebookSDK 3.0 - Apple Mach-O Linker Error iOS应用程序中的Mach-O Linker错误 - Mach-O Linker Error in iOS application iOS:SocketRocket Mach-o链接器错误 - iOS: SocketRocket Mach-o Linker Error iOS Mach-o链接器错误解析 - iOS Mach-o linker error parse 在iOS5中实现库时,获取“apple mach-o linker id错误未定义的架构i386符号” - Getting “apple mach-o linker id error undefined symbols for architecture i386” when implement a Library in iOS5 Apple Mach-O链接器错误。 架构armv7的未定义符号 - Apple Mach-O Linker Error. Undefined symbols for architecture armv7 Apple Mach-O链接器错误/体系结构i386的未定义符号: - Apple Mach-O Linker Error / Undefined symbols for architecture i386: Apple Mach-O链接器错误-体系结构x86_64的未定义符号:“ _ UISceneWillEnterForegroundNotification”和“ ___isPlatformVersionAtLeast” - Apple Mach-O Linker Error - Undefined symbols for architecture x86_64: “_UISceneWillEnterForegroundNotification” and “___isPlatformVersionAtLeast” 如何修复Apple Mach-o链接器错误“体系结构i386的未定义符号”? - How can I fix apple mach-o linker error “Undefined symbols for architecture i386”? Apple Mach-o链接器错误体系结构i386的未定义符号: - Apple Mach-o Linker Error Undefined symbols for architecture i386:
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM