Provisioning Profiles, certificates and such - objective-c

I'm trying to understand the whole provisioning-proccess, but I just don't get it..
I have tried to read up, but it's too weird and difficult for me to understand, especially when English is neither my primary or secondary language..
I have been developing for a while, and I remember stressing alot when setting up my iphone for development the first time. When I go into Settings->General on my phone I have 17 profiles, but at least I got it working in the end.
Now, I'm porting my app to iPad, and I'm trying to add my iPad to the table.
This is what I did:
I went to developer.apple.com, added my udid in devices, I then went to provisioning on the same webpage, and saw three profiles, one uneditable(controlled by xcode), one connected to my app's AppID, and one connected to myself as an AppID.
I added my new iPad-device to all three of them to be sure, and downloaded them again.
I dragged the .mobileprovisions to iTunes and to Xcode, and I went into organizer and clicked Refresh to update them. I clicked Use for development on my iPad, and it says it contains those profiles. They're also in Settings->General on my iPad.
In my XCode project, I go under Targets->Build Settings->Code Signing, and set one of my new profiles to Debug, and one of the other to Any iOS Sdk inside it. I've tried multiple combinations. I also went to Project->Build Settings->Code Signing and did the same thing.
When I run my app on my device, it pops up two of the same error message saying A valid provisioning profile for this executable was not found.
When I now connect my iPhone, which has been working perfectly fine all along, the exact same thing happens. Two of the same error message.
The question:
Which profiles goes where? What is the difference between the profile containing myself as an AppID and the one containing my actual app's ID as AppID? What is the difference between Target->Build Settings and Project->Build Settings when it comes to Code Signing?
Also, we spent a lot of time making push work, and out app is on AppStore rigth now, so I don't want to start deleting profiles and ID's, cause I think I read somewhere that that could make the notification stop working.
Oh, and I downloaded a new certificate as well at some point, containing the new profiles, and it ended up in keychain named along with 1000 others..
Help :( ?
Sorry for long and extremely boring/noobish question.

I think that your code doesn't build because of a certificate issue - like you said at the end of your question - you "downloaded a new certificate at some point containing the profiles..." You need to understand that a certificate does not 'contain' profiles, but profiles are created and signed using a specific certificate. Check that you have the private key of this certificate - if the signing request was not issued by you, it will require someone else exporting this certificate for you from his own keychain. Keep in mind that downloading the certificate available in your developer account will not suffice.
As for everything else:
Which profiles goes where?
Make sure you're creating relevant profiles with correct bundle IDs for your apps. Distribution profiles should include AdHoc and AppStore profiles, while Development profiles are, well, for development :)
What is the difference between the profile containing myself as an AppID and the one containing my actual app's ID as AppID?
Not sure what you mean here. Myself as an AppID? Each profile is linked to a specific App ID that has a bundle ID - it can be used to compile any app that has this bundle or any sub-domain of it in the info.plist of the project.
What is the difference between Target->Build Settings and Project->Build Settings when it comes to Code Signing?
You can think of your Project->Build Settings as the global settings and the Target->Build Settings as the target-specific settings. If XCode can't figure out which profile to use from the target settings, it will go and fetch it from the project settings.

The problem was that after we had released our app to the AppStore, we forgot to put the "Edit Scheme->Run" back to Debug from Release. This had no effect on my iPhone because I have added it to the release-provisioning-test thing.

Related

How to submit two copies of same iOS app to the itunesconnect (app store)

Thanks,
I want to upload the two copies iPhone application to the app store.
1) One with iwatch extension included.
2) One without iwatch extension.
If I include iwatch extension. I can't keep the deployment target below 8.0.
Is it possible and allowed by apple. can I keep the bundle identifiers same or I should change it?
Do I need to create two App IDs for the app?
Please help me with any other setting to change.
My deployment target without iwatch extension is iOS 7+.
Yes, that should be possible.
Note that you should change the Bundle Identifier as every app needs to have a unique one. I would also recommend to change the name (I believe you have to do that anyways) to show the users which one is w/ and w/o AppleWatch Extension.
Hope that helps :)
The answer is NO. You cannot have the same app in the AppStore that has the same bundle identifier.
Also, is there a real pressing need to have that backward compatibility (apart from wanting to have the greatest number of phones able to download your app)? Because if not, then maybe consider that deployment > 8.0 is enough.
Thanks a lot for suggestions and answers.
We can do it. These are the steps we need to follow.
1) Just we have to create new app id for the iPhone application with watch extension.
In case we are doing it manually.
2)we need to create two more app ids one for watchapp and other for watchkitextension as a target.
for eg. the app id is com.appname
The appid for the watch extension would be com.appname.watchkitextension
The app id for the watch app would be com.appname.watchkitapp
Both will be considered different app ids.
3) We need enable the all the three app ids with same App Group
4) keep deployment target of the watchextension and watchkitapp target as 8.2. And for iPhone companion app we can keep it 8.0
4) Generate the app store distribution provisioning provisioning profiles (can keep same distribution certificate) in case want to upload to the iTunes stores for beta testing or app review.
and We are done. This will successfully archieve the app bundle.
Another way. : Just don't do it manually and let Xcode handle it
Note : While developing app. When we add new target as watchkit. The new Xcode generates the app id for watch kit app and extension.
Just we can use it by refreshing provisioning profile from Xcode -> Preferences -> Accounts. Select Account and refresh. (Note : We need to configure the developer account with Xcode for that).
It will download and install the provisioning profile with Xcode.
And we can directly archieve the app bundle for app store submission by selecting the right provisioning profile

OSX Cocoa Bad Instruction crash

I am developing an app (for like a year) and it works fine , when it comes to submitting to App Store -> all my problems started:
1)The app store would me to make my app to run in a sandbox(Why Apple ? Why !?).
It took like 2 days to understand why just toggling "ON" in capabilities doesn't make it...
etc ... in the end I somehow managed to convince my app to run in sandbox.
2)now the app passing the validation fine and can be submitted to the bloody App Store
However when I checked the app before the submitting I discovered that it simply don't want to work (running from Xcode or product).
It just crashes before it comes to `applicationDidFinishLaunchingWithOptions"
The crash itself is even more epic "thread1: EXC_BAD_INSTRUCTION (code=EXC_i386_INVOP, subdued = 0x0)"
and I see a lot of assembly lines -> from the comments inside the assembly I understood that the app tries to "Open" a sandbox , but then comes the bad instruction :( ud2
The stuck I see is:
_libseinit_initialize_once
0 _libsecinit_setup_secinitd_client
1 _libsecinit_initialize_once
2 _dispatch_client_callout
3 dispatch_once_f
4 libSystem_initializer
5 ImageLoaderMachO::doModInitFunctions(ImageLoader::LinkContext const&) ()
I think the rest are not relevant since they are all about some IMAGE loader :/
lately I ensured that removing the app sandbox key or setting it to NO Resolves my Issue but if I do so i getting back to issue number 1
so I kinda stuck with an egg and a turkey problem :(
maybe some 1 knows any interesting workaround or solution to submit the bloody app to the mighty app store ?
Sounds like what Apple document here:
OS X’s enforcement of container integrity impacts your development and
distribution cycle. This is because, in the course of creating and
distributing an app, the app is code signed using various signatures.
Here’s how the process works:
Before you create a project, you obtain three code signing
certificates from Apple: a development certificate, a distribution
certificate, and (optionally) a Developer ID certificate. (To learn
how to obtain these code signing certificates, read App Distribution
Guide.) When used in conjunction with the corresponding private keys
from your keychain, these certificates form three separate digital
identities. For development and testing, you sign your app with your
development identity. When you submit a version to the app store, you
use your distribution identity. If you are distributing a version
outside the app store, you use your Developer ID identity.
When the Mac App Store distributes your app, it is signed with an
Apple code signature. For testing and debugging, you may want to run
both versions of your app: the version you sign and the version Apple
signs. But OS X sees the Apple-signed version of your app as an
intruder and won’t allow it to launch: Its code signature does not
match the one expected by your app’s existing container.
If you try to run the Apple-signed version of your app, you get a
crash report containing a statement similar to this:
Exception Type: EXC_BAD_INSTRUCTION (SIGILL) The solution is to
adjust the access control list (ACL) on your app’s container to
recognize the Apple-signed version of your app. Specifically, you add
the designated code requirement of the Apple-signed version of your
app to the app container’s ACL.
I also had this problem, and although Droppy's answer was correct, it doesn't really resolve the problem (at least, not for me).
After messing around a bit, I found that the reason I had this problem is that, (although I had disabled keychain sharing in 'Capabilities' in Xcode's project editor) I still had a keychain value added. Removing this, or completely disabling all app capabilities (yes, including sandbox) will solve this problem.
Hopefully, this saves someone some time in the future.

How to remove code signing in Xcode?

I've created an iOS7 project in Xcode 5. It's a very simple app. I zipped it and sent it to another developer. When they open it, they get these messages:
No matching code signing identity found
No code signing identities (i.e.certificate and private key pairs)
matching "iPhone Developer" were found. Xcode can resolve this issue
by downloading a new provisioning profile from the Member Center.
How do they get around this? The app isn't going to be submitted to the app store.
Is this happening because they have not linked Xcode to their online developer account? Isn't an online developer account free?
The other developer can ignore that message if the intention is to run the app on the Simulator. But you must use code signing in order to run an app from Xcode on a device, even for testing purposes, even if the app is never going to be submitted to the App Store. And that costs $99/year. End of story.
You could turn your account into a Company account and put this developer on your company; that way the developer is covered under your $99.
Or, if you just want to send the app to someone for testing and you don't need them to run the app directly from Xcode on a device, you can create an Ad Hoc build targeted to their device.
And of course the developer can look at your code, test on the simulator, and run your previously built Ad Hoc build on the device - but not run from Xcode on the device, i.e. the developer can not build for a device without someone paying that $99/year fee.

App Wireless Distribution not working in iOS7. Internet Connection needed?

In iOS6 I used to install some of my apps over an adhoc network without internet sharing. So the iPad had no internet connection. Therefore I use a typical html and plist file. Everything was alright.
Now, in iOS7 the installation is not working anymore. It is just stuck in "Waiting" and nothing more happens. (Note: It is still working on my iOS6 iPad)
First I thought something might be wrong with my plist, but then I copied the files to my IIS Server and installed it from there. Here I had a internet connection on my iPad and everything worked out.
Is it possible that the wireless distribution now needs an internet connection in iOS7 e.g. to check the ipa in the app store or something like that? Because this is the only difference I can see.
The app is signed with a valid distribution profile.
Thanks for your help.
It turned out the installation of apps over the air in iOS 7 really needs an internet connection now. The iPad tries to contact at least the following URLs before installing the app.
ax.init.itunes.apple.com: The device obtains the current file-size limit for downloading apps over the cellular network.
ocsp.apple.com: The device contacts this site to check the status of the distribution certificate used to sign the provisioning profile.
It seems in iOS6 it was ok if those URLs were not reachable and now in iOS 7 they have to be reachable.
Well i just had the same problem and I figured it out. At least on my xcode this is what happened. Turns out the application target release code siging identities auto set to developer and not their current state, from xcode 4.x, which is distribution. So when I went to distribute my application I kept getting the same error you had. So Click on your project name in your project explorer then click on the application target, not the project, and make sure the code signing identity is not set to developer for your releases. I have no idea why the code signing identities were automatically set to the developer profile, maybe there was some sort of bug when updating from xcdoe 4.x to xcode 5 that caused this. But now other devices are able to install the program. Hope this helps.

In-App-Purchase does not work anymore

I've recently (2 weeks ago) tested successfully the In-App Pruchase functionality with some iPad products.
After Apple has updated its License Agreement, it didn't work anymore on my iPad.
Even after agreeing this agreement, the functionality doesn't work. I read some posts (post1, post2, post3) and found out, that others came across this issue too. I tried everything described in the posts but nothing worked for me. I hard-resetted the ipad (Settings -> reset settings & data), i rebuild it a few times, i looked at the developer forum, if there where any issues posted, ..
It can successfully retrieve the product data, but when a payment will be added to the default payment queue following error is being returned in the TransactionObserver:
Error Domain=SKErrorDomain Code=0 UserInfo=0x2e09e0 "Cannot connect to itunes store"
I tested the same functionality on other iPhones and it worked (simply copied the classes from the iPad project to the iPhone project and created the dev. prov. profile).
To completely understand my situation, i had to renew my dev account and there i accidently renewed my certificate. So i created a new prov. profiles for my apps.
I than tested it on another iPad but it also didn't work. I also created a new provi. profile and a new product, cleard all and rebuilt it to test it on the ipad, but it always keeps returning the same error.
So it seems that the problem is in my iPad project, but what can i do? I copied the source code from Apples StoreKit Guide and modified it (a little bit) so it can manage the purchases with our server. I also changed the code sign identity (project and target) to build it with the correct dev. prov. profile. But what else can i do?
Please help!
Thanks & BR
Nic
Your provisoning profile is made for inapp ?
Sometimes the Apple sandbox server respons error but not during long period.
Are you unlog from your iTunes account in the iPad setting befor buy in your sandbox?
Now it works! It was a little bit unusual but it works!
I reviewed the provisioning profile. The certivicate was unchecked, so I rechecked it, downloaded it and installed (double clicked) it
Deleted the app and all installed porvisioning profiles from my ipad
Set the code signing identifier (in the target and the project setting) in the last hand in project (prev. version of the app) and rebuilt (clear all, build) it
Set the code signing identifier of the current project and rebuilt it
And the test in app purchase worked.
Hope it helps anyone!
BR
Nic