OBJC_CLASS _ $ _ MTSCRA",引用自

Gau*_*arg 3 iphone api ios

我试图通过链接下载示例代码

http://www.magtek.com/support/software/downloads/sw/99510108.zip

这是一个读卡器api,这是一个示例代码.当我运行此代码时,我收到错误:

ld: warning: ignoring file /Users/gaurav.garg/Downloads/99510108/SampleCode/Lib/libMTSCRA.a, missing required architecture i386 in file
Undefined symbols for architecture i386:
  "_OBJC_CLASS_$_MTSCRA", referenced from:
      objc-class-ref in MagTekDemoAppDelegate.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

MTSCRA类只是一个头文件,而且我已解决的解决方案我们必须在目标的构建构建阶段的编译源路径中添加.m文件...但不幸的是我没有MTSCRA.m文件.MTscra.h具有AudioToolBox和externalAccesory框架.

小智 8

实际上问题是MagTek为您提供了两个单独的.a文件.

如果您查看Release-iphoneos中的那个并运行以下命令:

> lipo -info libMTSCRA.a 
Architectures in the fat file: libMTSCRA.a are: armv7 (cputype (12) cpusubtype (11))
Run Code Online (Sandbox Code Playgroud)

同样,如果你看一下Release-iphonesimulator中的那个......

> lipo -info libMTSCRA.a 
input file libMTSCRA.a is not a fat file
Non-fat file: libMTSCRA.a is architecture: i386
Run Code Online (Sandbox Code Playgroud)

因此,真正的答案是通过将两个使用lib工具组合,然后创建单独的DEBUG和RELEASE库搜索路径,为DEBUG创建一个新的libMTSCRA.a,它是n路FAT.

首先,您将转到MagTek保存两个不同版本的libMTSCRA.a的上面的目录.当您在那里时,您将运行以下命令:

libtool -static -o libMTSCRA_FAT.a Release-iphoneos/libMTSCRA.a Release-iphonesimulator/libMTSCRA.a 
Run Code Online (Sandbox Code Playgroud)

检查输出文件时,您应该看到:

>lipo -info libMTSCRA_FAT.a 
Architectures in the fat file: libMTSCRA.a are: armv7 (cputype (12) cpusubtype (11)) i386 
Run Code Online (Sandbox Code Playgroud)

然后在您的项目中,创建两个文件夹(也称为组)"debug"和"release",然后重新构建DEBUG和RELEASE库搜索路径以使用这些相应的目录.

最后,将libMTSCRA_FAT.a重命名为libMTSCRA.a并将其置于调试搜索路径中,使iOS(armv7(cputype(12)cpusubtype(11)))处于释放状态.我们这样做的原因是因为虽然在调试模式下使用这个新创建的.a文件可能没问题但是将它推入生产中是不好的,因为我们无法确认合并的lib是100%我们想要的(拱门的合并).

Etvoilà!