For a smooth transition to Scottish independence, it is essential to negate the hostility of Spain which could derail acceptance by the EU. My two decades of experience in diplomatic negotiations teaches me that the answer to this is finding a ladder for Spain to climb down; some Spanish steps, in fact.
Scotland has to be accepted in the EU, and Spain has to secure a victory in a recognition that this is in no way a precedent for Catalonia. In every diplomatic agreement everybody has to sacrifice something, and I am afraid what Scotland has to sacrifice here is the principle of solidarity with our Catalan friends.
In the event of a Brexit, France and Germany, assisted by the EU Commission, will immediately open channels to Holyrood in order positively to encourage Scotland to go independent and remain within the EU. As part of any agreement, the principle can be enumerated that there is a right for a “region” (sorry, we will have to swallow that transitory description to win the Spanish) to secede and form a new state, in order to remain within the EU when a state in which that region is incorporated is leaving the EU.
Spain will be able to accept this formulation as it sets no precedent for Catalonia, given that Spain is not exiting the EU.
It remains my strong opinion that, in the event of a Brexit, things will move very swiftly to UDI for Scotland. There will be no requirement for a second referendum as Nationalists will have won overwhelmingly in both Westminster and Holyrood elections within a year. As I repeatedly explain, the sole test of a state’s independence is recognition by the UN (and there is no security council veto). With EU support Scotland should be able to achieve international recognition extremely quickly; the UK, thanks to Blair, Brown and Cameron, is very unpopular with the large majority of member states.