Pain in the anterior portion of the shoulder is a common site in freestyle swimmers. It is more frequently a problem occurring in high volume swim training or, in recreational swimmers with tissue restrictions common in postural distortions in desk workers. Sports medicine research into this issue indicates fatigue of the deep internal shoulder rotators (Subscapularis) and/or serratus anterior scapula control are commonly part of this presentation.
If the shoulder pain starts up at the beginning of (or before) the session, continues afterwards, or occurs with other everyday activities, it may be tendon or capsule related, and may take several weeks to settle under exercise management.
Generally the first port of call is to have your coach/a coach assess your technique, and assess your training volume (I am not a technique coach, I assess and treat the biomechanics that enable the technique and efficiency to occur). In the absence of a technique issue, a training volume issue (ie too much load for current fitness) will have shown itself by pain that you first became aware of towards the end of your sessions, or end of a week training and then goes away. This implies muscular fatigue. Reducing volume for a week will help before ramping back up. Focus on cleaning up the technique in the meantime and getting to know the factors elsewhere in your body that lead to overwork.
You are unlikely to know just what swimming related ranges of motion you are in deficit with until you are tested.
The body acts as a whole - you know, the thighbone is connected to the shoulder joint, breathing dysfunction interferes with shoulder function, and so on, for example. Improving the general economy of a swimmers body by removing unnecessary restrictions along its kinetic chain and approximating it towards optimal swimming range of motions allows the strain and fatigue in the deep internal shoulder rotators/serratus muscle to reduce. From this point of view, the shoulder is just the symptom.
However, the painful shoulder does need to be specifically treated too. The first reason is that general treatments for underlying causes need at least a week to show changes, and sometimes several weeks. But, specific treatments aim at treating the symptomatic tissues in the shoulder for trigger points, scar tissue, and "reactive"(fatigue and pain-related) tightness to create immediate effects. Significant disruption to training can be reduced by using specific treatments. Taping and a variety of self-treatments also fall into this category of assistive treatment.
Younger swimmers tend to have hyper-mobile shoulder capsules with reduced or imbalanced strength in the rotator cuff. Strengthening the rotator cuff and scapula stabilisers is commonly required in this group. Technique training and volume reduction with a coach is the most important immediate strategy at this stage. Avoiding stretches of the rotator cuff is also generally important. Taping to discourage excess shoulder extension or encourage everyday postural scapula control may help these people.
Generally, older swimmers will have a stiffness related problem in the rotator cuff along side of fatigue in the deep internal rotators, with contributions from several areas lower down the kinetic chain relating to that shoulder. For this group, manual therapy directed at loosening the thoracic cage, lengthening and loosening the posterior shoulder capsule and pectoralis minor are commonly required.
A common example in older swimmers is the person new to swimming trying to find a less impactful form of aerobic exercise. After years of desk work and postural decline, gaining the minimum range of motion throughout the body for swimming is a big task made easier with assessment manual therapy and dry land exercises.
So both populations often present the same area of pain, while needing different treatment.
If pain onset has progressed to the beginning of sessions, or continues afterwards, this implies tendon or other non-muscular structures are involved and that their structures have been damaged. These tissues are slower to heal but it doesn't necessarily mean an end to training. Relative rest just means to train smart. I definitely recommend careful progressive strength rehabilitation here.
Also, full kinetic chain assessment with targeted exercise management may help take excess load off the shoulder and put you in a stronger position when you restart full training.
So, the basic rule is relative rest (smart training) alongside of progressive rehabilitation (smart exercise) and technique training. What this looks like in practice depends on the swimmers whole situation, and I hope that you feel like your situation has been broadly identified and clarified here.