The German and Allied force committtments
For the Germans there were two scenarios considered. The first was against Spain resisting a German invasion, the second was Spain acting as an Axis ally.
Scenario 1....Spain as an Allied nation.
The German plan (scheduled for early 1941) called for the following forces to be committed
4 x Panzer Divs (3, 4, 6, 7), 2x Mot Divs (SS Totenkopf, 20 Mot), 2 x Gebirgsjager Divs, 14 x Inf Divs (5, 6, 8, 11, 12, 17, 24, 28, 34, 35, 52, 57, 78, 87, 267, 296, Pol (SS)) 1 x Air landing Division (22), 5 x Parachute Bns, 1 x Bicycle Bn, 2 x mot MG Bn, 3 x Hy AA Regt, 10 x engineer, 6 x Artillery Regt (Corps Artillery). On D-28 they hoped to have in place outside gibraltar an impressive Siege train, consisting of most of germany's heavy siege guns...about 6 x hy artillery regts. About half of these were railroad guns and would have required about three months to get into position due to the state of Spains railways.
The LW committment was for one air fleet to be initially deployed. I forget which one, but not all these units are specialist anti-shipping units. Approximate committment levels were
80 x Dp17z, 200 x He111, 180 Ju 87B, 280 Me 109, 120x Me 110, 3-400 Ju52s,
Scenario 2....Spain as an axis nation
In the event of Spain joining as an Axis Partner, German committment was far more restrained. Canaris's mission in June 1940, envisaged the committment of a single mtn div amounting to 15000 men. There was no heavy artillery committed, as the germans assumed the Spaniards would provide that. If so, there would have been a minimum three month delay between the Spaniards joining the Axis and and the commencement of an actual attack. In that time the Brits would have reinforced the garrsion even further.
The British response
The British also had a number of contingency plans in the event of Spanish belligerency. If Spain were hostile, this would have meant a delayed involvement of at least three months. in that time the Brits planned or made contingency plans to occupy Spanish Morroco and the canary islands, to seize the approaches to Gibraltar. I am not exactly sure of the operational plans....but they involved committment by 4 x Inf Divs (1, 2 Can, 3, 43), 1 x Armoured Div (1), 2 x Hvy Tank Bdes (3, 5), 3 x Cprps Artillery Regt, 3 x Engineer Regts, 3 x Hvy Aa Bdes. The Brits planned to commit about 400 aircraft to the capture of morocco, including 140 Spits and a similar number of hurricanes.
The standing garrison in Gib consisted of 2 x Infantry Brigades (1Gib, 2 Gib) and over 300 gun emplacements. The approaches to Gibraltar were heavily mined, and aparently narrowed to less than 500 yards across. The approaches to Gib were flat and open, whilst the fortress rose uncharacteristically out of the sky.
I have not found what the British response would have been if the germans had invaded Iberia. However it was expected that the Spaniards would have been jooined by the portuguese (since they had an alliance), and force levels similar to the above could be expected from the Brits.
General situation
"Following the fall of France to Germany in June 1940, Hermann Göring advised Adolf Hitler to occupy Spain and North Africa rather than invade Britain. As early as June 1940, before the armistice with France had been signed, General Heinz Guderian also argued for seizing Britain's strategically important naval base of Gibraltar. Guderian even urged Hitler to postpone the armistice so that he could rush on through Spain with two Panzer divisions, take Gibraltar, and then invade French North Africa. General Alfred Jodl, chief of Oberkommando der Wehrmacht (OKW) operations, presented Hitler with a formal plan to cut off Britain from its eastern empire by invading Spain, Gibraltar, North Africa, and the Suez Canal instead of invading the British Isles.
On 12 July 1940, the OKW set up a special group for the necessary planning. On 22 July, Admiral Wilhelm Canaris, the head of the Abwehr and an acknowledged expert on Spain, travelled with several other German officers to Madrid, Spain, where they held talks with General Francisco Franco and General Juan Vigón, his Minister of War. They then travelled on to Algeciras, where they stayed some days to reconnoiter the approaches to Gibraltar. They returned to Germany with the conclusion that Franco's regime was reluctant to enter the war. However, it has since become known that Canaris was disloyal to Hitler and actually encouraged Franco not to join the Axis, since an Allied victory was almost certain. Canaris' team did however determine that Gibraltar might be seized through an air-supported ground assault involving at least two infantry regiments, three engineer battalions, and 12 artillery regiments. The assessment team advised that without 15 in (380 mm) heavy assault cannon — which he knew were unavailable — Gibraltar could not be taken. When Canaris reported to Field Marshal Wilhelm Keitel, he gave his personal opinion that even if Germany were able, with the cooperation of Spain, to seize Gibraltar, the British would land in Morocco and French West Africa.
On 18 July, Franco claimed Gibraltar. He did not expect the British to accede to the claim and made it to keep Germany from attempting to take it.
In August, Canaris met with Franco's brother-in-law, Ramón Serrano Súñer, who was about to become Spain's Foreign Minister. Canaris urged Súñer to do what he could to convince Franco to stay out of the war. Soon after, Franco dispatched Súñer to Berlin to get an idea of Hitler's attitude, since Canaris had assured him that Germany would not forcibly intervene in Spain. When Súñer met Hitler on September 16, Hitler did not press very hard for Spanish involvement in the war, perhaps because he planned to meet Franco himself very soon.
Canaris met with Franco around the same time and warned him that if Spain joined the Axis, the Spanish islands — even mainland Spain itself — would be at risk from British attack. Knowing that Franco feared a hostile German invasion of Spain if he refused to cooperate, Canaris informed him that Hitler had no such intention due to the planned invasion of Russia. Canaris also surprised Franco by admitting that he was convinced Germany could not win the war
German military leaders proceeded to prepare for a large-scale operation against Gibraltar. Codenamed Operation Felix, the plan called for two German army corps to enter Spain across the Pyrenees. One corps, under General Ludwig Kübler, was to cross Spain and assault Gibraltar, while the other, commanded by General Rudolf Schmidt, was to secure its flanks. Air support would need one fighter and two dive-bomber wings. Overall command of Felix was to be assigned to Field Marshal Walther von Reichenau. The plan also made provisions for occupying Spanish possessions in North Africa: Spanish Morocco, Río de Oro, and the Canary Islands, whose ports could then be used as bases for German U-boats.
On 12 November, Hitler issued Führer Directive No. 18, which stated that "political measures to induce the prompt entry of Spain into the war have been initiated" and that "The aim of German intervention in the Iberian Peninsula (code name Felix) will be to drive the English out of the Western Mediterranean." It also mentioned the potential invasion of Portugal if the British gained a foothold and requested that the occupation of Madeira and of the Azores be investigated.
On 5 December, Hitler met with the German High Command and decided to request permission from Franco for German troops to cross the Spanish border on 10 January 1941. It was planned that General Jodl would go to Spain to make preparations for the attack on Gibraltar as soon as Canaris had obtained Franco's agreement. Canaris accordingly met with Franco on 7 December and put to Franco the need for Spain's immediate entry into the war. Franco responded that Spain was simply not capable, due to shortages of food. He also expressed his fear that German seizure of Gibraltar would lead to the loss of the Canary Islands and Spain's other overseas possessions.
On receiving Canaris' report, Hitler decided that Operation Felix should be cancelled.
In the opening weeks of 1941, unsuccessful efforts were made by both Berlin and Rome to encourage the Spanish government to change their stance. Franco answered negatively to another request from Hitler to join the war, received on 6 February, using as a pretext the precarious state of Spain's economy. Joachim von Ribbentrop, Germany's Foreign Minister, told Hitler that in his opinion Franco had no intention of ever joining the war.
In February 1941, the OKW advised the naval high command that Operation Felix was out of the question for the time being, since the troops earmarked for it would soon be needed elsewhere.
Felix-Heinrich
On Hitler's insistence, the OKW developed a revised plan for the capture of Gibraltar, which might be implemented once the German invasion of the Soviet Union had been completed. Codenamed Felix-Heinrich, the plan was submitted to General Franz Halder on 10 March 1941. It proposed that as soon as the invading forces in the Soviet Union reached a line between Kiev and Smolensk, hopefully by 15 July, units could then be withdrawn to prepare for the Gibraltar operation, which it was thought could begin on 15 October. Felix-Heinrich would broadly follow the original plan, with the same forces, but with new supporting units."