“This app contains an app extension with an illegal bundle identifier” issue

China☆狼群 提交于 2019-11-29 03:48:56

I ran into a similar problem with the Bundle identifier in a share extension

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.

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.plist instead 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 identifier of the app and extension:

 ERROR.com.myname.myappname

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.

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

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

cd ~/Library/Developer/Xcode/DerivedData
find . -name "*.appex" -exec rm -fr {} \;
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:

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

I was missing the "." before Extension

This also addressed a related to issue

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