Xcode 14 watchOS Error

Entry Point (_main) undefined for architecture x86_64, Anyone else getting this after updating settings request by xcode 14 and your watch app?

There are three possible solutions to this issue after upgrading settings to convert an extension based watch app to a single target watch app.

If you're using SwiftUI, and you're using App, then you need to annotate your App type with @main. For example:

@main
struct MyApp: App {
    var body: some Scene {
        WindowGroup {
            NavigationStack {
                ContentView()
            }
        }
    }
}

Otherwise, if you're using Swift, but not using App (for example if you're using storyboards or you are using a mix of storyboards and SwiftUI), then you need to annotate your WKApplicationDelegate type with @main. If you had an WKExtensionDelegate in your app prior to the upgrade, it should have been renamed to WKApplicationDelegate for you by the settings upgrade process (though in some cases this needs to be done manually). For example:

@main
class AppDelegate: NSObject, WKApplicationDelegate {
    ...
}

Lastly, if you're using Objective-C, then you need to add a main function which calls WKApplicationMain and passes in your delegate class type (which must conform to WKApplicationDelegate). For example:

#import <WatchKit/WatchKit.h>
#import "AppDelegate.h"

int main(int argc, char * argv[]) {
    NSString * appDelegateClassName;
    @autoreleasepool {
        // Setup code that might create autoreleased objects goes here.
        appDelegateClassName = NSStringFromClass([AppDelegate class]);
    }

    return WKApplicationMain(argc, argv, appDelegateClassName);
}

The settings upgrade process will try to perform these steps automatically, but can't handle all possible project structures. Please file a report via Feedback Assistant and attach your original Xcode project if possible, so that we can investigate why this project wasn't able to be fully converted automatically.

This worked to get it to build, i needed to hand add an extension delegate and the corresponding main / infoplist entries. but now when trying to run on a iphone simulator it says this. Feel as if im missing something else.

Please try again later. Found WatchKit 2.0 app at /Users/x/Library/xxxxxxDeveloper/CoreSimulator/Devices/E18868EE-130C-4159-AAF2-95319072DD5E/data/Library/Caches/com.apple.mobile.installd.staging/temp.JH6Xuf/extracted/Payload/TestingApp.app/Watch/TesterExt.app but it does not have a WKWatchKitApp or WKApplication key set to true in its Info.plist

I attached a sample project, clean xcode 13 ios app, added watch target, then opened up xcode 14 did the migration and doesnt run on ios simulator (seems to run on device though) so maybe its a simulator issue / check? FB10066285

I was getting the error after updating my project to consolidate watchOS app extension and app targets. Adding a WKApplication key to the watch app's Info.plist (type: boolean, value: 1) fixed this for me.

It points to a crash on @main on my AppDelegate class (WKApplicationDelegate). There isn't much in the debugger other than: Couldn't instantiate class _TtC30PDX_Transit_WatchKit_Extension23MainInterfaceController

Any ideas of where I can begin with this?

Xcode 14 Beta 3

We are seeing the same error message as @marioguzman. Info.plist contains WKApplication key entry set to YES in addition we have the Info.plist from the WatchExtension where the WKExtensionDelegateClassName is set with the value set to $(PRODUCT_MODULE_NAME).ExtensionDelegate.

The ExtensionDelegate looks as follows:

import SwiftUI

// ScenePhase observation doesn't work reliably
// https://developer.apple.com/forums/thread/650632
// Implement custom appDelegate and notiy about lifecycle changes
@main
class ExtensionDelegate: NSObject, WKApplicationDelegate {
    func applicationWillEnterForeground() {
        NotificationCenter.default.post(name: Notification.Name.willEnterForeground, object: nil, userInfo: nil)
    }

    func applicationDidEnterBackground() {
        NotificationCenter.default.post(name: Notification.Name.didEnterBackground, object: nil, userInfo: nil)
    }
}

And the watch app crashes at the @main with

Watch[71777:6577905] [default] -[SPRemoteInterface createViewController:className:properties:contextID:info:gestureDescriptions:clientIdentifier:interfaceControllerCreationCompletion:]:3230: Critical failure. Simulating crash: Condition failed:"NO". Couldn't instantiate class _TtC15Watch_Extension17HostingController

inline-codeAny solution for this issue team.

Xcode 14 watchOS Error
 
 
Q