-
From your Xcode project, tap on
File > Add Package Dependencies...
-
Paste this URL into the search text field:
https://github.com/DodyMagic/mentaldice_swift.git
-
Add package
-
Add
source 'https://github.com/DodyMagic/mentaldice_swift.git'
on top of your Podfile -
Add
pod 'MentalDice-Swift'
into your Podfile targets -
Run
pod install
-
Add the
NSBluetoothAlwaysUsageDescription
key to yourInfo.plist
if it is not already there. -
Add
import MentalDice
to the file which is meant to receive the dice's values. -
Set yourself as delegate:
MentalDice.shared.delegate = self
-
Connect to the Mental Dice:
MentalDice.shared.connect()
-
Listen to the delegate protocol:
extension YourClass: MentalDiceDelegate {
func didUpdate(dice: [Die]) {
// ...
}
func didDetect(color: Die.Color) {
// ...
}
func didConnect() {
// ...
}
func didDisconnect() {
// ...
}
}
Optional: Remove the potential extra MentalDice.
prefixes from the generated protocol functions (func didUpdate(dice: [Die])
instead of func didUpdate(dice: [MentalDice.Die])
for example).