iOS Today Extension created as .app rather than .appex

我的未来我决定 提交于 2019-12-06 14:48:22
ErmaCK

I had the same problem.

The following steps helped:

selected target Today Extortion -> Build Settings -> line Wrapper Extension add (change) value to appex

See:

I am herewith sharing the step and source code.

Step 1:- App extension must have a containing app - you can't just create an app extension to be downloaded from the store, first create a regular app to contain the app extension. For the sake of this demonstration just create a new single view project and leave it untouched. Go to File-> New-> Project and select Single view application under iOS -> Applications call it 'ExtendableApp'.

Step 2:- If you want to create your custom experience simply set your ExtensionViewController to inherit from UIViewController, Once your extension is activated all the regular viewDidLoad, viewDidAppear, etc will be called.

Step 3:- In your controller storyboard create outlets for button, I am herewith describing 3 buttons.

Step 4:- In ExtensionViewController.m write

- (void)viewDidLoad {
    [super viewDidLoad];
    self.preferredContentSize = CGSizeMake(self.view.frame.size.width, 60.0f);
    // Do any additional setup after loading the view from its nib.
}

Step 5:- I am assuming that you have set the outlets and IB Action of your buttons in extension storyboard

- (IBAction) mActionButtonTapped :(UIButton *) sender {
    switch (sender.tag) {
        case 0: {
            NSURL *url = [NSURL URLWithString:@"IDENTIFIER_1://"];
            [self.extensionContext openURL:url completionHandler:nil];
        }
            break;
        case 1: {
            NSURL *url = [NSURL URLWithString:@"IDENTIFIER_2://"];
            [self.extensionContext openURL:url completionHandler:nil];
        }
            break;
        case 2: {
            NSURL *url = [NSURL URLWithString:@"IDENTIFIER_3://"];
            [self.extensionContext openURL:url completionHandler:nil];
        }
            break;

        default:
            break;
    }
}

Step 6:- In your project write these code in appDelete.m

- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url {
    [self appExtensionCallBack:url.absoluteString];
    return YES;
}

- (void) appExtensionCallBack :(NSString *)urlString {
    if ([urlString isEqualToString:@"IDENTIFIER_1://"]) {

            [self.tabBarController setSelectedIndex:0];   
    } else if ([urlString isEqualToString:@"IDENTIFIER_2://"]) {

            [self.tabBarController setSelectedIndex:1];
    } else if ([urlString isEqualToString:@"IDENTIFIER_3://"]) {

            [self.tabBarController setSelectedIndex:2];
    }
}

Note :- I am using Tab Bar Controller in my project, You can give own respected controller.

- (void) moveToControllerScene {
        UIStoryboard *storyboard              = [UIStoryboard storyboardWithName:STORY_BOARD_IDENTIFIER bundle:nil];
        YOUR_CONTROLLER_OBJECT *obj           = [storyboard instantiateViewControllerWithIdentifier:@"YOUR_CONTROLLER_OBJECT"];
        [navController pushViewController:obj animated:YES];
}

Step 7:- For testing the Extension in real device you have to make a separate App ID and Provisioning profile. Delete appropriate provisioning profile in extension and ur project.

Same problem happened today when I created a Notification Content extension in an old project.(2016, Xcode8 iOS10)

Finally I found the cause:

"Wrapper Extension" in Build Settings of the project was “app”, and when the new target of extension was created, "Wrapper Extension” inherited from the project settings as “app”.

Clearing the project setting before adding an extention target will make Xcode creat an extention as “appex” automatically.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!