libtool failed with exit code 1 - ios

I attempt to Create a Xcode-WorkSpace,there are there projects in it. Now the first Project is a static library base on ZBar Code Reader.I already download the source code ,now I drag the finder named "src" into my first project. When I bulid it,here is the problem:
Libtool /Users/asset/Library/Developer/Xcode/DerivedData/huishow1-efdjffeirjufbndvocvtzkrzkwss/Build/Products/Debug-iphonesimulator/libZBarTest.a normal i386
cd /Users/asset/iPhone_Tmp/ZBarTest
setenv MACOSX_DEPLOYMENT_TARGET 10.6
setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool -static -arch_only i386 -syslibroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/asset/Library/Developer/Xcode/DerivedData/huishow1-efdjffeirjufbndvocvtzkrzkwss/Build/Products/Debug-iphonesimulator -L/Users/asset/iPhone_Tmp/ZBarTest/SDK -L/Users/asset/iPhone_Tmp/ZBarTest/SDK3 -filelist /Users/asset/Library/Developer/Xcode/DerivedData/huishow1-efdjffeirjufbndvocvtzkrzkwss/Build/Intermediates/ZBarTest.build/Debug-iphonesimulator/ZBarTest.build/Objects-normal/i386/ZBarTest.LinkFileList -lxml2 -ObjC -framework Foundation -lzbar -o /Users/asset/Library/Developer/Xcode/DerivedData/huishow1-efdjffeirjufbndvocvtzkrzkwss/Build/Products/Debug-iphonesimulator/libZBarTest.a
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/libtool failed with exit code 1
Who can help me?

Sounds like a missing dependency. I'm not familiar with the ZBar code reader but I'd imagine it declares dependencies on some system frameworks that you haven't yet included in your app? Look in the docs for ZBar to determine which frameworks you need to link to when including it. Typically when you get these types of libtool errors when you don't include a framework or other dependency.

Related

cocoapods setup issue: inker command failed with exit code 1

I'm trying to setup cocoapods with a project in order to use the STPrivilegedTask class and have been running into the following error:
Ld ProductBuilder.app/Contents/MacOS/ProductBuilder normal x86_64
cd /Users/zach/Dev/Code/ProductBuilder
export MACOSX_DEPLOYMENT_TARGET=10.7
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -L/Users/zach/Dev/Code/ProductBuilder -F/Users/zach/Dev/Code/ProductBuilder -filelist /Users/zach/Dev/Code/ProductBuilder/Build/Intermediates/ProductBuilder.build/Debug/ProductBuilder.build/Objects-normal/x86_64/ProductBuilder.LinkFileList -mmacosx-version-min=10.7 -ObjC -lSTPrivilegedTask -framework Security -fobjc-arc -fobjc-link-runtime -framework QuartzCore -framework OpenGL -framework Cocoa -lPods -Xlinker -dependency_info -Xlinker /Users/zach/Dev/Code/ProductBuilder/Build/Intermediates/ProductBuilder.build/Debug/ProductBuilder.build/Objects-normal/x86_64/ProductBuilder_dependency_info.dat -o /Users/zach/Dev/Code/ProductBuilder/ProductBuilder.app/Contents/MacOS/ProductBuilder
ld: library not found for -lSTPrivilegedTask
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I am able to use the STPrivilegedTask class in my code without any issues, it's just that I do not build - even without adding any STPrivilegedTask code, the app does not build.
Some other notes:
I am opening the project using the xcworkspace file.
STPrivilegedTask does show up in the Pods section in Xcode, and has it's source code there, so that seems OK. As I said, I can also reference this class in code, so I think it's grabbing the class correctly.
The app I am adding cocoapods to is relatively old, but has not used cocoapods before, so this is a fresh install.
I am using cocoapods version 0.39.0
Please let me know if you have any ideas!
Thank you,
Zach
This was fixed by changing my Per-configuration Build Products Path setting to:
$(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME).
I tested the STPrivilegedTask pod in a new project without any issues, so I figured it must be something with my project setup. The project is somewhat of a legacy app, and has gone through some odd phases/cycles, so I can't explain why the Build Products Path was set to anything but that (the expected/normal value I think...)
Anyways, it builds OK now - hopefully this helps someone else!

selective library linking Xcode 6 / LLVM 6

I selectively link a library depending on the configuration in my project build settings. i.e.
Debug: -l libcws_ps
Release: -l libcws
In library search paths, I point to the directory that contains these 2 .a libraries.
I'll point out that this worked on Xcode 5, but now on Xcode 6 it's not linking properly and I'm getting undefined symbol errors. If I link using the usual method - 'link binary with libraries', then it works - but then I don't have the configuration based linking.
Any ideas how to fix this, or at least some clues how I get debug it?
Libtool /Users/dave/Library/Developer/Xcode/DerivedData/FilmFlexMovies-ddwyjuvbhaqgqralpjczhprnltla/Build/Products/Release-iphoneos/libiOSIrdetoLibrary.a normal armv7
cd /Users/dave/Developer/GIT/FilmFlex/iOS/Submodules/iOSModelController/Submodules/iOSIrdetoLibrary
export IPHONEOS_DEPLOYMENT_TARGET=7.0
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only armv7 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk -L/Users/dave/Library/Developer/Xcode/DerivedData/FilmFlexMovies-ddwyjuvbhaqgqralpjczhprnltla/Build/Products/Release-iphoneos -LCloakwareStreaming/lib/ios -L/Users/dave/Developer/GIT/FilmFlex/iOS/Submodules/iOSModelController/Submodules/iOSIrdetoLibrary/CloakwareStreaming/lib/ios -filelist /Users/dave/Library/Developer/Xcode/DerivedData/FilmFlexMovies-ddwyjuvbhaqgqralpjczhprnltla/Build/Intermediates/iOSIrdetoLibrary.build/Release-iphoneos/iOSIrdetoLibrary.build/Objects-normal/armv7/iOSIrdetoLibrary.LinkFileList -framework MediaPlayer -framework CoreVideo -framework AVFoundation -framework UIKit -framework Foundation -o /Users/dave/Library/Developer/Xcode/DerivedData/FilmFlexMovies-ddwyjuvbhaqgqralpjczhprnltla/Build/Products/Release-iphoneos/libiOSIrdetoLibrary.a
RTFM... or RTFRN... Xcode 6 release notes
"Xcode will no longer pass options in the build setting OTHER_LDFLAGS to libtool when building static libraries, nor will it pass options in OTHER_LIBTOOLFLAGS to the Mach-O linker when building any other kind of product. Previously all options in both settings would be passed to both tools. Make sure that options are in the correct build setting for the product type, static library, or other component being built. (4285249)"
So it just wasn't even passing my 'other linker flags'. I needed to move them to 'other librarian flags'.

iOS Static library compilation error - table of contents is empty

I am trying to create a Objective C static library for iOS. When I try to compile it gives following warnings.
Libtool /Users/******/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Intermediates/MyLib.build/Debug-iphoneos/MyLib.build/Objects-normal/armv7/libMyLib.a normal armv7
cd /Users/******/Desktop/MyLib
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool -static -arch_only armv7 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -L/Users/******/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Products/Debug-iphoneos -filelist /Users/******/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Intermediates/MyLib.build/Debug-iphoneos/MyLib.build/Objects-normal/armv7/MyLib.LinkFileList -ObjC -framework Foundation -o /Users/shafraz/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Intermediates/MyLib.build/Debug-iphoneos/MyLib.build/Objects-normal/armv7/libMyLib.a
I am getting similar errors for armv7s, arm64 also
(null): /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/libtool: warning for library: /Users/******/Library/Developer/Xcode/DerivedData/MyLib-eyucoczochpovhcqduwoieknpyer/Build/Products/Debug-iphoneos/libMyLib.a for architecture: armv7 the table of contents is empty (no object file members in the library define global symbols)
I am getting similar errors for armv7s, arm64 also
This worming shown only after removing MyLib.m and class declaration in MyLib.h file.
How can I fix this?
This generally happens if your static library contains nothing but categories or informal protocols. The linker is warning you that you don't seem to have any classes to link.
In my case, I realized that the library I wrote ended up being a header only library. That implies I don't even need to compile a library, just include the headers in "Header Search Paths" in "Build settings".

j2objc as subproject in XCode

I have a problem to link the j2objc library as a subproject. It always ends up with "missing libjre_emul.a" error.
Steps I have done:
1) Create empty iOS project
2) Include j2objc library by following the simple steps in the part "Including JreEmulation project into your project.
I checked that I am building for the iPhone simulator and the build process is running. It seems that libjre_emul.a is generated at j2objc/jre_emul/build_result/ but it should be also available in the DerivedData, which is not. I have also tried setting a shared folder for DerivedData (File -> Project settings -> Derived Data -> Advanced), but this didn't help.
The reason why I would like to include it as a subproject is to be able to set breakpoints inside j2objc source.
Here is the error:
Ld /Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/SubProject4.app/SubProject4 normal i386
cd /Users/user/Documents/Project1/SubProject4
setenv IPHONEOS_DEPLOYMENT_TARGET 6.1
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk -L/Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -F/Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator -filelist /Users/user/Library/Developer/Xcode/DerivedData/Build/Intermediates/SubProject4.build/Debug-iphonesimulator/SubProject4.build/Objects-normal/i386/SubProject4.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=6.1 /Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/libjre_emul.a -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/SubProject4.app/SubProject4
clang: error: no such file or directory: '/Users/user/Library/Developer/Xcode/DerivedData/Build/Products/Debug-iphonesimulator/libjre_emul.a'
Tom Ball responded on the j2obj google group:
The problem looks to be that the JreEmulation project's makefile is not copying the built library to where Xcode expects it to be. Xcode used to pass build environment variables like BUILT_PRODUCTS_DIR to external build system targets, but doesn't any more. Here's a workaround until I figure out how to fix embedding JreEmulation properly (if anyone has a solution, please reply):
Remove the red libjre_emul.a from your project's Link Binary with Libraries list.
In that list, click the + button, then Add Other...
Go to your j2objc directory, then dist/lib and add libjre_emul.a
Now when you look at the link list, libjre_emul.a should be red after cleaning your project (since it was deleted), and black after your project builds successfully.
So it was a bug, but I still can't debug/step into the j2objc source code. But at least this is working.

Apple Mach-O Linker Error Xcode 4.5.2

I am thinking of rebuilding the project from scratch which I would like to avoid, so I am asking for help.
When trying to build the project on release I get the following link error:
Ld
/Users/MAS/Library/Developer/Xcode/DerivedData/MyStreamPlayer-auylvnjdlrkfpvaxnulcaadbfhwl/Build/Products/Release-iphoneos/MyStreamPlayer.app/MyStreamPlayer
normal armv7
cd /Users/MAS/iphoneApps/AlfsreamPlayer/MyStreamPlayer
setenv IPHONEOS_DEPLOYMENT_TARGET 6.0
setenv PATH "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk
-L/Users/MAS/Library/Developer/Xcode/DerivedData/MyStreamPlayer-auylvnjdlrkfpvaxnulcaadbfhwl/Build/Products/Release-iphoneos
-L/Users/MAS/iphoneApps/AlfsreamPlayer/MyStreamPlayer -L/Users/MAS/iphoneApps/AlfsreamPlayer/MyStreamPlayer/../build -F/Users/MAS/Library/Developer/Xcode/DerivedData/MyStreamPlayer-auylvnjdlrkfpvaxnulcaadbfhwl/Build/Products/Release-iphoneos
-filelist /Users/MAS/Library/Developer/Xcode/DerivedData/MyStreamPlayer-auylvnjdlrkfpvaxnulcaadbfhwl/Build/Intermediates/MyStreamPlayer.build/Release-iphoneos/MyStreamPlayer.build/Objects-normal/armv7/MyStreamPlayer.LinkFileList
-Xlinker -map -Xlinker /Users/MAS/Library/Developer/Xcode/DerivedData/MyStreamPlayer-auylvnjdlrkfpvaxnulcaadbfhwl/Build/Intermediates/MyStreamPlayer.build/Release-iphoneos/MyStreamPlayer.build/MyStreamPlayer-LinkMap-normal-armv7.txt -dead_strip -finalize -prefinalized-library libViewRightWebiOS.a -finalized-product /Users/MAS/Library/Developer/Xcode/DerivedData/MyStreamPlayer-auylvnjdlrkfpvaxnulcaadbfhwl/Build/Products/Release-iphoneos/MyStreamPlayer.app/MyStreamPlayer
-libVideoWebiOS -fobjc-link-runtime -miphoneos-version-min=6.0 -framework Foundation -framework UIKit -framework CoreGraphics -framework MediaPlayer -framework CFNetwork -libVideoWebiOS_debug -libVideoWebiOS -o /Users/MAS/Library/Developer/Xcode/DerivedData/MyStreamPlayer-auylvnjdlrkfpvaxnulcaadbfhwl/Build/Products/Release-iphoneos/MyStreamPlayer.app/MyStreamPlayer
clang: error: no such file or directory:
'/Users/MAS/Library/Developer/Xcode/DerivedData/MyStreamPlayer-auylvnjdlrkfpvaxnulcaadbfhwl/Build/Products/Release-iphoneos/MyStreamPlayer.app/MyStreamPlayer'
No problem with debug mode. The project runs fine on another computer on xcode 4.5.1. I thought the xcode version could be the problem but when I tried it on another computer with xcode 4.5.1 I got the same problem.
The project uses a library libVideoWebiOS. I have it on the Build Phases -> Link Binary With Libraries. Any idea what produce could this issue? Here is the screenshot of build settings -> architectures.
There are lot of suggestions to Change "Build Active Architecure Only" to Yes but unfortunately that didn't work for me.
From your comment, it seems you are having multiple targets in your project. If you are using any third party libraries or wrapper classes, don't import the project. Add only the required files and folders you want. I don't know how to make the project in release mode which having multiple targets. But making your project with one target might solve your problem. Remove the references of your third party project.xcodeproj and add the source files what are all you needed in that project. Hope it helps.
Ron is correct, you must use the Finalizer before you can create a release build. Be sure you have Xcode closed for the finalizer to work.

Resources