72

I am having a problem with ad-hoc distribution on my iPhone. I have developed an application with SDK 3.0. I have a developer's license. I have added certificates and provisioning profiles in my project. So, no problem with that.

But, when I try to install the app on my iPhone, it compiles the project and then displays the error: "The executable was signed with invalid entitlements" in the Organizer window. Am I missing something? I have upgraded my iPhone from 2.2.1 and have downloaded latest SDK from Apple.

Please help me with this issue.

YOU
  • 120,166
  • 34
  • 186
  • 219

19 Answers19

52

There are pretty good instructions in the 'Portal Program'. If you log into

http://developer.apple.com/iphone

Then click Distribution on the left, and click the

Creating and Downloading a Distribution Provisioning Profile for Ad Hoc Distribution

link at the bottom.

Here's the key bit:

For Ad Hoc Distribution, complete the following:

  • In the File Menu, select New File -> iPhone OS -> Code Signing -> Entitlements. Name the file “Entitlements.plist" and click ‘Finish’. This creates a copy of the default entitlements file within the project.
  • Select the new Entitlments.plist file and uncheck the “get-task-allow” property. Save the Entitlements.plist file. (in Xcode 4, get-task-allow is called "Can be debugged" )
  • Select the Target and open the Build settings inspector. In the ‘Code Signing Entitlements’ build setting, type in the filename of the new Entitlements.plist file including the extension. There is no need to specify a path unless you have put the Entitlements.plist file somewhere other than the top level of the project.
  • Click ‘Build’. (Note: Your binary must contain a flattened, square-image icon that is 57x57 pixels. This icon is displayed on the iPhone or iPod touch home screen.)
John
  • 1,549
  • 1
  • 13
  • 15
  • 1
    I was just going to write the same thing, it's easy to forget you need the get-tak-allow for ad-hoc in addition to store builds! – Kendall Helmstetter Gelner Jul 02 '09 at 16:44
  • This didn't work for me — it resulted in the same "invalid entitlements" error. But based on some comments below, I cleared everything, and then CHECKED (not unchecked) "get-task-allow", and tried again -- this time it worked. – Joe Strout May 25 '10 at 16:04
  • I had this same problem with an old project that I updated from git-hub, and checking that property (when I recall it was previously unset) also seemed to cure my issue as well. Strange. – TimM Jun 15 '10 at 03:53
  • 2
    Wow, that just saved me about 12 hours of head-banging. Thanks. – JayCrossler Jun 29 '10 at 14:03
  • 3
    Thanks for this, surprising how this stuff is so hard to find on Apple's site, it seems SO is a better resource. – KevinDTimm Oct 19 '10 at 12:28
  • @KevinDTimm Actually, it's not surprising. The documentation uses anchors very poorly and as a result, is not easily referenced by URI. That's why you see so many posts about provisioning and IOS on SO that describe going to a URI and then "click here, click there, click anywhere". I look forward to the day when Apple's documentation is not a walled garden. – David Watson Apr 03 '15 at 19:48
34

This error also may occur if you're trying to profile an app where the device is not included in the provisioning profile.

Make sure your device is included in the dev provisioning profile you want to use. Somehow the error message is misleading. My entitlements were actually ok.

TTT
  • 366
  • 3
  • 2
14

I have found that "get-task-allow" needs to be checked for Development builds but unchecked for Distribution builds. The easiest way to accomplish this (AFAIK) is to have two entitlements files in your project: Entitlements.plist and EntitlementsDebug.plist - and to reference the proper one in the build project settings for the various configurations in your project.

gumbypp
  • 159
  • 1
  • 2
6

Code signing entitlements are no longer necessary for Ad Hoc builds in Xcode 4 - see details notes in Apple Technical Note TN2250

Cœur
  • 37,241
  • 25
  • 195
  • 267
snibbe
  • 2,715
  • 1
  • 27
  • 34
5

If you once come into the situation, that checking "get-task-allow" seems to be required in order to deploy your debug (!) build to your phone, check this:

a) Check the build setting. There should be no entry in "Code Signing Entitlements" for Debug b) Remove Entitlements.plist temporarily and build your debug version. If it complains about a missing Entitlements.plist, then you probably have the same situation, I had to fight today. c) Build again with Entitlements.plist and enable "get-task-allow". If it works now, you probably have the same problem:

After messing around with new profiles I couldn't deploy my Debug build to the phone. AdHoc was fine. I checked a) - empty.. Hmm. I checked b) - complains. c) - worked...

After all I examined project.pbjproj in an editor and - although the GUI did claim, that there was no entry for "Code Signing Entitlements" in fact there was one in the Debug section. I emptied it and was done.

neil
  • 111
  • 1
  • 4
  • This worked for me. After I added an Entitlements.plist for AdHoc, xcode copied that requirement to my Debug and Release targets (although I did not enter that in the Build tab). After removing from the pbxproj file by hand, the Debug build works again. – thrusty Mar 17 '11 at 17:27
4

This is because your device, on which you are running your application is not selected with your provisioning profile.

So just go through Certificates, Identifiers & Profiles select your iOS Provisioning Profiles click on edit then select your Device

enter image description here

Rajneesh071
  • 30,846
  • 15
  • 61
  • 74
3

I have just had an exciting three hours battling with this. I have just upgraded a project to 4.2 and for some reason it just wouldn't work.

I eventually removed the Entitlements.plist file and then created a new one.

File > New File > Code Signing > Entitlement

Name the file Entitlements.plist

Make sure it's in the Resources group in xCode.

It didn't put in the get-task-allow BOOL type in the Entitlements.plist file. I added it, checked it, saved it, unchecked it, saved it. This made me feel better.

I then removed the Adhoc and Release profiles I had created. Re-downloaded them from the Provisioning Portal and droped them back into the xCode organizer.

I then went into Build Settings and made sure the correct profiles were assigned to the Debug and Release profiles.

I then changed the to Release / Device. Hit the build button and it worked.

I have no idea why.

Gerald
  • 31
  • 1
1

John's answer is 99% correct. I found that (at least in my configuration), you have to open the Build settings inspector for the PROJECT. The build settings for the target do not contain "Code Signing Entitlements". Perhaps this doesn't make a difference if you have only one target in your project. But if you have multiple targets, you need to go to the project build settings. In any case, after doing what John said, my ad-hoc distribution build worked perfectly.

iisystems
  • 1,089
  • 1
  • 11
  • 12
1

In Xcode 5.1, if you go into Preferences -> Accounts -> View Details...

Make sure the Signing Identity status is Valid. If it says Revoked, hit the Plus button and add the appropriate signing identity: iOS Development or iOS Distribution. Xcode will replace it with a new, valid one.

TalkLittle
  • 8,866
  • 6
  • 54
  • 51
1

For me that solved it: https://coderwall.com/p/-ckobg

  1. Open Project.xcodeproj > project.pbxproj
  2. Remove all lines like these:
    1. PROVISIONING_PROFILE = ...
    2. "PROVISIONING_PROFILE[sdk=iphoneos*]" = ...
    3. CODE_SIGN_IDENTITY = ...
    4. "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ...
  3. Set provisioning profiles & code signings for the target again
Robert
  • 431
  • 7
  • 19
  • This solved my problem. It was specifically the line `CODE_SIGN_IDENTITY = ...` that caused the problem. I have no idea when this was added by Xcode, or if I did it by mistake myself, but what a mess. Compared to other IDE's I have had so many weird problems with Xcode. I try to avoid it and stick to AppCode. – Tobiaswk Jun 26 '15 at 08:04
0

I was trying to add iCloud support to my existing app, but found that after adding entitlements and configuring iCloud, my app would no longer debug.

I realised that my generic iOS development certificate had a different APPID from the app I was working on. So to fix it, instead of using my generic certificate I created a specific development certificate for that APPID.

I refreshed my provisioning profile in XCode, cleaned out the app, disconnected my device, restarted XCOde and connected device and ran, and it now works a treat!

theDuncs
  • 4,649
  • 4
  • 39
  • 63
0

I also spent several hours fighting with this as well. The fix is real simple. Edit your Entitlements.plist file in the root of your project's directory. Find the line that says <key>get-task-allow</key>. Underneath it should be <false/>. Change that to <true/>.

Brian Knoblauch
  • 20,639
  • 15
  • 57
  • 92
0

Sorry that this is very late, but I just was looking at this question and found something that worked for me. I went to PROJECT->Build Settings and found the Code Signing section. Beside debug, my distribution profile that said Iphone Distribution: MY NAME was selected. I instead selected Iphone Developer: MY NAME on the drop-down list under IpodProfile (for bundle identifiers com.myName.myApp which was the provisioning Profile for my device. Hope this helps!

John Farkerson
  • 2,543
  • 2
  • 23
  • 33
0

I just had this happen to a developer on the team I administer.

It turned out his developer certificate expired and after renewal, I neglected to add his certificate to the provisioning profile his app used. enter image description here

sean808080
  • 242
  • 4
  • 13
0

I had not agreed to the new updated licensed agreement from apple.

Briefly : Please log in to your developer's account -> profile's -> review -> read the agreement or get your lawyer read it for you -> agree (at your own will) -> and again click profile's to check the status of your profile.

In my scenario the valid code signing entity was not showing up. When i followed the above procedure it was visible and i was able to run the app on the device and/or create the iPA file without much difficulty.

iCodeAtApple
  • 466
  • 5
  • 16
0

Had this issue occur when everything seemed to be setup correctly, build setting were pointing to correct provisioning profile, code signing was properly setup, etc.

Issue occurred because I had just created a new scheme and hadn't regenerated my CocoaPods for the new configurations. As you can see from the image, the new ad-hoc configuration is pointing to the Pods.production configuration, instead of a Pods.ad-hoc configuration (and test respectively)

Demonstrating a mis-match of ad-hoc configuration and scheme configuration

To fix:

  • Set the offending configuration to None -- cocoapods wouldn't generate the configs unless I did this
  • Close XCode
  • Run pod install
  • Re-open XCode and set the new scheme's configurations to the newly generated configurations.

That's it!

Gavin Miller
  • 43,168
  • 21
  • 122
  • 188
0

pJosh, this might help understanding. In my case, my Team Provisioning Profile was expiring (the Provisioning Portal indicated it is managed by XCode), as well as the device testing profile for the app. (I still don't know why, but the portal had a "Renew" button next to the team profile, but it wouldn't do anything when I clicked it.)

So, I deleted the profiles about to expire, then in XCode go to Organizer (Command-Shift-2), under Library / Provisioning Profiles, I deleted the expiring ones. Then click "Refresh" at the bottom, enter my Apple ID, and it renewed the expiring ones.

Finally, on my Target, I went to Build Settings, Code Signing, and made sure to select the provisioning profile. Voila, now it builds to my device.

Jay Imerman
  • 4,475
  • 6
  • 40
  • 55
0

Just got this same error code. It seems there are different things that cause this and therefore different ways to fix it.

In my case, I had two different devices with the same name (an iPhone 4 and an iPhone 4S). Changing the name of one of them fixed this error completely for me...

Andy Ibanez
  • 12,104
  • 9
  • 65
  • 100
-1

Check if you're device is included in the provisioning profile.

Steve Ham
  • 3,067
  • 1
  • 29
  • 36