Tesseract-OCR-iOS
Tesseract-OCR-iOS copied to clipboard
Non-Cocoapods Installation
I'm having some trouble with getting Tesseract appropriately working sans cocoa pods.
- I cloned this repo and built the framework -- Set ENABLE_BITCODE to NO -- Set GENERATE_MASTER_OBJECT_FILE to YES
- I copied the framework into my project
- I added the following to my project Build Settings -- Added other linker flags (-lstdc++ and -lz) -- Set ENABLE_BITCODE to NO -- Set CLANG_CXX_LIBRARY to Compiler Default
The project works fine when I build and run on a real device. Building and running on a simulator device however results in a Linker Error
In the log it shows:
ld: warning: ignoring file <ProjectFolder>/TesseractOCR.framework/TesseractOCR, missing required architecture x86_64 in file <ProjectFolder>/TesseractOCR.framework/TesseractOCR (2 slices)
Undefined symbols for architecture x86_64:
"_OBJC_CLASS_$_G8Tesseract", referenced from:
objc-class-ref in ViewController.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Any guidance in resolving this would be greatly appreciated.
Thanks!
@gali8 @kevincon - still seeing this issue. Any advise you may have would be great! Also - any thoughts on making the framework available via providing the binary in the release for Carthage users?
For those who are interested I was able to figure out the following with some help from here https://dzone.com/articles/creating-a-universal-framework-in-xcode-9.
In a root directory create a script (e.g. create-tesseract-universal-framework.sh). The contents of the script is:
git clone https://github.com/gali8/Tesseract-OCR-iOS.git
rm -Rf Tesseract-OCR-iOS/build
xcodebuild archive -project Tesseract-OCR-iOS/Tesseract\ OCR\ iOS.xcodeproj -scheme TesseractOCR -sdk iphoneos SYMROOT=build
xcodebuild build -project Tesseract-OCR-iOS/Tesseract\ OCR\ iOS.xcodeproj -target TesseractOCR -sdk iphonesimulator SYMROOT=build
cp -RL Tesseract-OCR-iOS/build/Release-iphoneos Tesseract-OCR-iOS/build/Release-universal/
cp -RL Tesseract-OCR-iOS/build/Release-iphonesimulator Tesseract-OCR-iOS/build/Release-universal/
lipo -create Tesseract-OCR-iOS/build/Release-iphoneos/TesseractOCR.framework/TesseractOCR Tesseract-OCR-iOS/build/Release-iphonesimulator/TesseractOCR.framework/TesseractOCR -output Tesseract-OCR-iOS/build/Release-universal/TesseractOCR.framework/TesseractOCR
cp -r Tesseract-OCR-iOS/build/Release-universal/TesseractOCR.framework .
After running the script, there will be a TesseractOCR.framework in the directory. Drag this framework into your project. This will allow the project to compile for either a device or a simulator.
@klongmitre you are a lifesaver!!
This helped me a lot!
For those who are interested I was able to figure out the following with some help from here https://dzone.com/articles/creating-a-universal-framework-in-xcode-9.
In a root directory create a script (e.g. create-tesseract-universal-framework.sh). The contents of the script is:
git clone https://github.com/gali8/Tesseract-OCR-iOS.git rm -Rf Tesseract-OCR-iOS/build xcodebuild archive -project Tesseract-OCR-iOS/Tesseract\ OCR\ iOS.xcodeproj -scheme TesseractOCR -sdk iphoneos SYMROOT=build xcodebuild build -project Tesseract-OCR-iOS/Tesseract\ OCR\ iOS.xcodeproj -target TesseractOCR -sdk iphonesimulator SYMROOT=build cp -RL Tesseract-OCR-iOS/build/Release-iphoneos Tesseract-OCR-iOS/build/Release-universal/ cp -RL Tesseract-OCR-iOS/build/Release-iphonesimulator Tesseract-OCR-iOS/build/Release-universal/ lipo -create Tesseract-OCR-iOS/build/Release-iphoneos/TesseractOCR.framework/TesseractOCR Tesseract-OCR-iOS/build/Release-iphonesimulator/TesseractOCR.framework/TesseractOCR -output Tesseract-OCR-iOS/build/Release-universal/TesseractOCR.framework/TesseractOCR cp -r Tesseract-OCR-iOS/build/Release-universal/TesseractOCR.framework .
After running the script, there will be a TesseractOCR.framework in the directory. Drag this framework into your project. This will allow the project to compile for either a device or a simulator.
There is a way to build with "GENERATE_MASTER_OBJECT_FILE = YES" without setting the flag manually in Xcode, for example adding some options to build command in the script