It sounds like you didn't replicate your schema to production.
When you run from Xcode the app choses to use the development environment or the production environment based on the value in the info.plist of:
Once your app is approved it will always use 'production'.
You also need to deploy to development -
0) remove unwanted record fields and select the specific indexes that you actually want to sort and query
1) click on the blue cube in the top left
2) select the database
3) open the 'settings' type icon next to "development"
4) click 'deploy to production'