TextCleaner is a macOS application that utilizes the imgclean CLI tool to enhance scanned images by turning noisy, colored scans into clean, black-and-white images. It is particularly useful for preparing documents for Optical Character Recognition (OCR) or for improving the readability of scanned text.
I have started this project as a learning exercise to familiarize myself with macOS application development using XCode and Swift. The idea is simple: provide a GUI wrapper around the imgclean CLI tool to make it accessible to users who may not be comfortable using command-line tools. Unfortunately, I do not have an Apple Developer license, so I cannot distribute a signed version of this application. This means that for now, you will have to build the application yourself if you wish to use it.
Furthermore, Apple's notarization requirements have made packaging this app even more challenging. imgclean relies on several third-party libraries, which means that they need to be included with the application bundle as well. However, these libraries must be properly signed by the same developer ID as the main application to satisfy Apple's security checks. Since the libraries are neither built nor signed by me, I cannot include them as-is. Therefore, a re-signing step is necessary, but the script collect_dylibs.sh provided in this repository automates this process for you.
- Pray that everything will work as intended and that Apple's shenanigans won't get in your way.
- Clone the project to your machine.
imgcleanis a git submodule and should be automatically cloned when you clone the repository.- If not, run
git submodule update --init --recursive
- Using the terminal, navigate to
TextCleaner/imgclean/projectand build imgclean by following the instructions in theimgcleanREADME. I recommend using the config flags-DCMAKE_BUILD_TYPE=Release -DMEASURE_PERFORMANCE=OFFfor this project. - Collect all dylibs that imgclean needs by invoking the
collect_dylibs.shscript in the root folder of this project:The resulting dylibs will be placed in the./collect_dylibs.shimgclean-frameworksfolder. - Open the project in XCode.
- In this step, you need to ensure that all the dylibs collected in step 3 are included in the application bundle:
- Go to the
Build Phasestab of the TextCleaner target. - Look for a
Copy Filesphase with the destination set toFrameworks.- If it does not exist, create one by clicking the
+button and selectingNew Copy Files Phase, then set the destination toFrameworks. - If it exists, make sure to remove any old dylibs that may be there from previous builds.
- If it does not exist, create one by clicking the
- Add all the dylibs in the
imgclean-frameworksfolder to this phase. Make sure to selectCreate folder referenceswhen adding them and ensure thatCode Sign on Copyis checked for each dylib.
- Go to the
- Now, the
imgcleanbinary needs to be included in the application bundle as well:- Still in the
Build Phasestab, look for anotherCopy Filesphase with the destination set toExecutables.- If it does not exist, create one by clicking the
+button and selectingNew Copy Files Phase, then set the destination toExecutables. - If it exists, make sure to remove any old
imgcleanbinaries that may be there from previous builds.
- If it does not exist, create one by clicking the
- Add the
imgcleanbinary (located inTextCleaner/imgclean/project/build/) to this phase. Ensure thatCode Sign on Copyis checked.
- Still in the
- You should now be able to build and run the application from XCode. Have fun!
