Open cesss opened 1 year ago
I got it working in MacOS, by creating my own Makefile (for the MacOS example only, statically linking all the iosMath library inside the executable). I provide the Makefile here just in case anybody else needs to build the MacOS example in a simple way in recent MacOS versions. Just be sure to adjust the SDK_LOCATION variable to make it point to where your SDK resides:
# Adjust this variable to point to the location of the Mac OSX SDK */
SDK_LOCATION = /Users/cesss/mysdks/MacOSX10.12.sdk
# Compiler variables
CC = clang
CPPFLAGS = -IiosMath/ -IiosMath/lib/ -IiosMath/render/ -IiosMath/render/internal/
OBJCWARNINGS = -Wno-sign-compare -Wno-unused-parameter -Wno-deprecated-declarations -Wno-nullability-completeness
OBJCFLAGS = -Wall -Werror -Wextra $(OBJCWARNINGS) -g -DDEBUG -isysroot $(SDK_LOCATION) -mmacosx-version-min=10.12 -fmodules -fobjc-arc
LDFLAGS = -arch x86_64 -framework AppKit -framework Cocoa -framework CoreText -framework CoreGraphics -framework Foundation -DDEBUG
# Project variables
APP_NAME = iosMathDemo
APP_BUNDLE = $(APP_NAME).app
APP_RESOURCES = $(APP_BUNDLE)/Contents/Resources
APP_MACDIR = $(APP_BUNDLE)/Contents/MacOS
OBJC_FILES = iosMath/lib/MTMathAtomFactory.m \
iosMath/lib/MTMathList.m \
iosMath/lib/MTMathListBuilder.m \
iosMath/lib/MTMathListIndex.m \
iosMath/lib/MTUnicode.m \
iosMath/render/MTFont.m \
iosMath/render/MTFontManager.m \
iosMath/render/MTLabel.m \
iosMath/render/MTMathListDisplay.m \
iosMath/render/MTMathUILabel.m \
iosMath/render/NSBezierPath+addLineToPoint.m \
iosMath/render/NSColor+HexString.m \
iosMath/render/NSView+backgroundColor.m \
iosMath/render/UIColor+HexString.m \
iosMath/render/internal/MTFontMathTable.m \
iosMath/render/internal/MTTypesetter.m \
MacOSMathExample/AppDelegate.m \
MacOSMathExample/main.m
XIB_FILE = MacOSMathExample/Base.lproj/MainMenu.xib
NIB_FILE = MacOSMathExample/Base.lproj/MainMenu.nib
# Targets
all: $(APP_BUNDLE)
$(APP_BUNDLE): $(APP_NAME) $(NIB_FILE)
mkdir -p $(APP_RESOURCES)/Base.lproj
mkdir -p $(APP_RESOURCES)/mathFonts.bundle
mkdir -p $(APP_RESOURCES)
mkdir -p $(APP_MACDIR)
cp $(NIB_FILE) $(APP_RESOURCES)/Base.lproj
cp fonts/* $(APP_RESOURCES)/mathFonts.bundle
cp -R MathFontBundle/en.lproj $(APP_RESOURCES)
cp MacOSMathExample/Info.plist $(APP_BUNDLE)/Contents/
cp $(APP_NAME) $(APP_BUNDLE)/Contents/MacOS/$(APP_NAME)
open $(APP_BUNDLE)
$(APP_NAME).nib: $(XIB_FILE)
ibtool --compile $(NIB_FILE) $(XIB_FILE)
$(APP_NAME): $(OBJC_FILES) $(APP_NAME).nib
$(CC) $(OBJCFLAGS) $(CPPFLAGS) $(OBJC_FILES) $(LDFLAGS) -o $(APP_NAME)
clean:
rm -f $(APP_NAME) $(NIB_FILE)
rm -rf $(APP_BUNDLE)
Also, I edited the MacOSMathExample/Info.plist so that it's installed easily in the appbundle without the need of Xcode. My minimal version of it is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>iosMathDemo</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
With this, you should be able to get iosMath working in recent versions of MacOS, without having to install CocoaPods, and without having to fix the Xcode project, which doesn't seem to work in recent Xcode versions (at least for me).
I always build my Mac apps from the command-line with Makefiles, so I'm no expert with XCode at all. I assumed it was a matter of downloading, double clicking on the project for the MacOS build, and that it would work, but that's not the case at all: First it expects to find something called "pods" (after a search I suppose it's CocoaPods, and I'd prefer not to install that, so I deleted everything related to pods). Also, I had to increase the MacOS deploy version to 10.9, because my XCode version (14.x) doesn't support 10.8 anymore. Then, it didn't find some iosMath headers, which belong to the project. So I added all the project directories to the include paths. Then, I realized that the Project Navigator didn't show all the sources, but just a couple of them. So, I inserted all the files again in the project. Finally, I managed to get a successful build. The MacOS demo window appeared, but nothing is displayed if I type LaTeX formulas in the input box.
Does anybody have a fork of the MacOS build, that works fine in XCode 14.x and without having to install CocoaPods? (or even better: with plain Makefiles).