xcode XCode5 模拟器:-Xlinker 中的未知选项字符“X”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19693769/
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 04:14:02  来源:igfitidea点击:

XCode5 simulator: unknown option character `X' in: -Xlinker

iosiphoneobjective-cxcodexcode5

提问by dacoinminster

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).

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

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

当我尝试编译时,我收到一个“Apple Mach-O 图书馆员错误”,它给了我以下文字墙:

Libtool build/DevOnly-iphonesimulator/libCozi\ Common\ Code.a normal i386 cd /Users/jr/ios/app/iCozi setenv IPHONEOS_DEPLOYMENT_TARGET 4.3 setenv PATH "/Applications/XCode5/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/XCode5/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/XCode5/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only i386 -syslibroot /Applications/XCode5/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/jr/ios/app/iCozi/build/DevOnly-iphonesimulator -L/Users/jr/ios/app/iCozi/../../ext/aiMatch/SASIA_iOS_SDK-iphonesimulator -L/Users/jr/ios/app/iCozi/../../ext/GoogleAdsSDK-iphone-v3.1/Library -L/Users/jr/ios/app/iCozi/../../ext/Google\ Analytics\ SDK/Library -L/Users/jr/ios/app/iCozi/../../ext/AdMarvel_iOS_SDK_2_9_1/AdMarvelSDK -L/Users/jr/ios/app/iCozi/../../ext/libComScore-1.1107.12 -L/Users/jr/ios/app/iCozi/../../ext/TestFlightSDK -L/Users/jr/ios/app/iCozi/../../ext/mBlox-SDK/Debug-universal -L/Users/jr/ios/app/iCozi/../../ext/mBlox-SDK/Release-universal -L/Users/jr/ios/app/iCozi/../../ext/FacebookSDK/FacebookSDK.framework/Versions/A -L/Users/jr/ios/app/iCozi/../../ext/GoogleConversionTrackingSDK -L/Users/jr/ios/app/iCozi/../../ext/TapjoyAdvertiserSDK/TapjoyAdvertiserLibrary -L/Users/jr/ios/app/iCozi/../../ext/MobileAppTracker.framework/Versions/A -filelist /Users/jr/ios/app/iCozi/build/iCozi.build/DevOnly-iphonesimulator/Cozi\ Common\ Code.build/Objects-normal/i386/Cozi\ Common\ Code.LinkFileList -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 -framework MobileAppTracker /Applications/XCode5/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libz.dylib -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -framework Security -framework MobileCoreServices -framework CFNetwork -framework SystemConfiguration -weak_framework MessageUI -framework QuartzCore /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20.a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20UI.a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20UINavigator.a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20UICommon.a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20Style.a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20Network.a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20Core.a -framework CoreLocation -weak_framework MediaPlayer -weak_framework iAd -framework AVFoundation -framework AudioToolbox -lGoogleAnalytics /Applications/XCode5/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libsqlite3.0.dylib -weak_framework EventKit -weak_framework EventKitUI -lTestFlight -framework comScore -framework MDS-SDK-PhoneGap -lMDSCore -framework FacebookSDK -lGoogleConversionTracking /Users/jr/ios/ext/TapjoyAdvertiserSDK/TapjoyAdvertiserLibrary/TapjoyAdvertiserLibrary.a /Users/jr/ios/ext/FacebookSDK/FacebookSDK.framework/Versions/A/FacebookSDK /Users/jr/ios/ext/MobileAppTracker.framework/Versions/A/MobileAppTracker -o /Users/jr/ios/app/iCozi/build/DevOnly-iphonesimulator/libCozi\ Common\ Code.a

/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

Libtool build/DevOnly-iphonesimulator/libCozi\Common\Code.a 普通 i386 cd /Users/jr/ios/app/iCozi setenv IPHONEOS_DEPLOYMENT_TARGET 4.3 setenv PATH "/Applications/XCode5/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator. platform/Developer/usr/bin:/Applications/XCode5/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/XCode5/Xcode.app/目录/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only i386 -syslibroot /Applications/XCode5/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk -L/Users/jr/ios/app/iCozi/build/DevOnly-iphonesimulator -L/Users/jr/ios/app/iCozi/../../ext/aiMatch/SASIA_iOS_SDK-iphonesimulator -L/Users/jr /ios/app/iCozi/../../ext/GoogleAdsSDK-iphone-v3.1/Library -L/Users/jr/ios/app/iCozi/../../ext/Google\ Analytics\ SDK/Library -L/Users/jr/ios/app/iCozi/../../ ext/AdMarvel_iOS_SDK_2_9_1/AdMarvelSDK -L/Users/jr/ios/app/iCozi/../../ext/libComScore-1.1107.12 -L/Users/jr/ios/app/iCozi/../../ ext/TestFlightSDK -L/Users/jr/ios/app/iCozi/../../ext/mBlox-SDK/Debug-universal -L/Users/jr/ios/app/iCozi/../../ ext/mBlox-SDK/Release-universal -L/Users/jr/ios/app/iCozi/../../ext/FacebookSDK/FacebookSDK.framework/Versions/A -L/Users/jr/ios/app/ iCozi/../../ext/GoogleConversionTrackingSDK -L/Users/jr/ios/app/iCozi/../../ext/TapjoyAdvertiserSDK/TapjoyAdvertiserLibrary -L/Users/jr/ios/app/iCozi/.. /../ext/MobileAppTracker.framework/Versions/A -filelist /Users/jr/ios/app/iCozi/build/iCozi.build/DevOnly-iphonesimulator/Cozi\Common\Code.build/Objects-normal/i386/ Cozi\通用\代码。LinkFileList -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 -framework MobileAppTracker /Applications/XCode5/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/usr/lib/libz.dylib -framework Foundation -framework UIKit -framework CoreGraphics -framework QuartzCore -framework Security -framework MobileCoreServices -framework CFNetwork -framework SystemConfiguration -weak_framework MessageUI -framework QuartzCore /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20.a /Users/jr/ios /ext/three20/Build/Products/Release-iphonesimulator/libThree20UI。a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20UINavigator.a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20UICommon.a /Users/jr/ ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20Style.a /Users/jr/ios/ext/three20/Build/Products/Release-iphonesimulator/libThree20Network.a /Users/jr/ios/ext/three20/ Build/Products/Release-iphonesimulator/libThree20Core.a -framework CoreLocation -weak_framework MediaPlayer -weak_framework iAd -framework AVFoundation -framework AudioToolbox -lGoogleAnalytics /Applications/XCode5/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs /iPhoneSimulator7.0.sdk/usr/lib/libsqlite3.0。dylib -weak_framework EventKit -weak_framework EventKitUI -lTestFlight -framework comScore -framework MDS-SDK-PhoneGap -lMDSCore -framework FacebookSDK -lGoogleConversionTracking /Users/jr/ios/ext/TapjoyAdvertiserSDK/TapjoyAdvertiserLibrary/TapjoysAdvertiserLibrary/Tapjoyr /FacebookSDK/FacebookSDK.framework/Versions/A/FacebookSDK /Users/jr/ios/ext/MobileAppTracker.framework/Versions/A/MobileAppTracker -o /Users/jr/ios/app/iCozi/build/DevOnly-iphonesimulator/libCozi \通用\代码.aframework/Versions/A/MobileAppTracker -o /Users/jr/ios/app/iCozi/build/DevOnly-iphonesimulator/libCozi\Common\Code.aframework/Versions/A/MobileAppTracker -o /Users/jr/ios/app/iCozi/build/DevOnly-iphonesimulator/libCozi\Common\Code.a

/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/X Command- /Xcode.app/Contents/Developer/Toolchains/XcodeDefault。xctoolchain/usr/bin/libtool 失败,退出代码为 1

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 中的未知选项字符‘X’”,但 Google 对该错误没有提供太多帮助:https: //www.google.com/search?q =%22% 60X%27+in%3A+Xlinker%22

"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 . . . ")

“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 ...")

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

只是为了咧嘴笑,我尝试从“Cozi Common Code”目标名称中删除空格,但这没有帮助。

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).

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

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

我真的很感激任何能帮我弄明白这件事的人。谢谢!

回答by Petesh

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

为了了解错误,您必须了解该命令试图执行的操作。

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 -ooption, 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.

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

Because you're making a static library archive, the only thing you're actually doing is taking .ofiles and possibly .afiles and turning them into another .afile. This can be roughly equated to the creating of a .zipfile from a set of files (.o), and the contents of other .zipfiles (.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.

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

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:

libtool 正在抱怨,因为它不理解用于传递的静态库的选项。在这种情况下,选项是:

-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

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.

这些是您尝试在权利文件中链接时出现的选项,这意味着某些选项指定了权利文件的使用。在这种情况下,您自己找到了正确的解决方案,即删除project settings-> Code Signing-> Code Signing Entitlements-> 中指定的权利文件DevOnly

回答by Iryna Tsimokhautsava

First check the scheme that you build for Debug (Product -> Scheme -> Manage schemes then select target and press Edit) Go to the Build Settings (both in project and target), find Code signing and change to Automatic in Debug in Provisioning Profile and Don't code sign in Debug in Code Signing Identity. It helped me, hope it will help someone else too)

首先检查您为调试构建的方案(产品-> 方案-> 管理方案,然后选择目标并按编辑)转到构建设置(在项目和目标中),找到代码签名并在配置文件中的调试中更改为自动并且不要在代码签名标识中进行代码登录调试。它帮助了我,希望它也能帮助其他人)

回答by jingxw

I met the same problem, and my approach to solve is to erase the unsupported option "-Xliner" in the command line of libtool (Actually i think this option should be supported by libtool, as is documented in the manual of libtool in gnu. Might be xcode disable it in libtool?)

我遇到了同样的问题,我的解决方法是删除 libtool 命令行中不受支持的选项“-Xliner”(实际上我认为 libtool 应该支持此选项,如 gnu 中的 libtool 手册中所述。可能是 xcode 在 libtool 中禁用了它?)

To erase this option, i first try to find out which setting generate it. In my side, it's code signing. I built the project with code signing "iOS Distribution" while an identity correspond to this signing is also exist in keychain. This will result in the build tool read this identity and try to do something like generate extra link option for libtool.

要删除此选项,我首先尝试找出生成它的设置。在我这边,它是代码签名。我使用代码签名“iOS Distribution”构建了项目,而与此签名对应的身份也存在于钥匙串中。这将导致构建工具读取此标识并尝试执行诸如为 libtool 生成额外链接选项之类的操作。

To dismiss it, I change the signing to "iOS Developer". And i think a remove of correspond identity also works.

要关闭它,我将签名更改为“iOS 开发人员”。而且我认为删除相应的身份也有效。

Hope my solution could be helpful to you.

希望我的解决方案对您有所帮助。

回答by MCMatan

This is notthe ultimate solution, But in my case, This accord because I was trying to use "ReactiveCocoa" with this pod:

不是最终的解决方案,但在我的情况下,这个协议是因为我试图在这个 pod 中使用“ReactiveCocoa”:

pod 'ReactiveCocoa', '3.0.0-alpha.1'

pod 'ReactiveCocoa', '3.0.0-alpha.1'

And it automatically installed "LlamaKit", witch you don't necessarily need when using ReactiveCocoa...

它会自动安装“LlamaKit”,在使用 ReactiveCocoa 时你不一定需要......

So first I removed the podfile, run "pod install". Then deleted the "Podfile.lock" file (At the same folder as your project).

所以首先我删除了 podfile,运行“pod install”。然后删除“Podfile.lock”文件(与您的项目位于同一文件夹中)。

Then used this pod:

然后使用了这个 pod:

pod 'ReactiveCocoa'

豆荚“反应可可”

and run "pod install" once again. clean project, run, and good luck.

并再次运行“pod install”。清理项目,运行,祝你好运。

回答by UKDataGeek

I had a file with a "+" in the file name in my pods folder for some reason. Deleted it and it worked great

由于某种原因,我的 pods 文件夹中有一个文件名中带有“+”的文件。删除了它,效果很好

回答by thundertrick

I also met the Apple Mach-O Librarian Error. But after checking my build settings, I found Code Signing entitlementof both myProjectand Podswere empty.

我也遇到过Apple Mach-O Librarian Error。但是,检查我的构建设置后,我发现Code Signing entitlement两者的myProject的都是空的。

As it might be a problem of static library, I just changed the Mach-O typesetting of Pods-myExtensionfrom static libraryto Dynamic libraryand found it worked!

由于可能是静态库的问题,我只是将Pods-myExtensionMach-O type设置从更改为并发现它有效!static libraryDynamic library

Mach-O typecan be found in Pods-myExtension-> Build settings -> Linking.

Mach-O type可以在Pods-myExtension-> Build settings -> Linking 中找到。

Hope it helps:)

希望能帮助到你:)

回答by Oscar Hierro

FWIW, this exact error can also occur on Xcode 7.3.1 if the "Code Signing Entitlements" build setting has been mistakenly set for an static library build target, where it doesn't really apply.

FWIW,如果错误地为静态库构建目标设置了“代码签名权利”构建设置,则在 Xcode 7.3.1 上也可能发生此确切错误,而它实际上并不适用。

回答by Ashok

My first quick take on this error is that it's a falsealarm. If I were you, I would do some troubleshooting accordingly and clean up Xcode, project and simulator settings etc.

我对这个错误的第一反应是,这是一个误报。如果我是你,我会相应地进行一些故障排除并清理 Xcode、项目和模拟器设置等。

Try deleting Xcode's preferences file (from common and user library both) and restart Xcode -

尝试删除 Xcode 的首选项文件(从公共库和用户库中)并重新启动 Xcode -

/Library/Preferences

/图书馆/首选项

com.apple.dt.Xcode

com.apple.dt.Xcode

/Users/YourUsername/Library/Preferences ( I have following 3 files related to Xcode there )

/Users/ YourUsername/Library/Preferences(我有以下 3 个与 Xcode 相关的文件)

com.apple.dt.Xcode.plist

com.apple.dt.Xcode.plist

com.apple.dt.Xcode.LSSharedFileList.plist

com.apple.dt.Xcode.LSSharedFileList.plist

com.apple.dt.Xcode.plist.BoGEJ0T

com.apple.dt.Xcode.plist.BoGEJ0T

Alternatively- try building the project on some other machine (or switch to some other user on same machine).

Alternatively- 尝试在其他机器上构建项目(或切换到同一台机器上的其他用户)。

回答by RB Chauhan

To fix this issue , kindly change the schema to debug in simulator, this is because you have selected to release.

要解决此问题,请更改架构以在模拟器中调试,这是因为您已选择发布。