When gnerating Code of a Model (== Build the model for RPi) then the CodeGenerator needs a TLC File to inline the S-Function. When you have the RealTimePacer From Matlab Exchange, there is a Sentence that is does not support Code Generation. The only thing you can do is to write a TLC file on your own. See More Details in the Mathwork Help with Searching for "TLC generation", "Inlining S-Functions","..."
I did this with another Matlab Exchange Pacing-Script until it worked. Just 2 weeks before R2018a.
BUT since the new Matlab Version R2018a, Simulink comes with a "RealTimePacer" by it's own. This one does the same as the Script. Unfortunately I have not tested myself wether it supports CodeGeneration. Here is the Link to the new Feature: Simulink RealTimePacer
Since in this Link under Limitations, they don't exclude CodeGeneration, I suppose that it works.
Hopefully this helps you :-)