xcode 无法分发Mac Catalyst扩展

eivgtgni  于 2023-05-19  发布在  Mac
关注(0)|答案(5)|浏览(133)

我成功地上传了一个带有多个扩展的应用程序到Appstore for iOS,但是当我尝试上传同一个应用程序到Mac AppStore(一个Mac Catalyst应用程序)时,我在两个扩展上从Xcode得到以下错误
错误ITMS-90355:“缺少信息plist值。在www.example.com的扩展Info.plist中未找到NSExtensionPrincipalClass的值MyApp.app/Contents/PlugIns/MyExtension.appex“
这些扩展是一个ShareExtension和一个ActionExtension,它们都有一个脚本文件,所以如果我在Info.plist文件中设置NSExtensionPrincipalClass键,我会在控制台中得到以下消息
无效配置:必须在扩展的Info.plist文件中指定NSExtensionMainStoryboard或NSExtensionPrincipalClass,但不能同时指定两者。
当然,扩展界面不会出现,什么都不起作用
有人知道怎么解决吗?
或者,也可以只在Info.plist文件中设置NSExtensionPrincipalClass键,然后以编程方式调用故事板文件?

y53ybaqx

y53ybaqx1#

等待苹果的回答,我已经想出了一个解决方案,包括 Package 故事板到一个新的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
bq9c1y66

bq9c1y662#

从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,没有任何问题!
我要做的就是在直播前查一下最新的细节……
试着相信!
让我知道你的印象

ttisahbt

ttisahbt3#

现在苹果已经解决了这个问题,我能够用扩展加载应用程序而没有问题。
[更新:问题未解决-查看评论]

htrmnn0y

htrmnn0y4#

我的方法是只使用一个简单的VC加载到代码中,然后VC容器实际上呈现我们想要的VC(从故事板加载)
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)
    }
}
u0njafvf

u0njafvf5#

在我的扩展中,我使用的是故事板,可以使用NSExtensionPrincipalClass而不是NSExtensionMainStoryboard吗?与此同时,我给苹果公司发了一份反馈

相关问题