changePlatform.sh 947 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/sh
  2. CHOSEN_PLATFORM=$1
  3. # Check if a parameter was passed
  4. if [ -z $CHOSEN_PLATFORM ]
  5. then
  6. echo "No chosen platform was passed. Please enter iOS, Android or Web as platforms"
  7. exit 1
  8. fi
  9. #Check for valid platforms
  10. if [ $CHOSEN_PLATFORM != "iOS" ] && [ $CHOSEN_PLATFORM != "Android" ] && [ $CHOSEN_PLATFORM != "Web" ]
  11. then
  12. echo "Unknown Platform. Please enter iOS, Android or Web as platforms"
  13. exit 1
  14. fi
  15. #Detect current platform by inspecting the current available Libraries
  16. if [ -d "Library_iOS" ]
  17. then
  18. if [ -d "Library_Android" ]
  19. then
  20. CURRENT_PLATFORM="Web"
  21. else
  22. CURRENT_PLATFORM="Android"
  23. fi
  24. else
  25. CURRENT_PLATFORM="iOS"
  26. fi
  27. echo "Current platform is $CURRENT_PLATFORM"
  28. #Swap libraries accordingly
  29. if [ $CURRENT_PLATFORM = $CHOSEN_PLATFORM ]
  30. then
  31. echo "You are already on $CURRENT_PLATFORM"
  32. else
  33. echo "Changed platform to $CHOSEN_PLATFORM"
  34. mv "Library" "Library_$CURRENT_PLATFORM"
  35. mv "Library_$CHOSEN_PLATFORM" "Library"
  36. fi