Problem with simulation of the desired shape of the signal
For a square wave as used in your example phase don't do anything.
Since the fourrier series is just based on a sine wave without phase.
The fourrier series are:
$$ 
S_n (x) = \frac{a_0}{2}+ \sum_{n=1}^{N} A_n \cdot \sin (\frac{2 \pi \cdot n \cdot x}{P}) \qquad \text{for integer } N \geq 1
$$

Since the square wave have only the odd frequencies. you can choose for the sinewaves: 1, 3, 5, 7, 9, 11, 13 ,...

For other functions it is different. In that case you have both sine and cosine signals. Combination of both give as result the phase.
if you have an series of 7 or 8 frequencies it is allready close to a square wave.