Skip to content

Instantly share code, notes, and snippets.

@julianschiavo
Last active December 22, 2023 14:26
Show Gist options
  • Save julianschiavo/19269383d4d31b61ad18560f6a65adee to your computer and use it in GitHub Desktop.
Save julianschiavo/19269383d4d31b61ad18560f6a65adee to your computer and use it in GitHub Desktop.
Bash script to resign wrapped iOS apps on Apple Silicon; allows running third party apps

iOS Apps on Apple Silicon

Bash script to resign wrapped iOS apps on Apple Silicon; allows running third party apps

  1. Get a copy of an unencrypted iOS app (IPA) file (see here)
  2. Double-click the file on Mac with Apple Silicon to install it to /Applications
  3. Save the resign.sh script
  4. Replace CODE_SIGN_IDENTITY_HERE with your code signing identity from Xcode (see here)
  5. If needed, allow execution on the script file by running chmod +x SCRIPT_PATH in Terminal
  6. Run resign.sh, passing in the wrapped app to resign ./resign.sh /Applications/Snapchat.app
  7. If successful, the resigned app will open

Unencrypted IPAs

Running third party iOS apps natively on Mac with Apple Silicon requires a decrypted IPA. You can get a decrypted IPA for your own app, or fetch it from your device. If you're unsure how to get a decrypted IPA, look it up online.

Signing Identities

The script requires an Apple Developer Account & Codesigning Identity in the Keychain. After installing Xcode and signing in with your Apple Developer Account, open Keychain Access and search for "Apple Development". Your keychain identity is the name of the certificate, which looks like: Apple Development: YOUR_EMAIL (ID). Replace CODE_SIGN_IDENTITY_HERE in resign.sh with that string.

Disclaimer

You must read and agree to the disclaimer before using this: DISCLAIMER.md.

License

See LICENSE.md.

#!/bin/bash
# Script code by Julian Schiavo
# Codesigning code modified from original by Steve Troughton-Smith: https://twitter.com/stroughtonsmith/status/1286671707248439296?s=21
codeSignIdentity="CODE_SIGN_IDENTITY_HERE"
tempDir=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')
tempEntPath="$tempDir"/temp.xcent
# Make sure the code signing identity is valid
if [ "$codeSignIdentity" == "CODE_SIGN_IDENTITY_HERE" ]; then
echo "You must replace CODE_SIGN_IDENTITY_HERE in the script before running. See instructions.txt for help."
exit 1
fi
# Make sure the app to resign is provided
if [ "$1" == "" ]; then
echo "Missing argument: the wrapped app to resign."
exit 1
fi
wrapperDir="$1"/Wrapper
app="$wrapperDir"/*.app
# Check for the existence of the wrapper app and directory -- if this doesn't exist, the .app path is invalid or it is not a wrapped iOS app, so quit
if [[ ! -a "$wrapperDir" ]]; then
echo "File not found: $wrapperDir does not exist."
exit 1
fi
echo "Resigning $1..."
# Authenticate as sudo, showing a notice if unauthenticated
sudo -n true
# Copy the original entitlements (running bash as sudo to ensure we have permission to pipe output to a protected file)
sudo bash -c "codesign -d --entitlements :- $app > $tempEntPath"
# Resign all embedded frameworks
sudo codesign -f -s "$codeSignIdentity" --entitlements "$tempEntPath" $app/Frameworks/*
# Resign the app itself
sudo codesign -f -s "$codeSignIdentity" --entitlements "$tempEntPath" $app
echo "Resigned $1"
echo "Opening $1..."
open $1

There are inherent dangers in the use of any software available for download on the Internet, and we caution you to make sure that you completely understand the potential risks before downloading any of the software.

The Software and code samples available here are provided "as is" without warranty of any kind, either express or implied. Use at your own risk.

The use of the software and scripts here is done at your own discretion and risk and with agreement that you will be solely responsible for any damage to your computer system or loss of data that results from such activities. You are solely responsible for adequate protection and backup of the data and equipment used in connection with any of the software, and we will not be liable for any damages that you may suffer in connection with using, modifying or distributing any of this software. No advice or information, whether oral or written, obtained by you from us or from this website shall create any warranty for the software.

We make makes no warranty that

  • the software will meet your requirements
  • the software will be uninterrupted, timely, secure or error-free
  • the results that may be obtained from the use of the software will be effective, accurate or reliable
  • the quality of the software will meet your expectations
  • any errors in the software obtained from us will be corrected.

The software, code sample and their documentation made available on this website:

  • could include technical or other mistakes, inaccuracies or typographical errors. We may make changes to the software or documentation made available on its web site at any time without prior-notice.
  • may be out of date, and we make no commitment to update such materials.

We assume no responsibility for errors or omissions in the software or documentation available from its web site.

In no event shall we be liable to you or any third parties for any special, punitive, incidental, indirect or consequential damages of any kind, or any damages whatsoever, including, without limitation, those resulting from loss of use, data or profits, and on any theory of liability, arising out of or in connection with the use of this software.

TO THE EXTENT NOT PROHIBITED BY APPLICABLE LAW, YOU ASSUME ALL RISKS AND ALL COSTS ASSOCIATED WITH TESTING, INSTALLATION, OR USE OF THE SOFTWARE AND SEEDING TOOLS PROVIDED, INCLUDING, WITHOUT LIMITATION, ANY BACK-UP EXPENSES, COSTS INCURRED FOR THE USE OF THE SOFTWARE ON YOUR COMPUTER, DEVICES AND/OR PERIPHERALS, AND ANY DAMAGE TO ANY EQUIPMENT, SOFTWARE, INFORMATION OR DATA, AND IN NO EVENT WILL I, OR CONTRIBUTORS, BE LIABLE FOR ANY INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, WHETHER ARISING IN TORT (INCLUDING NEGLIGENCE), CONTRACT OR OTHERWISE, ARISING OUT OF OR RELATED TO THIS AGREEMENT, INCLUDING ANY LIABILITY THAT STEMS FROM ANY USE OF THE SOFTWARE ON YOUR COMPUTER, DEVICES AND/OR ANY PERIPHERALS CONNECTED THERETO, AND/OR FROM ANY OTHER CONFIDENTIAL INFORMATION, AND/OR THE PERFORMANCE OR FAILURE TO PERFORM UNDER THIS AGREEMENT, EVEN IF WE HAVE BEEN ADVISED OR IS AWARE OF THE POSSIBILITY OF SUCH DAMAGES. THE FOREGOING LIMITATIONS WILL APPLY EVEN IF THE ABOVE STATED REMEDY FAILS OF ITS ESSENTIAL PURPOSE.

Copyright 2020 Julian Schiavo.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ayouch
Copy link

ayouch commented Aug 14, 2021

not working!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment