iOS - 升级到 Xcode 4.5 后出现链接器错误,可能与 Core Plot 相关

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12411077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 01:29:28  来源:igfitidea点击:

iOS - Linker error after upgrading to Xcode 4.5, possibly Core Plot related

iphoneiosxcodelinkercore-plot

提问by Jonathan Wareham

I've just upgraded to Xcode 4.5GMand tidied up some screens in my iPhone project to cope with the extra screen size on iPhone 5. The project is targeting iOS 5.1and I've just come to build it for my phone and I get this linker error :

我刚刚升级Xcode 4.5GM并整理了我的 iPhone 项目中的一些屏幕,以应对 iPhone 5 上额外的屏幕尺寸。该项目的目标是iOS 5.1我刚刚为我的手机构建它,但我收到此链接器错误:

file is universal (2 slices) but does not contain a(n) armv7s slice: /Users/JonathanW/Documents/MyXcode/myApp/myApp/CorePlot/libCorePlot-CocoaTouch.a for architecture armv7s

文件是通用的(2 个切片),但不包含 (n) armv7s 切片:/Users/JonathanW/Documents/MyXcode/myApp/myApp/CorePlot/libCorePlot-CocoaTouch.a 用于架构 armv7s

I'm using the Core Plot 1.0static library in my project and have not had any issues with it until now. Looking around I can see similar errors to do with the build architecture settings but not sure where to go from here. The project works fine in the simulator (both iOS 5.1and iOS 6). Any ideas?

Core Plot 1.0在我的项目中使用静态库,直到现在还没有遇到任何问题。环顾四周,我可以看到与构建架构设置有关的类似错误,但不知道从哪里开始。该项目在模拟器中运行良好(iOS 5.1iOS 6)。有任何想法吗?

采纳答案by Ben Clayton

By the looks of it you'll need to rebuild the libCorePlot library with Xcode 4.5GM so that there's a ARMV7S build of the library. Seems as if it's trying to use the version you built with the older Xcode.

从外观上看,您需要使用 Xcode 4.5GM 重建 libCorePlot 库,以便有一个 ARMV7S 构建的库。似乎它正在尝试使用您使用旧 Xcode 构建的版本。

回答by JSWilson

I'm also using the Core Plot 1.0 static library in my project. I was able to address the problem by Setting Build Active Architectures Onlyto Yes. Build Active Architectures Onlyis in the Architecturesection of the Target's Build Settingsin Xcode.

我也在我的项目中使用 Core Plot 1.0 静态库。我能够通过将Build Active Architectures Only设置为Yes来解决这个问题。 Build Active Architectures Only位于 Xcode 中Target 的Build SettingsArchitecture部分。

I downloaded the Core Plot 1.0 zip file which seems to be incomplete so I cannot rebuild the libraries.

我下载了 Core Plot 1.0 zip 文件,该文件似乎不完整,因此无法重建库。

回答by Matt Wilding

It works in the simulator because the simulator will always use i386 architecture. That hasn't changed with the new SDK. What has changed is the presence of the iPhone 5, which uses a new architecture (armv7s). The project for your app automatically added armv7s as a valid architecture, but the library was likely compiled without knowledge of it. Thus, your arm7s-enabled app tries to link against a library that was built without armv7s and fails.

它在模拟器中工作,因为模拟器将始终使用 i386 架构。新的 SDK 并没有改变这一点。发生变化的是 iPhone 5 的出现,它使用了新的架构 (armv7s)。您的应用程序的项目自动将 armv7s 添加为有效架构,但该库可能是在不知情的情况下编译的。因此,您启用 arm7s 的应用程序尝试链接到一个没有 armv7s 构建的库并失败。

To fix it, you'll just need access to the project that produces the library. Modify the "Valid Architecture" setting on the target to include armv7s, then rebuild.

要修复它,您只需要访问生成库的项目。修改目标上的“有效架构”设置以包含 armv7s,然后重建。

回答by PeterK

I have been struggling with this for days now and finally succeeded getting it to work by creating a new static library.

我已经为此苦苦挣扎了好几天,终于通过创建一个新的静态库成功地让它工作了。

I used the Mercurial Source Code control system via the instructions here: Create a static library using Mecurialand the "Core-Plot Static Library Install" from the wiki found here: How to do a Static Library Install of Core-Plot

我通过这里的说明使用了 Mercurial 源代码控制系统:使用 Mecurial 创建一个静态库和来自维基的“Core-Plot 静态库安装”:How to do a Static Library Install of Core-Plot

I am posting this for people like me, with low experience, as this is quite simple and self explained.

我是为像我这样经验不足的人发布这个的,因为这很简单并且自我解释。

回答by TappCandy

Switch the compiler on the CorePlot project from the Apple LLVM Compiler 4.1 to LLVM GCC 4.2

将 CorePlot 项目上的编译器从 Apple LLVM Compiler 4.1 切换到 LLVM GCC 4.2

回答by Apollo SOFTWARE

did you do a clean and rebuild? Also check to see that you have armv6 and armv7 in the architectures. You may need to recompile your targets and re-add the libraries to the target

你做了清理和重建吗?还要检查架构中是否有 armv6 和 armv7。您可能需要重新编译目标并将库重新添加到目标

回答by Adel

Simply i compiled the core-plot library and followed the Dependent Project install from this link http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications
and every thing going like a charm (my project now support both armv7 and armv7s without any problems) , in addition i still set Build Active Architecture Only to NO , to be sure to support all Architectures

简单地我编译了 core-plot 库,然后从这个链接http://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications安装了依赖项目
,一切都像魅力一样(我的项目现在同时支持 armv7和 armv7s 没有任何问题),此外我仍然将 Build Active Architecture Only 设置为 NO ,以确保支持所有架构

回答by Patel Manthan

You just need to remove armv7s from the list of valid architectures.

您只需要从有效架构列表中删除 armv7s。

just do the following things. -Select your project from the Project Navigator -Select your target from the list of targets -Select the build settings tab -Find the ‘Valid Architectures' setting. It should say armv7 armv7s. Remove armv7s and there will be only armv7 in your valid architectures. Now your project will compile correctly.

只需做以下事情。- 从项目导航器中选择您的项目 - 从目标列表中选择您的目标 - 选择构建设置选项卡 - 找到“有效架构”设置。它应该说 armv7 armv7s。删除 armv7s,您的有效架构中将只有 armv7。现在您的项目将正确编译。

回答by whyoz

Fix linker errors for Core Plot when using Xcode 5

修复使用 Xcode 5 时 Core Plot 的链接器错误

I've been using Core Plot for years and was getting a bunch of "Apple Mach-O Linker Warning" errors about armv7s not supporting certain files in the "CorePlotHeader" folder that was updated (deleted folder currently in my project and dragged the new folder into my project) to reflect the CorePlot_1.4 changes. I also deleted the old "libCorePlot-CocoaTouch.a" library and brought that into my Frameworks folder. Everything worked fine in the simulator, but I couldn't build on my iPad 4 with iOS 7.0.2.

我多年来一直在使用 Core Plot,并且收到了一堆关于 armv7s 不支持更新的“CorePlotHeader”文件夹中的某些文件的“Apple Mach-O 链接器警告”错误(已删除当前在我的项目中的文件夹并拖动了新的文件夹到我的项目中)以反映 CorePlot_1.4 的变化。我还删除了旧的“libCorePlot-CocoaTouch.a”库并将其带入我的 Frameworks 文件夹中。在模拟器中一切正常,但我无法在装有 iOS 7.0.2 的 iPad 4 上进行构建。

Here's the only thing I found that works when Debugging (seems to work when Archiving, etc.):

这是我发现在调试时唯一有效的东西(在存档等时似乎有效):

1) Do everything I mentioned above, set Build Active Architectures to No, then clean

1) 做我上面提到的所有事情,将 Build Active Architectures 设置为 No,然后清理

2) You might get an error about the architecture "arm64" not being supported, so delete the "arm64" out of your "Valid Architecture" section in Build Settings

2)您可能会收到有关不支持架构“arm64”的错误,因此请从“构建设置”中的“有效架构”部分中删除“arm64”

3) Right click on your "MyApp.app" file in your Products folder when Debugging, and you might see the old "libCorePlot-CocoaTouch.a" (if the modified date is pre 9/28/13) compiling with your app.

3) 在调试时右键单击 Products 文件夹中的“MyApp.app”文件,您可能会看到旧的“libCorePlot-CocoaTouch.a”(如果修改日期是 2013 年 9 月 28 日之前)与您的应用程序一起编译。

4) Delete that library and copy the new one into the build folder, clean then rebuild

4)删除该库并将新库复制到构建文件夹中,清理然后重建

This works for the "Static Library Install" method and hasn't been tested using the "Dependent Project Install" method

这适用于“静态库安装”方法,尚未使用“依赖项目安装”方法进行测试

回答by ducdh1210

I use Core Plot 1.0 static library for iOS 6.1 in Xcode 4.4. After updating to Xcode 4.5 with iOS 7.0 I faced the same problem as yours.

我在 Xcode 4.4 中为 iOS 6.1 使用 Core Plot 1.0 静态库。使用 iOS 7.0 更新到 Xcode 4.5 后,我遇到了与您相同的问题。

To fix it, I deleted the CorePlotHeaders folder and libCorePlot-CocoaTouch.a in my project. If you delete it in Xcode, choose the option "Move To Trash".

为了修复它,我删除了项目中的 CorePlotHeaders 文件夹和 libCorePlot-CocoaTouch.a。如果您在 Xcode 中删除它,请选择“移至垃圾箱”选项。

Then I download CorePlot_1.4.zip from https://code.google.com/p/core-plot/downloads/list, then I follow Static Library Install from https://code.google.com/p/core-plot/wiki/UsingCorePlotInApplications

然后,我从下载CorePlot_1.4.zip https://code.google.com/p/core-plot/downloads/list,然后我按照静态库从安装https://code.google.com/p/core-绘图/维基/使用CorePlotInApplications

Hope it helps

希望能帮助到你