gali8 / Tesseract-OCR-iOS

Tesseract OCR iOS is a Framework for iOS7+, compiled also for armv7s and arm64.
http://www.nexor.it
MIT License
4.21k stars 948 forks source link

Non-Cocoapods Installation #340

Open kevinmlong opened 7 years ago

kevinmlong commented 7 years ago

I'm having some trouble with getting Tesseract appropriately working sans cocoa pods.

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

screen shot 2017-08-30 at 12 28 18 pm

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!

klongmitre commented 6 years ago

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

klongmitre commented 6 years ago

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.

joel-yc commented 6 years ago

@klongmitre you are a lifesaver!!

eugeniobaglieri commented 6 years ago

This helped me a lot!

eugeniobaglieri commented 6 years ago

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