In an interview with al-Jazeera, Mr Swan, also the head of the UN Assistance Mission in Somalia, said timely elections will be possible only if parties adhere to the electoral deal reached in October between the federal government and federal member states.
The federal government has since announced the key commitees meant to handle the elections. But their composition has raised controversy with 14 presidential contenders largely opposed to the teams arguing they have spies amd civil servants loyal to President Mohamed Farmaajo.
Last week, the contenders threatened to boycott the elections unless the membership of the national electoral commission, dispute resolution commitee and that of the electoral commitee for Northern Regions (Somaliland) is reviewed.
Swan said that the plan is to have members of both houses of the Federal Parliament of Somalia by the end of this year, admitting that could be the most difficult task but which will make the presidential election easier.
In Somalia, a bicameral Parliament usually elects the President in a form of indirect election. The MPs for tje Senate and the Lower House are supposed to be voted in by end of December through specially selectes delegates.
Swan called on the leaders to jointly work together to prevent chaos and violence.
The United Nations has played a central role in efforts for peace in Somalia since the downfall of President Siad Barre in 1991 prompted political chaos across the Horn of Africa.
Tensions remain high over the election, especially its committees, which have expressed concern over the union of candidates.
On Thursday the 14 presidential contenders issued a joint 18 point communique in Mogadishu and called for the removal of intelligence operatives, civil servants and supporters of President Farmajo from electoral committees.
They also called on the removal of Federal Government Forces from Gedo region.
The 14 opposition presidential candidates include former PM Hassan Ali Kheire, Former heads of state Sheikh Sharif Ahmed, Hassan Sheikh Mohamud and Wadajir party leader Abdirahman Abdishakur.