how can I use iosMath in Swift on iOS, because iosMath is written in Objective C? Or is there another way to display mathematical formulas with Swift?
I will make this as fast as possible:
1.) install cocoaPods (open up terminal and write sudo gem install cocoapods
)
2.) From terminal change directory to your project and init cocoaPods and edit the Podfile like this:
cd /ProjectFolder
pod init
nano podFile
(opens the podfile, where you paste the pod repo) , should look like this:
# 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
save podfile and install via:
pod install
from now, use the workspace file instead of the project file... We are done installing the pod you need right now...
Now it gets a little bit tricky -> You need to add new Objective-C file into the project (so just New File -> Objective-C file and select create bridging header) from now, you can just delete the created file (BUT NOT THE BRIDGING HEADER)
from now, you can use the Objective-C framework just as it was swift framework,don't forget to import that framework into classes you will use it:
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.
}
}
Hope this helps, wish happy coding! :)