Just saw this -- to answer the question, you do indeed have to have the MkIII ships unlocked for the MkIV ships to be available. AND you have to have the advanced factory. So if you then lose the advanced factory, you can't build anymore MkIV ships until you get another advanced factory. If there are no more advanced factories... then that's just it for you and MkIV ships in that game. So be quite careful to keep those alive if possible! Generally there are at least 2 advanced factories in the map per human players in the game. But, under the mission objectives you can see the exact current number remaining if you ever need to know.
As far as gifting goes, you can gift any ships that another player has access to in terms of tech unlocking, regardless of whether they have construction buildings that can support it. So, for instance, you can gift any of the non-tech-unlock-requiring ships (golems, experimental ships, etc) between players at any time. And, in the case of MkIV ships, you can gift them to any players who have unlocked the MkIII versions of those ships, regardless of whether or not they have an advanced factory.
Often in a multiplayer game, it is a good idea to share a smaller number of advanced factories than there are players (or have some players specialized in non-MkIV ships such as other capturables, or Starships or similar), to avoid having to take so many planets to get enough advanced factories for everyone. But, it depends on the players and the scenario, for sure.
Hope that helps!