What is the difference between Apple's iMessag

2019-05-07 01:28发布

问题:

I have noticed this different regarding the creation of messages apps for iOS 10.

If you create a new project using iMessage Application choice on the new project's template, Xcode will create two targets, an app and an extension.

but the project is not able to run.

(see by this second picture that there is only one choice on the target selector at the bottom and that target is the extension).

When you create a normal app, like a single view app and then add a target that is an app extension of the type iMessage, you will have two targets there, the app and the extension.

My questions are:

Xcode iMessage's template is in fact creating just an extension, right? Not an app plus an an extension, correct?

If this is true, why in heavens name is Xcode creating the app target? What is the purpose of having an app target that compiles and appears on the products section with the extension .app if that is not in fact an app and will never run?

Or is in fact the extension just like a "remote control" running the code that is on the app? This is confuse, because by mistake I dragged a lot of content to the project and marked both targets to have them and the final thing doubled size, because the assets were copied to both targets.

The final question is: what will be submitted to Apple, just the extension or both?

回答1:

My guess is to make the whole thing consistent. I mean when you do an other extension (keyboard, widget etc) this has to come with an app. Here the situation is a bit more complex, we can do an iMessage app that will run by itself, or as an extension of an existing app... So when they developed the SDK they had to keep both way, but that's just a guess :) Also I'm pretty sure that when submitting the iMessage app to the store, the main target will go with it, as it is the case with all other actual extensions.



回答2:

Just to clarify -- iMessage extensions created using the template do not appear on the home screen. They only appear in the Messages app. If you add an iMessage extension to an existing app using the "Add Target" menu in Xcode, you are embedding your extension in a host app which appears on the home screen.

From what I can tell the job of the "app target" is literally to just sit there and hold your product name. In Beta 1, I believe the target didn't even have build settings. As of now, it has build settings but no build phases, and I'm guessing it will stay that way.

It does, however, appear in the Products folder after building, which makes me think it will somehow get submitted to the app store with the extension. Regardless, if you make sure your files' "Target Membership" is only set to the extension you should avoid any unnecessary size increase.