Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I code sign an iOS .xarchive so a client can resign properly? (using push notifications)

I need to create an iOS .xarchive file using a developer profile, that a client can resign using their distribution profile(s).

(I have read this but it didn't have any real solutions: How can I send iOS app to client, for them to code-sign)

The client doesn't want to share their private keys, nor give me access above 'Developer' in the member center. And we don't want to share our source code.

We need to support push notifications, so this means we need a fully qualified app id.

I cannot figure out a way that allows me to build and export an .xarchive signed with 'aps production', 'get-task-allow' as false, BUT ALSO using the certificate that matches the clients distribution certificate.

This feels like a bug in Xcode, shouldn't the changes to 'aps production' and 'get-task-allow' be tied to the configuration, not the type of provisioning profile? I am using 'Release', but with my developer profile.

Am I missing something, or is this just not possible?

like image 201
pj4533 Avatar asked Mar 14 '12 18:03

pj4533


People also ask

How does Code Signing work in iOS?

Code signing your app assures users that it's from a known source and hasn't been modified since it was last signed. Before your app can integrate app services, be installed on a device, or be submitted to the App Store, it must be signed with a certificate issued by Apple.

How do I get a code signing certificate from Apple?

Generate a Code Signing Certificate manuallyOpen your Keychain Access app on macOS. Select Keychain Access > Certificate Assistant > Request a Certificate From a Certificate Authority... Fill in the User's Email Address and the Common Name and select Saved to Disk .

What do you need to do to integrate push notifications in an iOS app?

Setting up Push Notifications in iOS. Go back to the iOS project you created earlier and select the main target. Under the Signing & Capabilities tab, click on the + Capability button, then select Push Notifications. This will enable your app to receive push notifications from OneSignal.


1 Answers

I figured out the answer to this question through trial and error. Even though tech notes and most web resources say you don't need an entitlements.plist if you are using XCode4+, there are certain cases where you do. Two cases are represented by my question above:

  • building Release configuration (i.e.: Archive), but signing with a Developer provisioning profile
  • using push notifications

My final custom entitlements.plist has 3 values:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>get-task-allow</key>
    <false/>
    <key>aps-environment</key>
    <string>production</string>
    <key>keychain-access-groups</key>
    <array>
        <string>L23874DF.com.your.appid</string>
    </array>
</dict>
</plist>

Once I had that in my entitlements.plist, I built with the developer provisioning profile for this app id. Then I archived it, and exported the archive from the organizer. Once exported, I sent it to my client. The client was able to resign the archive with an ad hoc profile, and send me back an IPA file, which I loaded onto my device. I also successfully received a push notification from Urban Airship to this IPA!

like image 131
pj4533 Avatar answered Oct 04 '22 22:10

pj4533