XCode6添加擴(kuò)展找不到Application Extension?
要在已有的工程上才可以添加Application Extension柜与。不能直接新建工程的時候就添加Application Extension巧勤。
添加方法:File/new/Target
from: StackOverFlow
extension 去掉左邊的空白
A Today widget created using the Xcode Today template includes Auto Layout constraints for standard margin insets. To get the inset values for your calculations, implement the widgetMarginInsetsForProposedMarginInsets: method.
from: stackoverflow
-(UIEdgeInsets)widgetMarginInsetsForProposedMarginInsets:(UIEdgeInsets)defaultMa??rginInsets{
return UIEdgeInsetsZero;
}
更新extension 內(nèi)容
[[NCWidgetController widgetController] setHasContent:YES forWidgetWithBundleIdentifier:@"The bundle identifier of the extension."];
Both a widget and its containing app can use this method to specify whether the widget has content to display. The value of flag determines whether a widget should be visible in the Today view and whether the widget’s most recent snapshot is still valid.
打開 Containing APP
通過自定義 URL scheme
來打開Containing APP。
[self.extensionContext openURL:[NSURL URLWithString:@"你自定義的 URL scheme"] completionHandler:^(BOOL success) {
}];
extension 里面不能用 UIApplicaion
的API來打開URL
不能在 App Extensions 里面用的API
因?yàn)锳PP Extension是專注于某一項(xiàng)功能弄匕,所以它是沒有資格參與某些活動颅悉,app extenstion 不能:
- Access a sharedApplication object, and so cannot use any of the methods on that object
- Use any API marked in header files with the NS_EXTENSION_UNAVAILABLE macro, or similar - - unavailability macro, or any API in an unavailable framework
For example, in iOS 8.0, the HealthKit framework and EventKit UI framework are unavailable to app extensions.- Access the camera or microphone on an iOS device
- Perform long-running background tasks
- The specifics of this limitation vary by platform, as described in the extension point chapters in this document.
(An app extension can initiate uploads or downloads using an NSURLSession object, with results of those operations reported to the containing app.)- Receive data using AirDrop
(An app extension can send data using AirDrop in the same way an app does: by employing the UIActivityViewController class.)
extension 鏈接的Framework里面也不能有上述的API,不然會被AppStore拒絕的迁匠。
Tips
extension 不支持鍵盤輸入
用戶只能查看剩瓶,點(diǎn)擊按鈕,不能輸入(像回復(fù)信息什么的不行城丧,extension 的目的是展示最新的信息)
extension 必須支持arm64
包含app extension 的APP必須支持arm64 (iOS) or x86_64 architecture (OS X)延曙,否則會被AppStore拒絕
extension 支持
NSURLSession
后臺任務(wù)
extension 可以在后臺建立上傳下載任務(wù),但是不能在后臺播放音樂芙贫,撥打VoIP等搂鲫。如果在你的extension的Info.plist 添加了UIBackgroudModes,你的應(yīng)用將會被AppStore拒絕磺平。
extension的
targeted device
必須是 “iPhone/iPad” (sometimes called universal)
為了通過審核魂仍,你必須為你的extension的targeted device
指定為 “iPhone/iPad” (sometimes called universal) ,不管你的containing app的targeted device
是什么拣挪。
確保你的extension 的 targeted device
是“iPhone/iPad”的步驟
- In the Xcode project navigator for your keyboard project, select the project file.
If the project & targets list in the project editor is hidden, show it. To do this, click the button at the left of the project editor tab bar. - In the targets group in the project & targets list, select the target for your app extension.
- Choose the Build Settings tab in the project editor.
Ensure that the Basic and Combined buttons are selected, to make it easier for you to locate the settings you need here. - In the Deployment group in the project editor, view the Targeted Device Family setting. For both the Debug and Release configuration, the value should be “iPhone/iPad.”
If you find different values, correct them to be “iPhone/iPad.”