Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

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

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

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

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

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!

like image 710
dacoinminster Avatar asked Oct 30 '13 21:10

dacoinminster


2 Answers

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

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

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.

like image 145
Petesh Avatar answered Oct 21 '22 11:10

Petesh


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

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.

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

Hope my solution could be helpful to you.

like image 28
jingxw Avatar answered Oct 21 '22 11:10

jingxw