3

I am trying to build share extension. Created the target, fixed the project settings (provisioning profile, app group, NSExtension).

Tried to run and saw the logs I added to the three methods isContentValid, didSelectPost, and configurationItems. This is my first time to create a share extension so, I was just looking around first and see when each method is called.

Now for some reason (I don't know what I did wrong), I am unable to see the logs from the extension. When I hit the run button in Xcode, the message Finished running ... gets displayed in the status bar on top.

Tried to change the scheme settings to the extension in the executable field, I get the following message when trying to run:

Could not locate installed application
Install claimed to have succeeded, but application could not be found on device. bundleId = <my-bundle-id-value>

Followed every solution I could find on the internet. Tried the solution from here and here.

UPDATE

I wanted to check if the extension actually runs or just the logs don't work. So I added the following logic to isContentValid:

- (BOOL)isContentValid {
    // Do validation of contentText and/or NSExtensionContext attachments here
    NSLog(@"isContentValid");
    NSUserDefaults * userDefaults = [[NSUserDefaults alloc] initWithSuiteName:@"<group-id>"];
    [userDefaults setObject:@"haha" forKey:@"key"];
    [userDefaults synchronize];
    return YES;
}

and read then read the haha in the main application it worked! So, the question is: Why can't I debug the application? Why doesn't the application print the log statements. Developing without logging and/or debugging could take 2x, if not more, time.

UPDATE 2

The best I was able to come up with is to manually attach the debugger to the extension, add breakpoints here and there (where I wanted to put logs) and edited the breakpoints to log as action and continue after evaluation.

joker
  • 3,416
  • 2
  • 34
  • 37

0 Answers0