If I am correct, Spain launched numerous crusades into north Africa capturing cities like Oran (1509), Melilla (1497), and Tripoli (1511), however they were not able to hold them for long. Portugal also launched crusades into Morocco, capturing Ceuta (1415), Tangiers (1471), and Mazagan (1485). Although Portugal was able to retain their possessions in Morocco longer than Spain was in North Africa (lets just ignore Ceuta, and Melilla here). The Barbary region itself was not very important to commerce (trans-saharan trade declined greatly following the establishment of Spanish and Portuguese colonies in West Africa), and were very resistant to occupation by, at that time, an enemy without a massive technological advantage. Hope this helps!