The shield came first. The sword is an invention of the bronze age, but the shield has been used to protect against many types of weapons by stone age (not primitive) peoples. It is still in use today by traditional societies. For example: See pics of an Australian aborigine and a Zulu warrior.
The shield is believe to have been invented in the late Neolithic Period. During the Neolithic, humans began invented more tools from wood, rather than only stone. An early shield would most likely be made from wood and humans would have co-invented it around the world at different times. Due to the fact that Australian Aborigines invented the shield, but not the bow, it is possible that it was invented around 10,000 BCE or before. The earliest cave drawings of organized warfare in Europe involve the use of formations and the bow, but not the shield. So, it is possible that the shield predates warfare, but it is unlikely. The Neolithic Period was a time when humans began animal husbandry and early agriculture. Soon population pressures led to warfare that is believed had not existed before this time. There was a huge increase in the manufacture of weapons, which can be seen in the archeological record. The invention of the shield is most likely a response to organized warfare and the invention of these weapons and was not used in earlier periods for another purpose, such as to a tool for protection while hunting. (Also when humans were hunter-gathers they would have had to carry the shield everywhere during their migrations.)