Advertisement
Guest User

Untitled

a guest
Jul 7th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. # Script to codesign ipa with AdHoc or distribution certificate
  2. # Execute script from the folder you have provisioning profile you want to be embedded with the IPA and name it as embedded.mobileprovision
  3. #
  4. # To change the bundle identifier pass it as argument to this script first argument is taken as bundle identifier, if more than one arguments are passed then its ignored
  5. # usage script.sh com.appid.bundleid 1.2 45 FinalIPAName
  6.  
  7. echo "Start the codesigning the app"
  8. mv *.ipa testapp.zip # Rename ipa file to .zip
  9. tar -xf testapp.zip # unzip the file to reveal Payload folder
  10. cd Payload/*.app/ # Go to Payload folder then into .app folder
  11. # Set first argument passed with this script as bundle identifier
  12. if [ $1 != 0 ]
  13. then
  14. echo "Overriding App bundle identifier...."
  15. /usr/libexec/PlistBuddy -c "Set CFBundleIdentifier $1" info.plist # Set the CFBundleIdentifier of info.plist to first argument of the script
  16. fi
  17. # Set second argument passed with this script as bundle ShortVersionString
  18. if [ $2 != 0 ]
  19. then
  20. echo "Overriding App bundle ShortVersionString...."
  21. /usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $2" info.plist # Set the CFBundleShortVersionString of info.plist to second argument of the script
  22. fi
  23. # Set third argument passed with this script as bundle version
  24. if [ $3 != 0 ]
  25. then
  26. echo "Overriding App bundle version...."
  27. /usr/libexec/PlistBuddy -c "Set CFBundleVersion $3" info.plist # Set the CFBundleVersion of info.plist to third argument of the script
  28. fi
  29. /usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" info.plist # Print CFBundleIdentifier info.plist file"
  30. /usr/libexec/PlistBuddy -c "print CFBundleVersion" info.plist
  31. rm -rf _CodeSignature # Remove _CodeSignature folder and its contents
  32. rm -rf CodeResources # Remove CodeResources file
  33. cp ../../*.mobileprovision . # Copy embdedded provisioning profile from parent folder to .app folder
  34. mv *.mobileprovision embedded.mobileprovision #Rename Provisioning profile in this folder to embedded.mobileprovision
  35. echo "Removing .DS_Store files"
  36. rm -rf .DS_Store # Remove any .DS_Store files from .app folder
  37. cd ../ # Go to Payload folder
  38. rm -rf .DS_Store # Remove any .DS_Store files from Payload folder
  39. cd ../ # Go to parent folder
  40. echo "Codesigning App..."
  41. /usr/bin/codesign -f -s "<Your Cert Name here. Get it from keychain>" Payload/*.app/ # Force Codesign the Application with Distribution certificate, name of distribution certificate should match with one in keychain access and give app path name
  42. echo "Zipping the app contained in Payload folder"
  43. if [ $4 != 0 ]
  44. then
  45. echo "Compressing payload to $4.ipa"
  46. zip -r $4.ipa Payload >/dev/null #Zip the codesigned .app into an ipa file
  47. else
  48. echo "compressing the payload to app.ipa"
  49. zip -r App.ipa Payload >/dev/null #Zip the codesigned .app into an ipa file
  50. fi
  51. rm -rf Payload
  52. rm -rf testapp.zip
  53. echo "Codesigning completed."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement