In May, the authorities in the canton of Basel-Landschaft — which is next to the canton of Basel-Stadt, where the swimming case occurred — ruled that two Syrian immigrant brothers, who studied at a public school in the small town of Therwil, could not refuse to shake their teacher’s hand on religious grounds. Their refusal to do so had provoked a national uproar.

The challenge of integrating immigrants has spilled over into culture, and, at times, helped fan a simmering culture war. In Denmark, pork meatballs and other pork dishes that are popular staples became part of a debate on national identity last year after the central Danish town of Randers voted in January to require public day care centers and kindergartens to include the meat on their lunch menus.

Supporters of the proposal said that serving traditional Danish food such as pork was essential to help preserve national identity. Critics said the proposal did nothing more than stigmatize Muslims, who had made no attempts to ban pork from school menus.

Germany was shaken during New Year’s Eve in Cologne in 2015 when young men, many of them of North African origin, committed sexual assaults during the street celebrations there. The attacks became an uncomfortable symbol of the challenges of integration in the country.

In France, the clash between secularism and religious conservatism came into sharp relief this summer when nearly 30 towns, mainly in the country’s southeast, introduced burkini bans, suggesting that the garments impinged upon French culture and way of life.

In the case of the swimming classes in Switzerland, the authorities ruled that lessons mixing boys and girls were an important part of the school curriculum; they did allow that the girls could apply for an exemption on religious grounds, but only if they had gone through puberty, which was not the case for the daughters of Mr. Osmanoglu and Ms. Kocabas.

The parents argued that even though the Quran does not require girls’ bodies to be covered until puberty, “their belief commanded them to prepare their daughters for the precepts that would be applied to them from puberty” onward, according to the court’s summary of the case.