Well, in an comment user user194703 mentioned, that commands \include and \includeonly can do what you want. Let us take a look into details ...
Please see that you need two tex files, for example main.tex
\chapter{Report}
Report body.
I want to reference \ref{sec:appendix1}
and appendix.tex
\appendix
\chapter{Appendix}
Here's a really long appendix with a reference \label{sec:appendix1}.
to be included in your file mwe.tex like this:
\documentclass{report}
\includeonly{main,appendix}% <========================================== first compile run
%\includeonly{main}% <================================================== second and more runs
\begin{document}
\include{main.tex} % <==================================================
\include{appendix.tex}% <===============================================
\end{document}
Command \includeonly{main,appendix} in your preamble includes only the two files main.tex and appendix.tex (there might be more files included in your document) into the compile run with the result that you get the two files main.aux and appendix.aux containing the needed informations for correct references.
Please see that after the first run you see only ?? instead a reference (that is okay! a second run is needed).
For the second (and third etc) run move the %sign to have only command \includeonly{main} called:
\documentclass{report}
%\includeonly{main,appendix}
\includeonly{main}% <================================================== second and more runs
\begin{document}
\include{main.tex} % <==================================================
\include{appendix.tex}% <===============================================
\end{document}
Then you get thw wished result: no appendix printed, but the reference to Appendix A is printed as you can see in the following pdf:

\includeand\includeonly. – Feb 08 '20 at 01:07\includeonly{main,appendix}, wheremain.texcontains `\chapter{Report} Report body. – Feb 08 '20 at 02:25