Sharing UserDefaults between extensions

You cannot use UserDefaults.standard to share data between a host app and its app extension. You instead have to create a shared container with UserDefaults(suiteName:) to share data. Even though an app extension bundle is nested within its containing app’s bundle, the running app extension and containing app have no direct access to each other’s … Read more

“Do Not Embed”, “Embed & Sign”, “Embed Without Signing”. What are they?. What they do?

As already stated by @przemyslaw-jablonski, this is similar to what was in XCode 10, but in only one screen (which I personally like!). Embedding Do not embed static frameworks and libraries (linking happens at build time), only shared ones (dynamic linking happens at run time, so they need to be in your bundle). file frameworkToLink.framework/frameworkToLink … Read more

Sharing data between an iOS 8 share extension and main app

You should use NSUserDefaults like this: Save data: objc NSUserDefaults *shared = [[NSUserDefaults alloc] initWithSuiteName:@”group.yougroup”]; [shared setObject:object forKey:@”yourkey”]; [shared synchronize]; swift let defaults = UserDefaults(suiteName: “group.yourgroup”) defaults?.set(5.9, forKey: “yourKey”) Read data: objc NSUserDefaults *shared = [[NSUserDefaults alloc] initWithSuiteName:@”group.yougroup”]; id value = [shared valueForKey:@”yourkey”]; NSLog(@”%@”,value); swift let defaults = UserDefaults(suiteName: “group.yourgroup”) let x = defaults?.double(forKey: “yourKey”) … Read more

openURL not work in Action Extension

This is what I used to do: UIWebView * webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)]; NSString *urlString = @”https://itunes.apple.com/us/app/watuu/id304697459″; NSString * content = [NSString stringWithFormat : @”<head><meta http-equiv=’refresh’ content=”0; URL=%@”></head>”, urlString]; [webView loadHTMLString:content baseURL:nil]; [self.view addSubview:webView]; [webView performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:2.0]; Please note that in this case I am instantiating this call from the … Read more

iOS 8 Custom Keyboard: Changing the Height

This is my code on Xcode 6.0 GM. Both orientations are supported. Update: Thanks to @SoftDesigner, we can eliminate the constraint conflict warning now. Warning: XIB and storyboard are not tested. It’s been reported by some folks that this does NOT work with XIB. KeyboardViewController.h #import <UIKit/UIKit.h> @interface KeyboardViewController : UIInputViewController @property (nonatomic) CGFloat portraitHeight; … Read more

Communicating and persisting data between apps with App Groups

Another benefit to App Groups is the ability to share a NSUserDefaults database. This also works for App Extensions (notification center widgets, custom keyboards, etc). Initialize your NSUserDefaults object like this in all applications in the app group and they will share the database: Objective-C: [[NSUserDefaults alloc] initWithSuiteName:@”<group identifier>”]; Swift: NSUserDefaults(suiteName: “<group identifier>”) Keep in … Read more