I'm sorry to hear about the issues you're experiencing with Apple Music. It can be frustrating when your music library gets disrupted like this. Here are some steps you can take to try and resolve the problem:
1. **Check iCloud Music Library Sync**: Since you mentioned that you turned off and then back on the "sync library" function, it's possible that this action caused some synchronization issues. Make sure that your iCloud Music Library is enabled on both your Mac and iPhone. To do this, go to Settings on your iPhone, then Music, and ensure that "Sync Library" is turned on. On your Mac, open Apple Music, go to Preferences, and under the General tab, ensure "Sync Library" is checked.
2. **Check Your Internet Connection**: Sometimes, issues with syncing can occur due to a poor or intermittent internet connection. Ensure that you have a stable internet connection when syncing your library.
3. **Restart Apple Music**: Sometimes, a simple restart of the Apple Music app can resolve minor issues. Close the app on both your Mac and iPhone, then reopen it.
4. **Re-add Missing Music**: If your music is still available on your Mac, you can try re-adding the missing songs to your library. Make sure the songs are correctly imported into your iTunes library and then add them to your iCloud Music Library.
5. **Contact Apple Support**: If none of the above steps resolve the issue, it might be a more complex problem. Contact Apple Support for assistance. They can help you diagnose and resolve issues specific to your Apple Music account and devices.
6. **Backup Your Music**: To avoid losing your music in the future, it's a good practice to regularly back up your music library. You can create backups of your music files on your computer or use a third-party service to back up your music library.
Remember to exercise caution when making changes to your music library, especially when importing and syncing. It's always a good idea to have backups to prevent data loss in case of unexpected issues.