91

I'm trying to build an extension project and Xcode keeps throwing the error in subject.

Xcode log error

Needless to day, the extension's bundle id is prefixed with app's bundle id.

Product Name: ro.chitza.TodayPics.$(TARGET_NAME:rfc1034identifier

Extension bundle id

I've tried cleaning the build folder and rebuilding, no luck. The funny thing is the entire project got built for a few times, but after some code and UI changes it started failing. Even if I create new projects, the same thing happens after about 5-6 builds.

Did anyone else encounter this error? Any hints for a solution or workaround?

Andrew
  • 15,357
  • 6
  • 66
  • 101
chitza
  • 1,434
  • 2
  • 11
  • 20

26 Answers26

69

For xCode v12 I solved that problem with one click:

TARGETS -> Build Phases -> Embed App Extensions

and check: Copy only when installing

enter image description here

Milovan Tomašević
  • 6,823
  • 1
  • 50
  • 42
39

It looks like the bundle ID behavior changed when WatchOS 2 arrived.

Previously I had an extension bundle identifier like this:

com.mycompany.myappname.watchkitextension

Somewhere else on Stackoverflow it was mentioned that the extension bundle identifier should be in this format, but no matter what I tried Xcode kept throwing errors at me.

The only possible solution is changing the extension bundle identifier to:

com.mycompany.myappname.watchkitapp.watchkitextension

I am pretty sure this wasn't the case with an WatchOS 1 app. A problem because of this change is that you can't actually generate an app id for the bundle identifier com.mycompany.myappname.watchkitextension. This isn't necessary, just set all provisioning profiles in the build settings to automatic and don't forget to use the right code signing certificate for you release/ad-hoc/debug schemes.

I actually found out that this approach works because Xcode suggested fixing the problem and this is what it did.

edwardmp
  • 6,339
  • 5
  • 50
  • 77
  • 1
    I tried this but now i am not able to submit to itunesconnect as i am getting error as no provisioning profile found having entitlement for app groups which is associated with my watchkit extension provisioning profile with previous bundle ID(com.mycompany.myname.watchkitextension)...how can we solve this issue & submit successfully to intunesconnect? – jayant rawat Jun 29 '16 at 13:03
  • Same problem here.. is there a fix? – Ramya Oct 21 '16 at 05:24
  • It fix my problem too, thanks this was not like that with first watchOS – Medhi Oct 16 '17 at 09:56
  • 1
    Worked for my iOS app widget/watch extension, thanks so much! – Supertecnoboff Dec 20 '18 at 15:07
  • This is what worked for me. I have dev and prod schemes so had to match the scheme bundle identifier in the widget extension. Thank you! – cherucole Apr 09 '23 at 08:13
32

Try a Clean before the Build. This fixed the problem for me (Xcode 6b2).

Julian
  • 1,573
  • 2
  • 22
  • 36
  • 1
    Problem solved with Xcode 6b2, builds just fine. Just that it crashes when launching the app :) – chitza Jun 21 '14 at 09:28
  • Running Clean fixed me similar issue; in my case, it was complaining about bundle identifier not being a subset of embedding application. – Mikrasya Dec 12 '14 at 06:38
  • This fixed my issue as well. – Dan Leveille Sep 08 '16 at 07:37
  • 2
    @chitza explicitly said "I've tried cleaning the build folder and rebuilding, no luck." I've run into chitza's issue as well and cleaning isn't fixing the issue in Xcode 9.3. – Michael Apr 01 '18 at 19:24
  • 2
    suggest delete the DerivedData, and Clean. The step below: Xcode File —> workspace settings —> click the direct button (Just Upside the Advanced button) go to /Users/{YourName}/Library/Developer/Xcode/DerivedData —> delete all the things below DerivfedData – Zgpeace May 24 '18 at 08:48
  • If this is a MacCatalyst and iOS extension, note that you might want to turn off the "Derive Mac Catalyst Bundle Identifier" to remove the `maccatalyst.` prefix. See https://developer.apple.com/documentation/xcode/preparing_your_app_for_distribution – ReinstateMonica3167040 Oct 04 '20 at 16:44
  • @Zgpeace has the right answer for me - nothing else worked but cleaning derivedData did the trick – Ali Oct 04 '22 at 08:33
25

I made changes like:

Main app bundle id: com.myapp.testapp

and

Extension app bundle id: com.myapp.testapp.myextension

and its works!!!

Sandip Patel - SM
  • 3,346
  • 29
  • 27
  • Do we need to have two bundle ids with two different provisioning profiles for main app and extension app? or Just have one bundle identifier for main app and then use same for extension app by just append .whateverextension to the main app bundle id? – Ganesh G Sep 18 '17 at 12:54
  • Yes Ganesh, we require two different provisining profiles for both main app and extension app if app has push notification functionality or else which require unique identifier. – Sandip Patel - SM Feb 07 '19 at 12:13
14

I had to manually change the BundleID in the extension's info.plist to what I needed.

I filed a radar : rdar://17487465

SushiGrass Jacob
  • 19,425
  • 1
  • 25
  • 39
  • 1
    Our build succeeded with this change. The BundleId in our info.plist file was `${PRODUCT_NAME}`. So for the OP's example, we'd instead use `ro.chitza.TodayPics.$(TARGET_NAME:rfc1034identifier)` for the BundleId in the extension's info.plist file. – Pete Aug 11 '14 at 00:45
  • @SushiGrass Jacob (Y) – iPC Dec 27 '16 at 13:13
14

Target->General-->Embedded Binaries delete the older and select the new this was how i solved this problem enter image description here

Michael Yang
  • 1,403
  • 2
  • 18
  • 27
13

this helped me:

The extension needs to have the parent's bundle ID as its prefix.

For example, if you app is com.ronnathan.myapp, your extension has to be com.ronnathan.myapp.today. You renamed the app target, now go into the extension target and change the name to match.

taken from here

dollar2048
  • 426
  • 6
  • 10
5

I got the same error, you probably add a extension like Today widget, since the extension is also a binary itself so it has its own plist, and make sure in extension's plist the bundle id is prefixed with app's bundle id. Hope this helps.

coolbeet
  • 1,645
  • 1
  • 18
  • 20
  • Unfortunately it does not help. I already stated it's an extension ("I'm trying to build an extension project") and that the bundle IDs are right ("Needless to day, the extension's bundle id is prefixed with app's bundle id"). – chitza Jun 13 '14 at 05:57
  • My extension has exactly the same id with the app, have you tried to clean the project? or delete the derived data? – coolbeet Jun 13 '14 at 18:59
  • 1
    Yes I did, unfortunately it didn't solve the problem: "I've tried cleaning the build folder and rebuilding, no luck" – chitza Jun 14 '14 at 06:23
4

In my case, this error occurred when I changed App bundle identifier. I also have WatchKit App in my project.

To fix this, update the WatchKit Extension and WatchKit App bundle Id prefix with the new bundle id of your app. Check info.plist in both targets.

Also update the following -

Update the following with the new Watch App bundle id. WatchKit Extension > Info.plist - NSExtension->NSExtensionAttributes->WKAppBundleIdentifier

Update the following with the new app id. WatchKit App > Info.plist - WKCompanionAppBundleIdentifier

After changing all the values don't forget to Clean product once.

Namit Gupta
  • 796
  • 9
  • 20
3

Make sure your:

Target App A -> Built Settings -> Code Signing -> Release

is the same with:

Target App A (Extension) -> Built Settings -> Code Signing -> Release

Santana
  • 232
  • 2
  • 11
3

It might have happened that you duplicated your targets to do a clone app. For instance you selected each of your targets and duplicated them. When you cloned your watchkit extension target its target membership could be automatically assigned to the original watch app.

To fix this, you would need to go to yours original "WatchKit extension.appex" file in Project Navigator and unselect Target Membership in File Inspector for your new clone watch app target. You should do the opposite for your duplicated "Watchkit extension-copy.appex" and make sure it has only duplicated "watch app-copy" target selected there.

Tomasz Zabłocki
  • 1,326
  • 7
  • 14
3

Xcode compile time error

error: Embedded binary's bundle identifier is not prefixed with the parent app's bundle identifier

Extension App[About] id should extend a Containing App id

//for example
//Extension App id
com.company

//Containing App id
com.company.extension
yoAlex5
  • 29,217
  • 8
  • 193
  • 205
1

I tried most of the solutions given here, but it did not helped me to fix the issue in Xcode 9.4

This SO Answer helped me fix the issue.

What i did is simply

  1. Unchecking the Automatically manage signing for all the targets and the project

  2. In code signing making it iOS Developer for all the targets and the project.

  3. Clean the project, then close the project and open it.

  4. Now Enable the Automatically manage signing for the target and choose the developer account. Then build it.

It fixed me the error. I don't know when Apple will fix these type of issues. It eats lot of hours.

Edit: I am using This answer too, That my target bundle id is com.companyname.projectname and for the extension bundle id com.companyname.projectname.myextension

R. Mohan
  • 2,182
  • 17
  • 30
1

The solution is already covered in a lot of answers:

Containing App Bundle Id: com.alphabet.gmail

and

Extension app bundle id: com.alphabet.gmail.notificationServiceExtension

But why should it be prefixed?

Because Apple wants communication between apps to be by the containing app's bundleId and avoid devs having to go around and send messages to the bundleID of the app Extension.

For example, your server must send a field named apns-topic to send a push notification to APNS so the app can download an image. The value of that topic is the bundleID.

But it's not the bundle ID of the service extension. It's the bundleId of the main app itself.

However on the actual physical phone, both the bundleIDs (com.alphabet.gmail.notificationServiceExtension and com.alphabet.gmail exist).

So how does the OS deliver the notification to the app extension and not the main app?

My understanding is that the OS looks for a target that:

  • Has a BundleId that is prefixed with com.alphabet.gmail example: Extension app bundle id: com.alphabet.gmail.notification
  • Has an NSExtensionPointIdentifier set to com.apple.usernotifications.service. You should not touch this value. It's just a pre-defined value by Apple.

enter image description here

mfaani
  • 33,269
  • 19
  • 164
  • 293
1

When I tried to set up two different environments, one for development and another for production, I faced the same issue. This happened because I was using the imageNotification extension. so I fixed it by adding the development bundle identifier to all Debug-dev, Release-dev, and Profile-dev then adding .ImageNotification .(the extension).

for example, this is the development bundle identifier: com.example.dev it will be com.example.dev.ImageNotification.

enter image description here

Amina Bekir
  • 220
  • 2
  • 9
0

The problem is likely that you added a folder using "Create folder references" when adding it to your project (like I did). @Jacob's fix didn't work for me :(

enter image description here

I had to delete the folder reference I added to my project, then clean and build, and that fixed it for me.

enter image description here

taber
  • 3,166
  • 4
  • 46
  • 72
0

I was having the same problems. Changing the CFBundleIdentifier for my WatchKit extension to something other than the original value used when I first added the WatchKit extension and re-setting my shared app group entitlement fixed it for me.

Ari Braginsky
  • 928
  • 1
  • 11
  • 21
  • changing bundle id is fine ...but my watchkit extension provisioning profile is having my old bundle id, so i am not able to submit my app to itunesconnect with new bundle id as i am getting error as no provision profile support application groups ..How did u reset ur shared group entitlement? – jayant rawat Jul 06 '16 at 06:34
0

I just clean derived folder and it helps me in these situations.

Alexander Khitev
  • 6,417
  • 13
  • 59
  • 115
0

Go to each target > Build Settings > Product Bundle Identifier > (Rename to whatever)

Marin
  • 12,531
  • 17
  • 56
  • 80
  • I had a workspace with multiple projects. Using Xcode's search function and the Build Settings search function, I was able to locate each instance that needed to be changed. Worked perfectly! – leanne Apr 11 '18 at 21:37
0

This was Helpful for me:

I was getting:

Xcode couldn't find any iOS App Development provisioning profiles matching

So I changed the Bundle Identifier name i.e com.example.something to com.example.something1, and then cleaned the build.

Make sure you change all the dependant bundle id as well..njoy!!

SherylHohman
  • 16,580
  • 17
  • 88
  • 94
Hitesh
  • 31
  • 1
0

Make sure bundle identifier of Extension have prefixed with app bundle identifier. If its same and still giving error, then go to the .plist file of Extension and change their Bundle Identifier.

Manish Mahajan
  • 2,062
  • 1
  • 13
  • 19
0

when we develop watch app then there is 3 target associate with the app. Their target must have the following style of bundle identifier.

  • The target for iPhone: com.company.app
  • The target for iWatch: com.company.app.watch
  • The target for iWatch Extension: com.company.app.watch.extension

In info.plist for watch target, it must have

WKCompanionAppBundleIdentifier = com.company.app

and in info.plist for watch app extension, it must have

NSExtension > NSExtensionAttributes > WKAppBundleIdentifier = com.company.app.watch

Rajan Twanabashu
  • 4,586
  • 5
  • 43
  • 55
0

It worked for me after deleting Onesignal runner

Imran Khan
  • 58
  • 1
  • 6
0

You usually get this when you have multiple targets.

First clean the build folder. If you don't have more than one target you should be ok.

If you do have multiple targets then in all your targets you should check that they all match the right naming convention.

for example com.YOURCOMPANY.YOURAPPNAME

Only one target should be named with this so choose your iOS target

Then all your other targets would follow

  • Mac target: com.YOURCOMPANY.YOURAPPNAME.Mac
  • Watch target: com.YOURCOMPANY.YOURAPPNAME.Watch
  • Widget target: com.YOURCOMPANY.YOURAPPNAME.Widget etc

It's too bad Xcode doesn't have one field to set the root but hey there is a bunch of things I would change in the Xcode project settings.

Richard Torcato
  • 2,504
  • 25
  • 26
0

The issue for me was in having widget's bundleId different than main target's one.
For example, I had:
bundleId: com.world.app
target bundleId: com.world.apps.widget (notice the s at the end)
After deleting s it compiled successfully because the bundle ids were matching.

stackich
  • 3,607
  • 3
  • 17
  • 41
0

My bundle id set in the extension was already correct (meaning it was prefixed with the app's bundle id). I've got it working by checking the Copy only when installing box, although the SwiftUI preview was still failing.

It turned out the Info.plist generated in the widget extension's folder by default only contains one property, which is for the NSExtension.

I just had to make sure to populate other values correctly which are normally part of a framework.

Info.plist should look like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>$(DEVELOPMENT_LANGUAGE)</string>
    <key>CFBundleExecutable</key>
    <string>$(EXECUTABLE_NAME)</string>
    <key>CFBundleIdentifier</key>
    <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>$(PRODUCT_NAME)</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>NSExtension</key>
    <dict>
        <key>NSExtensionPointIdentifier</key>
        <string>com.apple.widgetkit-extension</string>
    </dict>
    <key>NSPrincipalClass</key>
    <string></string>
</dict>
</plist>
iamszabo
  • 166
  • 2
  • 8