You’re looking for something like iRig.
https://www.amazon.com/IK-Multimedia-Interface-Adaptor-IPIRIG2PLGIN/dp/B00T631UTC
This should do it, I know one common use case of this is using effects apps on the phone
If you want cheap I'd recommend something like this.
IK Multimedia iRig 2 Guitar Interface Adaptor for iPhone, iPod Touch & iPad https://www.amazon.com/dp/B00T631UTC/ref=cm_sw_r_cp_api_glt_fabc_PAHQT9R6RH3F571D732F?_encoding=UTF8&psc=1
There are also camera adapters that let you charge the iPad while playing