<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Daniel</title>
    <description>The latest articles on DEV Community by Daniel (@danielplust).</description>
    <link>https://dev.to/danielplust</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F195223%2Fad1dbcc4-064f-45b2-8537-cee8c15c9798.jpg</url>
      <title>DEV Community: Daniel</title>
      <link>https://dev.to/danielplust</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/danielplust"/>
    <language>en</language>
    <item>
      <title>Resign An iOS App At The Command Line</title>
      <dc:creator>Daniel</dc:creator>
      <pubDate>Wed, 25 Nov 2020 15:59:10 +0000</pubDate>
      <link>https://dev.to/danielplust/resign-an-ios-app-at-the-command-line-5df</link>
      <guid>https://dev.to/danielplust/resign-an-ios-app-at-the-command-line-5df</guid>
      <description>&lt;p&gt;Do you need to resign an iOS app due to an expiring provisioning profile or new&lt;br&gt;
bundle identifier, but you don't have access to the project files&lt;br&gt;
(&lt;code&gt;.xcodeproj&lt;/code&gt; or &lt;code&gt;.xcworkspace&lt;/code&gt;)? Or maybe you do have access to the project&lt;br&gt;
files, but your environment's version of Xcode can't build the project within&lt;br&gt;
the GUI for whatever reason? In this article, I'll share with you a solution&lt;br&gt;
that resigns an app without having to open Xcode.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Svbm7cXM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k0eg4lbngyofbuanathr.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Svbm7cXM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/k0eg4lbngyofbuanathr.jpeg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Assumptions
&lt;/h2&gt;

&lt;p&gt;You have&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A Mac with Xcode installed&lt;/li&gt;
&lt;li&gt;An iOS app file (&lt;code&gt;.ipa&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;A valid provisioning profile you wish to resign the app with
(&lt;code&gt;.mobileprovision&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;A valid distribution certificate for the above provisioning profile along
with the private key used to generate the certificate in your Mac's Keychain&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;Below is a bash script I wrote that you can download:&lt;/p&gt;



&lt;p&gt;After downloading, you'll need to change the permissions of the script to allow&lt;br&gt;
it to be executable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;chmod &lt;/span&gt;755 resign-ios-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;

&lt;p&gt;Invoke the script without any arguments to see an instructional message:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./resign-ios-app
Expected at least three arguments.
Something like &lt;span class="s1"&gt;'AnApp.ipa'&lt;/span&gt; &lt;span class="s1"&gt;'AProvisioningProfile.mobileprovision'&lt;/span&gt; &lt;span class="s1"&gt;'iPhone Distribution: AnOrganization'&lt;/span&gt; where
  &lt;span class="nv"&gt;$1&lt;/span&gt; is an .ipa file
  &lt;span class="nv"&gt;$2&lt;/span&gt; is a .mobileprovision
  &lt;span class="nv"&gt;$3&lt;/span&gt; is the name of a distribution certificate &lt;span class="k"&gt;in &lt;/span&gt;the Keychain
You may pass a fourth argument to serve as a new bundle identifier &lt;span class="k"&gt;for &lt;/span&gt;the resigned app. If not included, the original bundle identifier will be used.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Assuming you have this script, the &lt;code&gt;.ipa&lt;/code&gt;, and &lt;code&gt;.mobileprovision&lt;/code&gt; all in the&lt;br&gt;
same folder, and you're in that folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./resign-ios-app &lt;span class="s1"&gt;'AnApp.ipa'&lt;/span&gt; &lt;span class="s1"&gt;'XC_iOS_comcompanyAnApp.mobileprovision'&lt;/span&gt; &lt;span class="s1"&gt;'iPhone Distribution: AnOrganization'&lt;/span&gt;
Unzipping &lt;span class="s2"&gt;"AnApp.ipa"&lt;/span&gt;...
Extracting .app...
Removing existing _CodeSignature...
Decoding &lt;span class="s2"&gt;"XC_iOS_comcompanyAnApp.mobileprovision"&lt;/span&gt; and writing to ProvisioningProfile.plist...
Extracting &lt;span class="s2"&gt;"Entitlements"&lt;/span&gt; from ProvisioningProfile.plist and writing to Entitlements.plist...
Embedding &lt;span class="s2"&gt;"XC_iOS_comcompanyAnApp.mobileprovision"&lt;/span&gt; into &lt;span class="s2"&gt;"AnApp.app"&lt;/span&gt;...
Resigning &lt;span class="s2"&gt;"AnApp.app"&lt;/span&gt; with existing bundle identifier &lt;span class="s2"&gt;"com.company.AnApp"&lt;/span&gt;
Resigning embedded Swift libraries...
./libswiftCoreImage.dylib: replacing existing signature
./libswiftObjectiveC.dylib: replacing existing signature
./libswiftCore.dylib: replacing existing signature
./libswiftCoreGraphics.dylib: replacing existing signature
./libswiftUIKit.dylib: replacing existing signature
./libswiftMetal.dylib: replacing existing signature
./libswiftCoreData.dylib: replacing existing signature
./libswiftDispatch.dylib: replacing existing signature
./libswiftos.dylib: replacing existing signature
./libswiftCoreFoundation.dylib: replacing existing signature
./libswiftDarwin.dylib: replacing existing signature
./libswiftQuartzCore.dylib: replacing existing signature
./libswiftCoreAudio.dylib: replacing existing signature
./libswiftAVFoundation.dylib: replacing existing signature
./libswiftFoundation.dylib: replacing existing signature
./libswiftCoreMedia.dylib: replacing existing signature
./libswiftsimd.dylib: replacing existing signature
Resigning embedded frameworks...
./BarcodeScanner.framework: replacing existing signature
./SQLite.framework: replacing existing signature
Resigning &lt;span class="s2"&gt;"AnApp.app"&lt;/span&gt; with certificate &lt;span class="s2"&gt;"iPhone Distribution: AnOrganization"&lt;/span&gt;...
Payload/AnApp.app: replacing existing signature
Zipping app data into an .ipa...
Resigning successful. Resigned app to /Users/daniel/resign-ios-app/resigned.ipa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After a successful resigning, you'll notice some extra files in the folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls&lt;/span&gt; &lt;span class="nt"&gt;-l&lt;/span&gt;
&lt;span class="nt"&gt;-rw-rw-r--&lt;/span&gt;@ 1 daniel  staff  11506405 Nov 19 15:57 AnApp.ipa
&lt;span class="nt"&gt;-rw-r--r--&lt;/span&gt;@ 1 daniel  staff       228 Feb  4  2019 AppThinning.plist
&lt;span class="nt"&gt;-rw-r--r--&lt;/span&gt;  1 daniel  staff       517 Nov 22 18:29 Entitlements.plist
&lt;span class="nt"&gt;-rw-r--r--&lt;/span&gt;@ 1 daniel  staff      7354 Nov 19 10:26 XC_iOS_comcompanyAnApp.mobileprovision
drwxr-xr-x@ 3 daniel  staff        96 Feb  4  2019 Payload
&lt;span class="nt"&gt;-rw-r--r--&lt;/span&gt;  1 daniel  staff      3382 Nov 22 18:29 ProvisioningProfile.plist
&lt;span class="nt"&gt;-rw-r--r--&lt;/span&gt;  1 daniel  staff  11488043 Nov 22 18:29 resigned.ipa
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Payload&lt;/code&gt; and the &lt;code&gt;.plist&lt;/code&gt; files are artifacts of the script and can be deleted.&lt;br&gt;
&lt;code&gt;resigned.ipa&lt;/code&gt; should be good to deploy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tested
&lt;/h2&gt;

&lt;p&gt;I developed and tested this script on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;macOS 10.15.7&lt;/li&gt;
&lt;li&gt;Xcode 12.2&lt;/li&gt;
&lt;li&gt;GNU bash, version 5.0.7(1)-release (x86_64-apple-darwin16.7.0)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That being said, this script should work with macOS's built in version of &lt;code&gt;bash&lt;br&gt;
version 3&lt;/code&gt; and recent versions of macOS and Xcode.&lt;/p&gt;

&lt;p&gt;Please create an Issue against &lt;a href="https://github.com/danieltorrecillas/resign-ios-app"&gt;my repository&lt;/a&gt; for this solution if you can&lt;br&gt;
offer any improvements for more complicated resignings.&lt;/p&gt;

</description>
      <category>ios</category>
      <category>bash</category>
      <category>swift</category>
    </item>
  </channel>
</rss>
