如何在 macOS 中使用 iosMath 数学库?

How to use iosMath math library in macOS?

我感兴趣的是能够键入 LaTeX 以获得 格式化的数学输出 我的 macOS 项目。我曾尝试使用著名的 iosMath CocoaPod Library and also seen its working from their official examples Repository on GitHub. I am using Xcode 10, Swift 4.2 on macOS Mojave (10.14). Using the guidance given on the reply of this I was able to successfully incorporate the library and make it render Mathematical Text using latex in any iOS projects successfully. But it is giving great conflicts and problems in macOS. After Installing the CocoaPod in my own project successfully I tried to follow the paradigm given in their official macOS Example 进行多次试验和错误,但都以失败告终。 我正在描述我尝试过的任何内容:

var mathViewCode: MTMathUILabel = MTMathUILabel() @IBOutlet weak var mathViewIB: MTMathUILabel! override func viewDidLoad() { super.viewDidLoad() mathViewIB.latex = "\lim_{x\to\infty}\left(1 + \frac{k}{x}\right)^x = e^k" mathViewCode.latex = "\int_{-\infty}^{\infty} \! e^{-x^2} dx = \sqrt{\pi}" self.view.addSubview(mathViewCode) }

Failed to set (contentViewController) user defined inspected property on (NSWindow): -[NSView setLatex:]: unrecognized selector sent to instance 0x60000330d7c0

IB Designables: Failed to render instance of MTMathUILabel: The agent threw an exception.

Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)

如您所见,我尝试遵循他们官方 macOS Sample Project 中给出的方法,但在我的情况下没有任何效果,即使他们的 示例项目成功编译并运行s好在我Xcode.

请帮我解决这个 iosMath 库 因为我真的很想用它 因为它的 Beautiful Output 强大的功能 或者请推荐一些其他的数学库来输入 LaTeX 在我的 Mac 应用程序中 在 macOS 上确实 运行s Swift非常感谢提前!!

我运行遇到了同样的问题。 我没有解决方案,但可以将 iosMath 与 MacOs 一起使用,并且 swift。 我创建了我的 Project LatexPic 并将其添加到原始 podfile。现在您可以在 macOS 应用程序中的视图控制器中使用它,例如:

let latexlabel = MTMathUILabel()

override func viewDidLoad() {
    super.viewDidLoad()
    view.backgroundColor = .white

    self.view.addSubview(latexlabel)
    latexlabel.backgroundColor = .white
    latexlabel.frame = CGRect(x: 0, y: 0, width: 200, height: 200)
    latexlabel.latex = "\frac{2}{3}"

    }

播客文件:

workspace 'iosMath.xcworkspace'
install! 'cocoapods', :deterministic_uuids => false

target 'iosMathExample' do
  project 'iosMath.xcodeproj'
  pod 'iosMath', :path => './'
end

target 'iosMathTests' do
  project 'iosMath.xcodeproj'
  pod 'iosMath', :path => './'
end

target 'MacOSMath' do
  project 'MacOSMath.xcodeproj'
  pod 'iosMath', :path => './'
end

target 'LatexPic' do
    use_frameworks!
    project 'LatexPic.xcodeproj'
    pod 'iosMath', :path => './'
end