The efficiency of Ullmann reaction of aryl chlorides on an Au(111) surface has been substantially increased by using dosed Cu as a catalyst. The different reactivity of aryl bromides and aryl chlorides has been exploited to design a programmed, on-surface synthesis to form 2D covalent organic frameworks.