本文介绍了XCode5模拟器:-Xlinker中的未知选项字符“X”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前被链接器错误阻止,该错误仅在XCode5上发生(XCode4编译正常)并且仅在模拟器上发生(正常设备编译正常)。

I am currently blocked by a linker error which happens ONLY on XCode5 (XCode4 compiles fine) and ONLY on the simulator (normal devices compile fine).

当我尝试编译时,我得到一个Apple Mach-O Librarian Error,它给出了以下文本墙:

When I try to compile, I get a "Apple Mach-O Librarian Error" which gives me the following wall of text:

/Applications/XCode5/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr / bin / libtool:
未知选项字符`X': - Xlinker用法:
/Applications/XCode5/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
-static [ - ] file [...] [-filelist listfile [,dirname]] [-arch_only arch] [-sacLT]用法:
/Applications/XCode5/Xcode.app/Contents/Developer /Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool
-dynamic [ - ] file [...] [-filelist listfile [,dirname]] [-arch_only arch] [-o output] [-install_name name ] [-compatibility_version#]
[-current_version#] [-seg1addr 0x#] [-segs_read_only_addr 0x#]
[-segs_read_write_addr 0x#] [-seg_addr_table]
[-seg_addr_table_filename] [ -all_load]
[-noall_load]命令
/Applications/XCode5/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/l ibtool
因退出代码1而失败

/Applications/XCode5/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: unknown option character `X' in: -Xlinker Usage: /Applications/XCode5/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-sacLT] Usage: /Applications/XCode5/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -dynamic [-] file [...] [-filelist listfile[,dirname]] [-arch_only arch] [-o output] [-install_name name] [-compatibility_version #] [-current_version #] [-seg1addr 0x#] [-segs_read_only_addr 0x#] [-segs_read_write_addr 0x#] [-seg_addr_table ] [-seg_addr_table_filename ] [-all_load] [-noall_load] Command /Applications/XCode5/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool failed with exit code 1

问题的根源似乎是未知选项字符`X': -Xlinker,但Google对此错误没有太多帮助:

The root of the problem seems to be "unknown option character `X' in: -Xlinker", but Google doesn't give much help with that error: https://www.google.com/search?q=%22%60X%27+in%3A+Xlinker%22

XLinker 在上面的混乱中出现了四次(。 。 。 -all_load -ObjC -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/jr/ios/app/iCozi/build/iCozi.build/DevOnly-iphonesimulator/Cozi\ Common \ Code.build/Cozi\ Common \ Code.xcent。 。 。 )

"XLinker" appears four times in the mess above (" . . . -all_load -ObjC -Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/jr/ios/app/iCozi/build/iCozi.build/DevOnly-iphonesimulator/Cozi\ Common\ Code.build/Cozi\ Common\ Code.xcent . . . ")

为了笑容,我尝试从Cozi Common Code目标名称中删除空格,但这没有帮助。

Just for grins, I tried removing the spaces from the "Cozi Common Code" target name, but that didn't help.

同样,这在XCode4模拟器上编译得很好,它在XCode5中编译得很好,可以在物理设备上运行,包括iPod和iPad,但是XCode5中的每个模拟器都有这个问题(iPhone / iPod) / iPad,正常和视网膜,在iOS5 / iOS6 / iOS7上)。

Again, this compiles just fine on XCode4 simulator, and it compiles just fine in XCode5 for running on physical devices, including an iPod and an iPad, but every simulator in XCode5 has this problem (iPhone/iPod/iPad, both normal and retina, on iOS5/iOS6/iOS7).

我真的很感谢任何可以帮助我深究这一点的人。谢谢!

I'd REALLY appreciate anybody who can help me get to the bottom of this. Thanks!

推荐答案

为了理解错误,你必须了解命令试图做什么。

In order to understand the error, you have to understand what the command is attempting to do.

在这种情况下,它使用 Libtool ,这是 libtool 的略微修改版本。命令行中指定了一些选项,但我们要查找的是目标文件,这是作为 -o 选项传递的,谁是参数是 / Users / jr / ios / app / i Cozi / build / DevOnly-iphonesimulator / libCozi \ Common \ Code.a ,以及我们正在生成的库的类型,在这种情况下它是 -static 。两个选项一起明确声明您正在制作静态库存档。

In this case it's using Libtool, which is a slightly altered version of libtool. There are some options that are specified in the command line, but what we're looking for is the destination file, and this is passed in as the -o option, who's argument is /Users/jr/ios/app/iCozi/build/DevOnly-iphonesimulator/libCozi\ Common\ Code.a, and the type of library we're generating, and in this case it's -static. Both options together explicitly state that you're making a static library archive.

因为您正在制作静态库存档,所以您实际做的唯一事情就是采取 .o 文件以及可能的 .a 文件并将其转换为另一个 .a 档案。这可以大致等同于从一组文件( .o )创建 .zip 文件,以及其他 .zip 文件的内容( .a )。在进行此归档时,您可以执行的操作非常少,例如,您无法指定在构建静态归档时需要隐式链接的库,您无法指定您将需要权限。

Because you're making a static library archive, the only thing you're actually doing is taking .o files and possibly .a files and turning them into another .a file. This can be roughly equated to the creating of a .zip file from a set of files (.o), and the contents of other .zip files (.a). There are very few things you can do while making this archive, for example you can't specify libraries that need to be implicitly linked while building a static archive, you can't specify that you're going to require entitlements.

libtool正在抱怨,因为它不了解正在传入的静态库所使用的选项。在这种情况下,选项是:

libtool is complaining because it doesn't understand the options that are being used for a static library that are being passed in. In this case the options are:

-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __entitlements -Xlinker /Users/jr/ios/app/iCozi/build/iCozi.build/DevOnly-iphonesimulator/Cozi\ Common\ Code.build/Cozi\ Common\ Code.xcent

这些当您尝试在权利文件中链接时存在的选项,这意味着某些选项指定使用权利文件。在这种情况下,您自己找到了正确的解决方案,即删除项目设置中指定的权利文件 - > 代码签名 - > 代码签名权利 - > DevOnly

These are options that are present when you're trying to link in an entitlements file, which means that some options is specifying the use of an entitlements file. In this case, you found the correct solution yourself, which was to remove the entitlements file specified in the project settings -> Code Signing -> Code Signing Entitlements -> DevOnly.

这篇关于XCode5模拟器:-Xlinker中的未知选项字符“X”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 12:18