在Swift中使用iosMath

我怎样才能在iOS上的Swift中使用iosMath ,因为iosMath是用Objective C编写的? 还是有另一种方法来显示math公式与斯威夫特?

我会尽可能快地做到这一点:

1.)安装cocoaPods(打开terminal并编写sudo gem install cocoapods

2.)从terminal更改目录到您的项目和init cocoaPods并像这样编辑Podfile:

 cd /ProjectFolder pod init nano podFile 

(打开podfile,粘贴pod repo的位置),应该如下所示:

 # Uncomment the next line to define a global platform for your project # platform :ios, '9.0' target 'mathExample' do # Comment the next line if you're not using Swift and don't want to use dynam$ use_frameworks! # Pods for mathExample pod 'iosMath' end 

保存podfile并通过以下方式安装:

 pod install 

从现在开始,使用工作区文件而不是项目文件…我们现在正在安装您需要的窗格…

现在有点棘手 – >你需要从项目中添加新的Objective-C文件(所以只需新build文件 – > Objective-C文件并select创build桥接头),你可以删除创build的文件(BUT不是桥头)

从现在起,您可以像使用Swift框架一样使用Objective-C框架,不要忘记将该框架导入到您将使用的框架中:

  import UIKit //Importing our module import iosMath class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() print(iosMathVersionNumber) // Do any additional setup after loading the view, typically from a nib. } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } 

希望这有助于祝愿编程愉快! 🙂

一般问题已经回答了。 检查这个问题了 。

所有你需要做的是添加iosMath在你的podfile中,只要你有use_frameworks! 在podfile中,你将不需要任何头文件。 只需将iosMath导入swift文件中即可。