在文件libCorePlot-CocoaTouch.a中缺少必需的体系结构x86_64

根据Ray Wenderlich教程 ,我做了以下工作:

第1步 –我在官方网站上下载了CorePlot_1.4.zip

第2步 –我在我的项目中添加了CorePlotHeaders文件夹名为libCorePlot-CocoaTouch.a静态库 (选中“将项目复制到目标组的文件夹(如果需要)”

第3步 –我将以下内容添加到Other Linker Flags字段-ObjC

第4步 – 如果libCorePlot-CocoaTouch.aQuartzCore框架在这里,我检查了Link Binary和Libraries

结果:当我编译我的项目时,它在我使用Iphone Retina(4英寸)时工作正常。 但是当我使用Iphone Retina(4英寸64位)时,我尝试构建和运行时收到以下消息:

ld: warning: ignoring file /blah/blah/libCorePlot-CocoaTouch.a, missing required architecture x86_64 in file /blah/blah/libCorePlot-CocoaTouch.a (3 slices)

这里有完整的信息:

 ld: warning: ignoring file /Users/me/Desktop/project/libCorePlot-CocoaTouch.a, missing required architecture x86_64 in file /Users/me/Desktop/project/libCorePlot-CocoaTouch.a (3 slices) Undefined symbols for architecture x86_64: "_CPTDecimalFromCGFloat", referenced from: -[PatientConstanteVisualiser configurePlots] in PatientConstanteVisualiser.o -[PatientConstanteVisualiser configureAxes] in PatientConstanteVisualiser.o "_CPTDecimalFromInteger", referenced from: -[PatientConstanteVisualiser configureAxes] in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTAxisLabel", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTColor", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTFill", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTMutableLineStyle", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTMutableTextStyle", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTPlotSymbol", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTScatterPlot", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTTheme", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_OBJC_CLASS_$_CPTXYGraph", referenced from: objc-class-ref in PatientConstanteVisualiser.o "_kCPTStocksTheme", referenced from: -[PatientConstanteVisualiser configureGraph] in PatientConstanteVisualiser.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

我在这个问题上花了几个小时…请帮忙……

如果您需要64位版本的Core Plot,则必须构建新版本的静态库。 Arm64版本需要iOS 7,但Core Plot也支持早期版本,因此预构建的库仅为32位。

打开CorePlot-CocoaTouch.xcodeproj并将架构设置更改为“Standard Architectures(包括64位)”。 构建“通用库”目标并包含生成的静态库来代替Core Plot 1.4附带的静态库,或者使用依赖项目设置。

CorePlot发布了1.5.1以与Xcode 5.1一起使用。 您只需将CorePlotHeaders文件夹和libCorePlot-CocoaTouch.a文件复制到项目中。

你可以从这里下载。

尝试:

 lipo -info libCorePlot-CocoaTouch.a 

它显示该库是为armv7,armv7s和i386(32位模拟器)而构建的,并且不包括64位模拟器。 你必须为64位模拟器构建lib,然后你可以使用lipo将64位lib添加到libCorePlot-CocoaTouch.a。

输出:

 Architectures in the fat file: libCorePlot-CocoaTouch.a are: armv7 armv7s i386 

PS:它也无法在iPhone 5S上运行(没有arm64)。

编辑:

以下是为了生成包含arm64和x86_64体系结构的二进制文件而需要执行的步骤:

  1. 从https://code.google.com/p/core-plot/downloads/detail?name=CorePlot_1.4.zip&can=2&q=下载CorePlot_1.4
  2. 打开位于CorePlot_1.4 / Source / framework中的Xcode项目(CorePlot-CocoaTouch.xcodeproj)
  3. 选择“架构”的“标准架构”和“基础SDK”的“最新iOS(iOS 7)”
  4. 建立图书馆(CMD + B)
  5. 转到终端中的CorePlot_1.4 / Source / build /
  6. 运行lipo -create ./Debug-iphoneos/libCorePlot-CocoaTouch.a ./Debug-iphonesimulator/libCorePlot-CocoaTouch.a -output core_plot_all.a
  7. 将新创建的lib(core_plot_all.a)添加到项目中
  8. 你准备好了

更改Xcode架构的设置

在此处输入图像描述

如果您不想完成下载和构建项目的过程,我构建了通用库(用于armv7,armv7s和arm64) 并将其放在此处 。

这是根据coreplot commit id cc0a18cef8915f4a11e0699e9429c0a2f0018b42构建的。

我在 iOS SDK 9.2中使用Xcode 7.2.1中的官方文档“ 在应用程序中使用核心图 ”。 即使.a支持arm64,我也得到了同样的错误,直到我添加了’-OjbC’之外的链接器标志’-lCorePlot-CocoaTouch’。

如果您尝试了以上所有但仍无效,请尝试将“-ObjC -lCorePlot-CocoaTouch”设置为“Build Settings”中的“Other Linker Flags”或项目目标。

最简单的解决方案适合我:转到您的项目>构建设置>架构。 将架构更改为armv7并删除其他类似armv6等,如下图所示: –

需要更改

我在Xcode7.3 + CocoaPod上遇到了同样的错误。 我用Other Linker Flags = $(inheritance)修复了这个问题。

当然,此设置仅对CocoaPod有效。