[英]Can't distribute Mac Catalyst extension
我成功地將帶有多個擴展程序的應用程序上傳到 iOS Appstore,但是當我嘗試為 Mac AppStore(Mac Catalyst 應用程序)上傳相同的應用程序時,我在兩個擴展程序上從 Xcode 收到以下錯誤
ERROR ITMS-90355: "Missing Info.plist value. No value for NSExtensionPrincipalClass found in extension Info.plist
for MyApp.app/Contents/PlugIns/MyExtension.appex"
這些擴展是具有故事板文件的共享擴展和操作擴展,因此如果我在 Info.plist 文件中設置 NSExtensionPrincipalClass 鍵,我會在控制台中收到以下消息
Invalid Configuration: Either NSExtensionMainStoryboard or NSExtensionPrincipalClass
must be specified in the extension's Info.plist file but not both.
當然擴展界面沒有出現,沒有任何作用
有人知道如何解決這個問題嗎?
或者,是否可以僅在 Info.plist 文件中設置 NSExtensionPrincipalClass 鍵,然后以編程方式調用故事板文件?
謝謝大家
萬尼
現在 Apple 已經解決了這個問題,我能夠毫無問題地加載帶有擴展程序的應用程序。
[更新:問題未解決 - 請參閱評論]
等待蘋果的回答,我想出了一個解決方法,包括將故事板包裝到一個新的 AUViewcontroller。
1. include MyXib_Wrapper.h and MyXib_Wrapper.m
2. Add to AudioUnitInterface.storyboard the ID mainStoryID
3. Remove or comment the <AUAudioUnitFactory> from your derived AUViewController class
4. Update code in MyXib_Wrapper.m -> createAudioUnitWithComponentDescription according to your code (if you are performing more tasks)
5. Replace in .plist NSExtensionMainStoryboard with NSExtensionPrincipalClass
6. Sets MyXib_Wrapper for NSExtensionPrincipalClass and factoryFunction (very important!)
MyXib_Wrapper.h
#import <CoreAudioKit/AUViewController.h>
#import "AudioUnitViewController.h"
@class AudioUnitViewController;
@interface MyXib_Wrapper : AUViewController <AUAudioUnitFactory> {
AudioUnitViewController *vc;
}
@end
MyXib_Wrapper.m
#import "MyXib_Wrapper.h"
#import "AudioUnitViewController.h"
#import "MyAudioUnit.h"
@implementation MyXib_Wrapper
- (MyAudioUnit *) createAudioUnitWithComponentDescription:(AudioComponentDescription) desc error:(NSError **)error {
vc.audioUnit = [[MyAudioUnit alloc] initWithComponentDescription:desc error:error];
// perform here more tasks
return vc.audioUnit;
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"AudioUnitInterface" bundle:nil];
vc = (AudioUnitViewController*) [storyboard instantiateViewControllerWithIdentifier:@"mainStoryID"];
}
return self;
}
#pragma mark - View lifecycle
-(UIView*)view {
return vc.view;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.preferredContentSize = vc.preferredContentSize;
}
@end
從 Alessandro Petrolati 變通方法中汲取靈感,我想我找到了一個更簡單的解決方案,至少在我的情況下,它在兩個擴展中都能很好地工作。
1. Replace in .plist NSExtensionMainStoryboard with NSExtensionPrincipalClass
2. Update YourViewController.m file
將此 init 方法添加到您的 .m 類文件中
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"YournStoryboardName" bundle:nil];
self = (YourViewController*) [storyboard instantiateViewControllerWithIdentifier:@"YourStoryboardID"];
}
return self;
}
這似乎太容易了...
包驗證成功,我終於成功將應用程序上傳到 AppStore Connect,沒有任何問題!
我所要做的就是在我上線之前檢查最新的細節......
試着相信!
讓我知道你的印象
我的方法是只使用一個加載在代碼中的普通 VC,然后使用 VC 容器來實際呈現我們想要的 VC(從 Storyboard 加載)
info.plist 包含:
<key>NSExtension</key>
<dict>
<key>NSExtensionPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).PreviewVCLoader</string>
<key>NSExtensionAttributes</key>
<dict>
<key>QLSupportsSearchableItems</key>
<true/>
<key>QLSupportedContentTypes</key>
<array>
<string>com.hobbyistsoftware.jump</string>
</array>
</dict>
<key>NSExtensionPointIdentifier</key>
<string>com.apple.quicklook.preview</string>
</dict>
然后我的 PreviewVCLoader 類是
import UIKit
import QuickLook
class PreviewVCLoader: UIViewController, QLPreviewingController {
init() {
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
lazy var realVC:PreviewViewController = {
let board = UIStoryboard.init(name: "MainInterface", bundle: nil)
guard let vc = board.instantiateViewController(withIdentifier: "PreviewViewController") as? PreviewViewController else {
fatalError("Unable to instantiate storyboard in preview")
}
return vc
}()
override func viewDidLoad() {
super.viewDidLoad()
self.addChild(realVC)
realVC.view.frame = self.view.bounds
realVC.view.autoresizingMask = [.flexibleWidth,.flexibleHeight]
self.view.addSubview(realVC.view)
realVC.didMove(toParent: self)
}
func preparePreviewOfFile(at url: URL, completionHandler handler: @escaping (Error?) -> Void) {
realVC.preparePreviewOfFile(at: url, completionHandler: handler)
}
}
在我的擴展中,我使用的是情節提要,是否可以使用 NSExtensionPrincipalClass 而不是 NSExtensionMainStoryboard ? 同時,我已經向 Apple 發送了反饋,
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.