Archive for the ‘iOS’ Category

This error only came out recently and according to this post in stackoverflow, it seems a bug in Apple.

Thanks for bringing this to the attention of the community and apologies for the issues you’ve been having. This issue stems from having a copy of the expired WWDR Intermediate certificate in both your System and Login keychains. To resolve the issue, you should first download and install the new WWDR intermediate certificate (by double-clicking on the file). Next, in the Keychain Access application, select the System keychain. Make sure to select “Show Expired Certificates” in the View menu and then delete the expired version of the Apple Worldwide Developer Relations Certificate Authority Intermediate certificate (expired on February 14, 2016). Your certificates should now appear as valid in Keychain Access and be available to Xcode for submissions to the App Store.

Following Apple’s instruction, the error is resolved now.

Advertisements

I received this error after a XCode update recently (maybe they are not related).

To fix it, just remove the Apple account and add it again …

I have updated my app to support Share Extension and it requires share keychain between containing App and extension, so that I need create a keychain access group. The app was working fine in simulator, but it will crash with the above exception in a real device. When debugging, I found the reason code is -25243.

The keychain wrapper i was using is from this link. https://gist.github.com/dhoerl/1170641

After troubleshooting for a few days, i found that the reason is that I was accessing using the wrong keychain access group.

-25243 is related to keychain permission and I didn’t see this error in simulator because simulator app wasn’t signed

For the sake of context, i set the keychain access group in Target->Keychain sharing, then directly accessed the keychain with the group name.  This is wrong because the actual keychain access group should be $(AppIdentifierPrefix)whatever.you.set. You can find it from entitlements.plist.

I was writing a Share Extension which allows users to share a file to others. The extension will use loadItemForTypeIdentifier to fetch the file’s name and display it to the user. But users must always wait for a while before the UI is updated.

Thanks to this post, I found that it is because that UI wasn’t updated in the main queue. To fix it is very simple, just dispatch the ui updating to the main queue.

dispatch_async(dispatch_get_main_queue(), ^{
//Your UI updating logic
});

My new project requires to share Keychain among containing app and share extension. This requires the support of the keychain access group, which my current wrapper doesn’t support.

The iOS KeychainItemWrapper provided by Apple supports access group, but it doesn’t work in ARC. I found this from github which claims ARCified. https://gist.github.com/dhoerl/1170641

The library is very easy to use, but when i tried to retrieve the stored password, it always gave me NSZeroData. After some research, i found that I need convert NSString to NSData before storing my string data as KSecValueData.

//store value
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:KEYCHAIN_NAME accessGroup:KEYCHAIN_GROUP];
[keychain setObject:[password dataUsingEncoding:NSUTF8StringEncoding] forKey:(__bridge id)kSecValueData];

//retrieve stored value
KeychainItemWrapper *keychain = [[KeychainItemWrapper alloc] initWithIdentifier:KEYCHAIN_NAME accessGroup:KEYCHAIN_GROUP];
NSData *mySecureData = [keychain objectForKey:(__bridge id)kSecValueData];
NSString *password = [[NSString alloc] initWithData:mySecureData encoding:NSUTF8StringEncoding];

To keep it simple, one reason could be that you detached the view controller inviewDidLoad, instead ofviewDidAppear.

As the message described, you are trying to launch a view controller on top of the other one which has been removed from the window hierarchy.

The reason can be different. For example, one said the second view controller was pushed modally in viewDidLoad where the first view controller hasn’t added to window hierarchy.

In my case, it’s because of the unwinded segue triggered by UITextField.

My login view controller has two text fields (name and password) and a login button. The screen is designed in storyboard and when user click the login button, it will perform the login segue.

But I always see this warning: whose view is not in the window hierarchy when I set the segue as push modally. When i changed it to Show, the warning is gone, but the home view controller flashed twice.

So i suspected that it’s because the segue was performed twice.

To confirm the reason, you can override the function prepareForSegue and set the break point inside. I found the break point was hit twice and in the second time, the sender is UITextField.

Because I only perform segue programatically, the fix is very simple. Just override the shouldPerformSegueWithIdentifier and return NO because the programmatically performed segue won’t trigger this method.

-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender{
    return NO;
}