47

When I am try to submit my app to app store, I am getting the error:

ERROR ITMS-90685: "CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value com.companyname.projectName under the application ProjectName.app"

Can any one help me?

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Raju Abe
  • 735
  • 2
  • 10
  • 25

7 Answers7

48

Cause

It happens if your HostApp embeds a framework which has been also embedded in some of the frameworks which are also being embedded in HostApp. For example,

  1. Host H embeds framework F1 and framework F2
  2. Framework F1 embeds framework F2
  3. Thus, Framework F2 will be duplicated in bundle after IPA generated

Solution

Only HostApp but no other frameworks should embed any dependent frameworks in their respective Build Phase. So,

  1. Go to Build Phase tab for F1
  2. Remove F2 from Embed Frameworks step, or remove full step
  3. Go to General tab for F1
  4. Select Frameworks, Libraries and Embedded Content
  5. Select Do Not Embed option for F2

Have a clean build.

Community
  • 1
  • 1
Sazzad Hissain Khan
  • 37,929
  • 33
  • 189
  • 256
  • 1
    I did not need to make changes in Build Phase settings. I only needed to select the `Do Not Embed` option for all of the frameworks listed under `General` settings for each of my framework and app extension targets. – Robin Stewart Nov 11 '21 at 23:33
  • 1
    For me there is no option "Do Not Embed". I've adde amplify framework to my project using SPM. I need this in my share extension also so I went to share extension general and 'Frameworks and Libraries' and manually added the libraries. It builds and runs but cannot archive with collision error. The solutions here don't seem to work for me because I have no option 'do not embed' next to the libraries. – alionthego Dec 03 '21 at 22:48
  • 1
    This solution works for duplicated frameworks, but SPM dependencies end up being static libs, and you can't "not embed" those. – Rick Jan 12 '22 at 23:07
  • Is there also a solution for SPM / static libs? I ran into the same problem. – patrickS Mar 03 '22 at 10:36
23

Sometimes this doesn't have anything to do with App Extensions, in an app without any App Extension this can be originated because you're duplicating a framework inside the generated IPA.

In my case the issue was I was importing a framework A that contained other two frameworks B & C, all in the same workspace. In the app I was importing A, B, C but in the framework A the frameworks B & C were embedded with the Embed & sign and that's incorrect and it was causing the issue. It should have been added with the Do not embed.

Victor Sigler
  • 23,243
  • 14
  • 88
  • 105
  • 4
    You would have thought xcode would warn before uploading to itms stage! – Nick Hingston Oct 01 '20 at 14:49
  • Thanks, this answer was solving my problem! – mahega Feb 08 '21 at 14:32
  • 2
    I cannot set do not embed for xcframework and I am stuck. I use alamofire and ziparchive in the framework and in the app as well. do you have any suggestions? – jorjj Mar 04 '21 at 18:42
  • I'm running into this with dependencies that end up being static libraries, and you can't set those to Do Not Embed. – Rick Jan 12 '22 at 23:05
7

Steps without script:

  • Open the (Your App).xcodeproj file (this is the first file on the project navigator pane).
  • Switch to the target for your app extension (on the top left of the middle pane).
  • Go to the Build Phases tab
  • Click the X after "Embed Pod Frameworks"
Wojtek Dmyszewicz
  • 4,188
  • 5
  • 30
  • 42
5

This seems to be a long standing bug that is even present with Swift Package Manager. For the build phase of the extensions, I added this "Run Script" as the last step:

cd "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/"
if [[ -d "Frameworks" ]]; then 
    rm -fr Frameworks
fi

This removes the duplicate framework it's complaining about during archiving, which will be linked from the host target anyway. We just need it to be linked in Xcode for the extension so we can compile at development time.

TruMan1
  • 33,665
  • 59
  • 184
  • 335
  • Nothing else has worked for me so I'm trying this solution for a package added using SPM but I've never used scripts before. So I went to my extension Build Phases pressed the plus to add run script and pasted your above code unchanged. But error is still there. Is there something more I need to do to add this script? – alionthego Dec 03 '21 at 22:52
  • This script does not work for me neither. Maybe there is some mistake? – Oleg991 Jan 14 '22 at 11:09
4

Have you got an App Extension in your app? I had this error because of Cocoapods embedded frameworks inside App Extension folder.

You need to remove build phase '[CP] Embed Pods Frameworks' from Extension target.

I wrote such ruby script for that:

# remove.rb
require 'xcodeproj'

project_path = "Keyboard.xcodeproj"
project = Xcodeproj::Project.open(project_path)
project.targets.each do |target|
    puts target.name
    if target.name.include?("Extension")
        phase = target.shell_script_build_phases.find { |bp| bp.name == '[CP] Embed Pods Frameworks' }
        if !phase.nil?
            puts "Deleting Embed Pods Frameworks phase from #{target.name}…"
            target.build_phases.delete(phase)
        end
    end
end

project.save

In CocoaPods 1.1.0 that should be fixed: https://github.com/CocoaPods/CocoaPods/issues/4203

Gleb Tarasov
  • 885
  • 11
  • 15
1

If you have an App Extension, make sure it's bundle identifier is distinct from your app's bundle identifier.

Example:

Does not work

App Bundle Identifier: company.myApp  
Extension Bundle Identifier: company.myApp

Works

App Bundle Identifier: company.myApp  
Extension Bundle Identifier: company.myApp.extension
Tim Isenman
  • 147
  • 10
  • Hi @Tim Isenman, say the extension bundle identifier is com.xyz.abc , what is your suggested "Works" Extension Bundle Identifier? I've tried com.myapp.xyz.abc and iterations and can't get it to work – Sergio Solorzano May 19 '20 at 11:34
1

For Frameworks managed by SPM

The solution is to create a shared Framework. Create a Framework in Xcode and move all the shared (static) SPM dependencies to the shared framework you just created and remove all of them from any other targets you've previously added to. And then add the new framework you just created (Shared framework) to the targets that need them. Make sure to select Do Not Embed. and in the host app Embed and Sign

bona912
  • 589
  • 2
  • 6
  • 14