i have successfully compiled static library and added it to the XCode project just like it's written in documentation:
- libclang.a file is in project directory (added file copy and group)
- libclang.a is listed in "Frameworks"
- i've added '-Objc' linker flag to 'Other linker flags'.
- libclang.a is listed in "Copy bundle resources"
libclang.a is compiled for ios simulator:
MBA-Anton:llvm_34_build_i386 asmirnov$ lipo -info ../llvm_34_ios_i386_installed/lib/libclang.a
input file ../llvm_34_ios_i386_installed/lib/libclang.a is not a fat file
Non-fat file: ../llvm_34_ios_i386_installed/lib/libclang.a is architecture: i386
I'm able to build the project but i'm getting error while ios simulator starts the app:
dyld: Library not loaded: @rpath/libclang.dylib
Referenced from: /Users/asmirnov/Library/Application Support/iPhone Simulator/7.1/Applications/D87A3FA9-7207-40B4-9EA0-5F06CEF6EF7B/StaticLibraryUsage.app/StaticLibraryUsage
Reason: image not found
I have found similar questions but it seems i did everything what was recommended. Any thoughts?
PS. I have libclang.dylib file but i'm not sure it's really needed since i have added libclang.a file in the project.
PPS. I have compiled armv7 version of libclang.a and created fat library with both i386 and armv7 using lipo
. After removing i386 version of libclang.a and adding fat version of libclang.a i have multiple unresolved references for i386 arch build errors.
PPPS. I have resolved "unresolved references" errors by adding all libLLVM*.a files in the project. but now i'm having original "dyld: Library not loaded".
PPPPS: .m compile command-line:
CompileC /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/Objects-normal/i386/ASAppDelegate.o StaticLibraryUsage2/ASAppDelegate.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
cd /Users/asmirnov/Documents/dev/src/iOS_Projects/StaticLibraryUsage2
export LANG=en_US.US-ASCII
export 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 -x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=/Users/asmirnov/Library/Developer/Xcode/DerivedData/ModuleCache -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclared-selector -Wno-deprecated-implementations -DDEBUG=1 -DDEBUG=1 -D__STDC_LIMIT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_CONSTANT_MACROS -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -fexceptions -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -Wno-sign-conversion -fobjc-abi-version=2 -fobjc-legacy-dispatch -mios-simulator-version-min=7.1 -iquote /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/StaticLibraryUsage2-generated-files.hmap -I/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/StaticLibraryUsage2-own-target-headers.hmap -I/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/StaticLibraryUsage2-all-target-headers.hmap -iquote /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/StaticLibraryUsage2-project-headers.hmap -I/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator/include -I/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/DerivedSources/i386 -I/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/DerivedSources -F/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator -include /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/PrecompiledHeaders/StaticLibraryUsage2-Prefix-baynabgphydhcmapwpcclpqhagrv/StaticLibraryUsage2-Prefix.pch -MMD -MT dependencies -MF /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/Objects-normal/i386/ASAppDelegate.d --serialize-diagnostics /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/Objects-normal/i386/ASAppDelegate.dia -c /Users/asmirnov/Documents/dev/src/iOS_Projects/StaticLibraryUsage2/StaticLibraryUsage2/ASAppDelegate.m -o /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/Objects-normal/i386/ASAppDelegate.o
link command-line:
Ld /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator/StaticLibraryUsage2.app/StaticLibraryUsage2 normal i386
cd /Users/asmirnov/Documents/dev/src/iOS_Projects/StaticLibraryUsage2
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export 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/iPhoneSimulator7.1.sdk -L/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator -L/Users/asmirnov/Documents/dev/src/llvm_34_ios_fat_installed -L/Users/asmirnov/Documents/dev/src/iOS_Projects/StaticLibraryUsage2/StaticLibraryUsage2 -L/Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_2/lib -F/Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator -filelist /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/Objects-normal/i386/StaticLibraryUsage2.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -ObjC -lstdc++ -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.1 -lLLVMRuntimeDyld -lLLVMSystemZAsmParser -lLLVMAArch64CodeGen -lLLVMTarget -lLLVMMCJIT -lLLVMX86Disassembler -lLLVMExecutionEngine -lLLVMPowerPCInfo -lLLVMHexagonAsmPrinter -lLLVMX86Utils -lLLVMPowerPCAsmParser -lclangDriver -lLLVMARMInfo -lLLVMAArch64AsmParser -lLLVMHexagonDesc -lLLVMipa -lclangARCMigrate -lLLVMMipsDesc -lLLVMNVPTXCodeGen -lLLVMBitWriter -lLLVMXCoreDisassembler -lLLVMNVPTXDesc -lLLVMX86CodeGen -lLLVMHexagonInfo -lLLVMSystemZAsmPrinter -lLLVMTableGen -lLLVMSystemZCodeGen -lLLVMInstrumentation -lLLVMAArch64Disassembler -lLLVMX86AsmPrinter -lLLVMCppBackendInfo -lclangBasic -lLLVMCodeGen -lLLVMDebugInfo -lLLVMAArch64Utils -lLLVMNVPTXAsmPrinter -framework CoreGraphics -lLLVMAsmParser -lLLVMSparcCodeGen -lclangFormat -lLLVMXCoreDesc -lLLVMipo -lLLVMObject -lclang -lLLVMX86Desc -lLLVMPowerPCDesc -lLLVMXCoreCodeGen -lLLVMVectorize -lclangAST -lclangSema -lclangTooling -lLLVMIRReader -lLLVMMipsCodeGen -lclangRewriteCore -lLLVMXCoreAsmPrinter -lLLVMMSP430Desc -lLLVMInstCombine -lLLVMAArch64AsmPrinter -lLLVMMCParser -lLLVMR600Info -lLLVMMipsAsmPrinter -lLLVMMipsAsmParser -lLLVMMCDisassembler -lLLVMBitReader -lclangAnalysis -lclangStaticAnalyzerCore -lLLVMMipsDisassembler -lLLVMR600AsmPrinter -lLLVMR600CodeGen -lLLVMAArch64Info -lclangDynamicASTMatchers -lLLVMARMAsmPrinter -lLLVMXCoreInfo -lclangStaticAnalyzerFrontend -lLLVMMipsInfo -lLLVMSelectionDAG -lLLVMTransformUtils -lLLVMSparcInfo -lLLVMR600Desc -lLLVMOption -lLLVMAArch64Desc -lLLVMObjCARCOpts -lLLVMJIT -lclangEdit -lLLVMSystemZDesc -lLLVMARMDesc -lLLVMSparcDesc -lLLVMMC -lLLVMMSP430CodeGen -lLTO -lLLVMHexagonCodeGen -lLLVMMSP430AsmPrinter -framework UIKit -lLLVMAnalysis -lLLVMMSP430Info -lLLVMARMCodeGen -lLLVMARMAsmParser -lclangCodeGen -lLLVMLinker -lLLVMPowerPCCodeGen -lLLVMAsmPrinter -lLLVMX86AsmParser -lLLVMSystemZInfo -framework Foundation -lclangASTMatchers -lLLVMScalarOpts -lLLVMPowerPCAsmPrinter -lLLVMARMDisassembler -lLLVMNVPTXInfo -lclangParse -lclangIndex -lclangStaticAnalyzerCheckers -lclangRewriteFrontend -lLLVMInterpreter -lclangLex -lLLVMCppBackendCodeGen -lLLVMX86Info -lLLVMCore -lLLVMLTO -lclangFrontend -lclangFrontendTool -lLLVMSupport -lLLVMSystemZDisassembler -lclangSerialization -Xlinker -dependency_info -Xlinker /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Intermediates/StaticLibraryUsage2.build/Debug-iphonesimulator/StaticLibraryUsage2.build/Objects-normal/i386/StaticLibraryUsage2_dependency_info.dat -o /Users/asmirnov/Library/Developer/Xcode/DerivedData/TestProject-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator/StaticLibraryUsage2.app/StaticLibraryUsage2
libclang.a adding to executable command-line:
CpResource /Users/asmirnov/Documents/dev/src/llvm_34_ios_i386_installed_2/lib/libclang.a /Users/asmirnov/Library/Developer/Xcode/DerivedData/PocketIDE-axtxqjlvmrcxqsfnvgobybceosvb/Build/Products/Debug-iphonesimulator/StaticLibraryUsage2.app/libclang.a
cd /Users/asmirnov/Documents/dev/src/iOS_Projects/StaticLibraryUsage2
export 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"
builtin-copy -exclude .DS_Store -exclude CVS -exclude .svn -excl