Magic Sapphires can be generated by using Owl Magic.
To generate Magic Sapphires, you need to activate the Apprentice Hat (Owl Magic), which is displayed at the top of the screen during battle. 
The number on the progress bar next to the Apprentice Hat indicates how many cards you need to play in a row to activate it. You need to play 5 cards to activate the Apprentice Hat (see the image below).
To complete the challenge that asks you to "Generate X Magic Sapphires", play 5 cards in a row to activate your Apprentice Hat, then play as many cards as possible before drawing a new card. 
Use a Wild Card strategically to play more cards!
Note: Each time you draw a new Card, the Apprentice Hat's progress bar resets to 0.