WatchKit extension doesn't see updates to NSUserDefaults for App Group - iphone

I've seen a couple of questions on this, and tried all the answers provided, and this still isn't working for me.
I'm trying to share several small pieces of data (Strings and BOOLs) between my iPhone App and its WatchKit extension. (If it makes any difference, the info is being read by the GlanceController of the WK app)
Via the Developer site I created an App group (group.com.theYawns.Sorcerers-Apprentice). If I look at 'App IDs' there I appear to have two identical IDs for my app (com.theYawns.Sorcerers-Apprentice) plus one for the extension (com.theYawns.Sorcerers-Apprentice.watchkitextension). Each of these has 'App Group' enabled (for both Development and Distribution) and the app group is selected if I edit the App ID.
I've turned on 'App Groups' in capabilities for both the App and the Extension. A concern I have it that periodically -- several times a day but not every build -- if I go in and look at the Capabilities tab, I have a red exclamation point saying 'Add the App Groups' entitlement to your entitlements file. If I look at the entitlements file, the entitlement is there, and if I click 'Fix issue', the red exclamation point changes to a checkmark. But the fact this needs to be done multiple times per day concerns me that something is amiss.
I've refreshed my provisioning profiles under XCode preferences many times, and while I don't see an App Groups icon under entitlements, if I hover I do see app groups in the tooltip that pops up.
In both my app and extension, I get a reference to the user defaults via
NSUserDefaults *sharedAppDefaults = [[NSUserDefaults alloc] initWithSuiteName:#"group.com.theYawns.Sorcerers-Apprentice"];
I've also tried adding a [sharedAppDefaults synchonize] after each write and before my WatchKit attempts to read, just in case things weren't being flushed out. (Didn't make any difference).
My WatchKit extension bundle id is different from my iPhone App bundle id, which is one of the answers I saw on a different thread.
I've also added an NSTimer to refresh the glance every 10 seconds, so if there was a timing issue with picking up the changes, I would expect it to resolve itself after an update cycle or two, but it does not.
Really stumped ... seems others have had their issue resolved by answers from the other threads but none have worked for me.
Other threads I've searched include:
Why won't app groups work inside my WatchKit extension?
https://stackoverflow.com/questions/27047455/how-to-shared-storage-between-app-and-extension-with-app-group-and-
WatchKit NSUserDefaults and NSKeyedUnarchiver issue

OK, I found an answer in the Apple developer forums.
It appeared, from the XCode target 'Capabilities' tab, that I had all the correct entitlements set. And I could see the 'Entitlements' file in my project, open it, and see that it was set up correctly.
BUT -- if I looked under my App Target's 'Build Settings' tab, in the 'Code Signing' section, there was no entitlements file shown. (It all shows up correctly for the WatchKit Extension but not for the main iPhone app).
When I plugged in the name of my entitlements file under Code Signing, everything started to work.
This seems like a bug to me -- I don't believe the 'Capabilities' tab and the 'Build Settings' tab of the same target should ever be looking in different places for entitlements. But wanted to post the answer that worked for me here in case anyone else runs into this.
Summary: to make sure entitlements are correct, you have to see the switches set properly in Capabilities, AND you have to see the entitlements file referenced under Build Settings / Code Signing.

You have to add the entitlement to your provisioning profile of app extension.To do this, Login to your developer account to add the entitlements, after this download the latest provisioning profile. To verify whether the app group has been enabled or not , open the downloaded provisioning profile in "TextEditor" and search for "app group". This will show you the result, if you have done it properly. Use these newly downloaded provisioning profiles ,and it will show you the check mark in capabilities.

Related

Trouble publishing my app to appStore: entitlements, bundleID, plist...?

I am getting a number of errors with the ApplicationLoader. But it looks like I have done things wrong in XCode4.2.1 and possible with certificates or profiles. Last time I submitted an App was with Xcode3.2.6. Not sure what to do here with Xcode4.2.1? thanks
After working with things a bit I have gotten to this point:
-the referencing not sure of
-code signing, I thought the process of the certs/downloading/uploading to apples sight took care of this.
And now down to this:
The remaining problems are easy to solve.
First the Icon:
Make sure you have named your icons as
icon.png
icon#2x.png
Then on the appname-Info.plist there should be a key called
"Icon Files (iOS 5)"
with a subkey
"Primary Icon"
with a subkey
"Icon files"
and 2 subkeys
"Item 0" and "Item 1"
Item 0 value should be icon.png and item 1 should be icon#2x.png
For your second problem:
You have to specify what code signing profile you want to use.
For this select your app on the item inspector and under Targets select your app again.
Then under build settings, select All and combined.
Here just scroll down to "Code Signing"
The code signing identity MUST have the RELEASE value to the same profile that has been registered on the iTunes connect (the certificate that you got which has the rights to publish etc etc)
just click on the value and you should see many provisioning profiles. If the Provisioning profile has been installed correctly (the one that can sign for release) it should also appear there, just select it.
Repeat the process for the Project configuration (Under Project -> AppName).
Edit:
if you have Entitlements defined:
If you are defining a custom Code Signing Entitlements file within
your Target > Build Settings, you might try removing that
configuration entirely and rebuilding/resubmitting. More often than
not, Code Signing Entitlements are defined unnecessarily. You only
need to specify a custom Code Signing Entitlements file if your
application is utilizing custom keychain access sharing or iCloud.
Otherwise, remove the Code Signing Entitlements configuration from all
build configurations on your Xcode project's Target > Build Settings,
the rebuild and reattempt your submission/validation.
Regarding the code signing issue:
Try following this apple guide, it explains everything very detailed
https://developer.apple.com/legacy/library/technotes/tn2250/_index.html
Especially the How do I resolve the error: Application failed codesign verification? Section.

Error Validating and uploading App to iTunes Connect

This is driving me crazy. I've tried searching for answers and nothing quite matches my problem.
I've successfully archived my app and need to upload it to iTunes Connect. Apple recommends Application Loader but first needs to be done in Xcode. When I attempt to validate or Distribute the app in Xcode, I get an error saying "No Identities are available for signing"
I'm confused because I've wiped my certificates and profiles clean but I continue to get this message. Any ideas what I'm missing?
"No identities available for signing" can get frustrating. What you should do is regenerate your distribution certificate and profile, that should fix the issue.
If you need help regenerating: Download and open the new distribution certificate, which will store it in your keychain. Then, drag-and-drop the profile into your Xcode organizer. Next, your going to click on the project in the upper left (it has a blue icon next to it), that will bring up the projects info. There should be 2 tabs at the top of the screen, "Info" and "Build Settings". When you click on Build Settings, the option to change the code signing is about halfway down the screen. When I ran into this issue, I had to change every single one of the code signing options to iPhone Distribution. (It might not be necessary to change every field, but I did). You should be good to go after this, let me know if you have anymore issues.
I solved the problem by deleting ALL dev profiles and recreating a single provisional profile for Distribution and Developing each. Xcode then selected the profiles automatically without me having to import them into Xcode.

Validating app using validate in xcode - Errors found - Image provided

I got 2 errors when I tried to validate my app with the appstore.
How could I solve this ?
The approach i took to upload my build;
When I set Build configuration to Ad Hoc it Archives correctly (and displays in Organizer), but when I set Build configuration to Release, the archive file doesn't get displayed in the organizer. I have a different question on this on SO, but haven't got any replies yet.
So I clicked on the archived file (which was obtained after I set the Build configuration to Ad Hoc), and clicked on Validate.
Here is the screen shot, can someone tell me what I should be doing to get rid of this error ?
NOTE: Actually I know why the 1st error occurred, but I have no clue why the 2nd one occurred, and need guidance to solve it
SOLUTION TO ERROR-1:
Make sure your app icon is added to your project bundle and Also it is exactly 57 x 57 pixels PNG image.
SOLUTION TO ERROR-2:
Make sure you have set the Distribution Certificate and not Development Certificate in both Project and Target Settings.
You need to cross check it.
Also please cross check whether you are archiving the correct scheme, which you are setting the Distribution Certificate for.
EDIT FOR PRIVATE KEY ISSUE:
I have found louie's answer from the link iPhone app signing: A valid signing identity matching this profile could not be found in your keychain which was helpful to me once with same private key issue:
Here is what Louie's answer is:
I had the same problem: I first downloaded my certificates to my small
MacBook while on the run. When trying to install the certificates on
my iMac... then I ran into the problems described on this page.
After spending hours pulling my hair out like many of you, I performed
the following steps to fix it:
Close all your stuff except your webpage that should be logged into
App Dev center.
Open Xcode. Click WINDOW > ORGANIZER > select "Provisioning Profiles"
on the left. That should bring up your provisioning profiles.
Highlight one by one (if more than 1), right click and delete profile.
Yes, just do it! Delete them all! (I kept making a new one after a new
one trying to make the thing work.)
From the first page you see after logging into the App Dev Center on
the right side click "iOS PROVISIONING PORTAL" > (do not "launch
assistant"). Instead click on the left side. Select CERTIFICATES. You
will probably have just one line listed with your name/company - from
there click on the right side REVOKE. Click OK to verify that's what
you want to do.
On the same page click DEVICES. Click the box next to your device you
are trying to provision and click REMOVE SELECTED. Again click OK to
verify.
Wait about 2 minutes to let Apple do their thing.
Now click on "HOME" that is on the left side navigation.
Click "Launch Assistant"
create a new app ID - call it whatever you want. Just make sure it's
unique enough to know that's the one you just created because the
others you've been messing with all day will not be deleted from
Apples Dev Center.
You should be able to follow the rest of the Assistant without
troubles -- the main thing is you just had to delete your old
provision profiles and start over.
Hope this helps you.
Well... Your screenshot says that you have some problem with your icon and codesign verification.
Icon should be 57x57 pixel, put in your app bundle, correctly added to your target membership and set in your info.plist.
Then you need an iPhone Distribution Certificate from iOS Provisioning Portal.
If you checked icon and certificate and everything it's OK, maybe it is a problem in your uplader: I had same problem in the past (my icon was in my app bundle, but uploader wasn't recognizing it). Try software update to get latest uploader.

Generating an application bundle for submission with Xcode 4

Please help me export my application to iTunes Connect. I dont understand the documents, I have tried my best. I cant find the release of my .app, only the debug version.
I am using xcode 4. Also I dont know if I have signed the application correctly.
Here is a screenshot of my build settings, are these correct.
I setup a distribution certificate, an app ID with a wildcard mask, and a provisioning profile for the App Store, this provisioning profile is then imported into the organizer and on the screenshot below, you see I have assigned it to the Release build.
I cant find the release build at all on my system, only the debug file and would you say my certificates/profiles are set up currently.
Make sure you have configured the Archive panel for the scheme with the name of the archive to create
Then choose Product | Archive from Xcode's menu
Then have a look in your organiser's Archive section
And here are the docs you should be looking at.
First, make sure your Scheme is set to Release. Then, Build your app. If all goes well with no errors, you should be able to get your release build of your app in your Derived Data directory (this is the default Xcode 4 location).
If you don't see anything in Derived Data, check under Xcode->Preferences and go to the Locations tab. That will show you where your builds are going.
Unless I misunderstand the question, to send your app to iTunes connect from Xcode4 you choose Product -> Archive from the menu.
If your certs and IDs are correct, and they seem to be, then you will be shown the Archives view in the Organizer. Select the recent Archive and choose Validate.
If it validates, choose Submit. Your app should be submitted to iTunes Connect.

Build and Archive Option in XCode and Submit to iTunes

Although I have already submitted my app using Build And Archive and then clicking on the Submit to iTunes connect I will ask the question anyway. Apple says that select a Distribution profile when submitting to Apple. So, I went on iTunes and downloaded the Distribution profile. I added profile to xCode. I did the build and archive option then validated the application. Everything was validated successfully. Before submitting the application I noticed that there is a big question mark on the left hand side saying "Application Info". This is strange because I have already filled out all the name, description, version, keywords etc on the iTunes connect website. Anyway, I submitted the app and now it shows "Waiting for review".
Will the validation catch the exception if I try to submit the app for any profile other than the distribution? I am asking this because I have several profiles I created for BETA testing.
UPDATE 1:
One other thing I am noticing is that even though when I select the distribution profile and do build and archive. When I open the archive.plist file in the archive folder the XCProfileUUID value matches that of the Team Provisioning Profile and not to the distribution profile. Not sure what is that??
Validation does not check, to my knowledge, which profile you built & signed with. It only checks that you selected a valid profile.
You must ensure that you have selected your distribution profile under Project > Select Active Build Configuration. There are a number of other application settings you need to verify are filled out properly.
Apple provides a great step-by-step Howto in one of the tabs online where you create & download your Distribution profile. As long as you followed those steps & properly set the Build Configuration, you should be golden.
The validation would not have passed if it was incorrectly signed.
I don't know if it is too late to talk about a solution of the issue. Anyways, based on my personal experience, the big question mark in the "Build & Archive" screen indicates that you have not explicitly specified the icon name for the "Icon file" key in the info.plist file of your app. Don't worry, this issue only relates to the "Build & Archive" screen, and your submitted app is still as good without the explicit declaration of icon file, rest assured!