xcode “此应用包含具有非法捆绑标识符的应用扩展”问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28007290/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 06:30:28  来源:igfitidea点击:

"This app contains an app extension with an illegal bundle identifier" issue

xcodeios-app-extensionios8-today-widgetbundle-identifier

提问by kwmaeng

I'm a bit mixed up, since I changed the app name, Bundle Display name, and Bundle identifier name...and now my app works properly, but my today widget won't.

我有点困惑,因为我更改了应用程序名称、捆绑包显示名称和捆绑包标识符名称……现在我的应用程序可以正常工作,但我今天的小部件却不能。

Whenever I try to run today widget, it builds successfully, but instead of being launched, it says

每当我尝试运行 today 小部件时,它都会成功构建,但没有启动,它说

This app contains an app extension with an illegal bundle identifier. App extension bundle identifiers must have a prefix consisting of their containing application's bundle identifier followed by a '.'.

此应用包含具有非法捆绑标识符的应用扩展。应用程序扩展包标识符必须有一个前缀,由它们包含的应用程序包标识符组成,后跟一个“.”。

However, I checked Info.plist and my bundle identifier is

但是,我检查了 Info.plist 并且我的包标识符是

com.myname.myappname

com.myname.myappname

and my bundle identifier of my today widget is

我今天小部件的捆绑标识符是

com.myname.myappname.mywidget

com.myname.myappname.mywidget

Isn't this just right?? I cleaned and built again and again..but it just won't work.

这不是刚刚好??我一次又一次地清理和建造……但它就是行不通。

And NO GOOGLE RESULT! Am I the only person with this problem??

没有谷歌搜索结果!我是唯一有这个问题的人吗??

My bundle name is not 'myappname', if it is the problem.

如果是问题,我的包名称不是“myappname”。

Any help is appreciated.

任何帮助表示赞赏。

Something's gone bad and I don't know where to look!

东西坏了,我不知道去哪里找!

采纳答案by dougbeal

I ran into a similar problem with the Bundle identifierin a share extension

Bundle identifier在共享扩展中遇到了类似的问题

error

错误

app Info.plist: com.company.product.$(PRODUCT_NAME:rfc1034identifier)
ext Info.plist: com.company.product.$(PRODUCT_NAME:rfc1034identifier)

So I ended up with

所以我结束了

app Info.plist: com.company.product.product
ext Info.plist: com.company.product.product_ext

which passed the build checks but refused to run on a device with error:

它通过了构建检查,但拒绝在出现错误的设备上运行:

This app contains an app extension with an illegal bundle identifier. App extension bundle identifiers must have a prefix consisting of their containing application's bundle identifier followed by a '.'.

此应用包含具有非法捆绑标识符的应用扩展。应用程序扩展包标识符必须有一个前缀,由它们包含的应用程序包标识符组成,后跟一个“.”。

Once I removed the extra product, the build ran on a device.

一旦我删除了额外的product,构建就会在设备上运行。

correct

正确的

app Info.plist: com.company.$(PRODUCT_NAME:rfc1034identifier)
ext Info.plist: com.company.product.$(PRODUCT_NAME:rfc1034identifier)

app Info.plist: com.company.product
ext Info.plist: com.company.product.product_ext

I discovered my error when I accidentally changed the application Info.plistinstead of the extension Info.plist. To aid in debugging the problem, introduce an error into the application Info.plist, and you should get a build error with the Bundle identifierof the app and extension:

当我不小心更改了应用程序Info.plist而不是扩展名时,我发现了我的错误Info.plist。为了帮助调试问题,在应用程序中引入一个错误Info.plist,你应该得到Bundle identifier应用程序和扩展的构建错误:

 ERROR.com.myname.myappname

回答by JamesDill

If the selected answer doesn't work, I found what appears to be an issue in xcode switching between some target schemas which caused this.

如果选定的答案不起作用,我发现 xcode 在某些目标模式之间切换时似乎存在问题,这导致了这种情况。

In this case, try doing a complete clean, as well as a clean of the build folder (hold down ALT when selecting product/clean).

在这种情况下,尝试彻底清理,以及清理构建文件夹(在选择产品/清理时按住 ALT)。

Addendum:As this happens fairly often for me now, a quicker fix is to also remove all .appex files. Eg:

附录:由于我现在经常发生这种情况,因此更快的解决方法是同时删除所有 .appex 文件。例如:

cd ~/Library/Developer/Xcode/DerivedData
find . -name "*.appex" -exec rm -fr {} \;

回答by Azin Mehrnoosh

For me this due to the misnamed bundle identifier for my app extension. Similar to @dougbeal's answer, but slightly different formatting that worked for me:

对我来说,这是因为我的应用程序扩展的包标识符命名错误。类似于@dougbeal 的答案,但对我有用的格式略有不同:

com.company.AppName
com.company.AppName.Extension

I was missing the "."before Extension

我错过了"."之前Extension

This also addressed a related to issue

这也解决了一个相关的问题