170

Archiving my project in Xcode is creating a multi-application bundle, instead of bundling my main target for release, which is what I want. Specifically, when I validate my archive in Organizer, it gives me the message:

"[projectname] does not contain a single–bundle application or contains multiple products. Please select another archive, or adjust your scheme to create a single–bundle application."

It sounds like there is some setting in the scheme that needs to be adjusted, but I can't figure out what's causing other targets to be included.

I'm using Xcode 4.0 by the way.

Pascal
  • 16,846
  • 4
  • 60
  • 69
Jared Friedman
  • 4,379
  • 3
  • 18
  • 9

5 Answers5

251

OK, answering my own question. Turns out it is an issue with dependent projects in XCode 4. If this happens to you, go through the Build Settings for all your dependent projects (e.g. static libraries) and make sure that the "Skip Install" option under "Deployment" is set to YES.

More detail here: http://flakasoft.com/developer-tips/xcode-4-bug-solution-for-archiving-build-with-static-library/

Tim Swast
  • 14,091
  • 4
  • 38
  • 61
Jared Friedman
  • 4,379
  • 3
  • 18
  • 9
  • 1
    You, sir, are my hero! I would not have found that easily :P – Andrew Natoli Mar 11 '11 at 05:23
  • 6
    Changed it to "YES" ... still failing. :( – Joe D'Andrea Mar 20 '11 at 16:49
  • 8
    Skip Install needs to be set to Yes on the static library only, not your Project or Target. This blog post on ad hoc distribution applies equally to app store builds and has a section on Skip Install: http://www.musicalgeometry.com/?p=1237 – jj0b May 02 '11 at 22:33
  • i'll second that Skip Install needs to be set to Yes on the static library only, not your Project or Target. – theiOSDude May 10 '11 at 10:02
  • 8
    Some libraries (like CorePlot) require you to change the Copy Headers section of their build phase, too. So make make sure you look at Ryan's answer, too. – Tim Swast Sep 04 '11 at 02:06
  • Thanks Jared! Just ran into this after opening an old Xcode 3 project in Xcode 4.2. This fixed it. – Héctor Ramos Oct 21 '11 at 16:23
  • That is the solution indeed! But the XCode generates a folder structure for me and there's a separate folder for my library (an .a file). Does this mean that the .ipa was compiled without the library? – Corvin Apr 23 '12 at 18:46
  • 2
    I also have to move all the header files (of the static library) in the Target "Build Phases", in "Copy Headers" I moved them from "Public" into "Project". – Hlung May 01 '12 at 10:26
  • I would have NEVER found this. Thanks for answering your own question once you figured it out! A lot of people don't do that - so thanks! – badweasel Jul 07 '12 at 08:02
  • You don't need to remove headers from the copy headers phase - simply under Packaging, set the Release value for Private/Public Headers Folder Path to an empty string - and that's it. – Charlie Monroe Apr 02 '14 at 12:40
  • An additional step which I found necessary was to Edit Scheme and under "Build" uncheck the box for "find implicit dependencies." – Fluffhead Sep 10 '14 at 19:53
151

Two things needed to be fixed in the sub-project(s) to resolve this issue:

  1. As Jared discovered, under the Build Settings, set the "Skip Install" to "Yes"
  2. Under the Build Phases, examine the Copy Headers section. If there are any header files listed as Private or Public, drag them down to the Project section.
Kirk Woll
  • 76,112
  • 22
  • 180
  • 195
Ryan Grimm
  • 1,972
  • 1
  • 11
  • 7
  • 5
    I fixed all the "Skip Install" settings but what I was missing was the Copy Header section, Thanks! – Thomas Einwaller Apr 26 '11 at 21:22
  • 2
    I'm using three20. This project has header files listed as Private or Public but if I move them in the project section it doesn't compile. Any suggestion? – Breezeight May 13 '11 at 15:43
  • 19
    Stop using Three20, even if you do get over this Xcode issue. I'm completely serious! – Adam Eberbach Jul 29 '11 at 06:27
  • 1
    @Breezeight: Did you ever manage to successfully create an archive for submission with three20? If so, would really appreciate if you could let us know how you resolved it as we're using three20 (unfortunately) in one of our projects and are unable to submit at this time. – gotnull Sep 09 '11 at 00:57
  • Ryan - nice one, you saved my a$$ when trying to make a build with Core Plot...thanks a bunch! – Jim Oct 05 '11 at 01:53
  • @Fulvio - by default three20 had its targets skip install set to YES - I didn't need to change anything on any of my three20 projects in 4.2. I also didn't need to move the public/private headers into project. – David Jan 05 '12 at 09:38
  • @Ryan: Sorry to say, but it didn't fix mine! I still get this warning in XCode 4.3.1. Previously it created the app correctly but now it doesn't! In every three20 Application i included in my project, is set the 'Skip Install' setting to YES and in my project i set it to NO (so it should create an App Archive, but it doesn't). When i move some of the three20 Public headers into the Project Section (in the Three20-subproject's buildphase) and when i try to create an archive than, it tells me that there is an error, but nothing specific! What am i doing wrong? – NicTesla Mar 12 '12 at 18:00
  • @Ryan: With previosly i meant with an older XCode version – NicTesla Mar 13 '12 at 09:14
  • 1
    @Fulvio: I think, you can only/simply get across this, by only using the source code of the three20 library! – NicTesla Mar 13 '12 at 16:11
  • I had this problem with a different cause: I had a target in my project (not the main target) that I created as a console tool, and Xcode had automatically created a man file for it and a copy-files build phase to install the man file in a public location (/usr/share/man). Once I removed this build phase, the error disappeared. – Colin May 02 '12 at 16:57
  • 2
    If you have numerous library projects like we do and having a hard time figuring out which library's Skip Install is set to No or which header files are causing the problem try this: Select the archive and click the Distribute button. Select the 'Save Built Products' option. Hit Next and Save. Browse the created directory in Finder. The 'libraries' subdirectory will identify the libraries that you need to set the Skip Install to Yes. The usr/local/include will identify the culprit header files you need to move from Public to Project. – Sunil Gowda Jul 09 '12 at 20:17
  • I'm wondering why this works for everybody, because, if I set the public headers of my static library to project, the app no longer compiles, because, well, the headers are no longer public. Do you all copy the headers into the app project? – Pascal Dec 11 '12 at 07:45
  • @gotnull so did you figure the three20 problem out? I tried moving the headers to project but then i'm getting compilation erros like everyone else – abbood Feb 27 '13 at 09:51
  • @NicTesla so did you figure the three20 problem out? – abbood Feb 27 '13 at 09:54
  • @abbood Yes, i fixed the compiler errors by removing the "three20" (or so) of every imported header in every file (also in the three20 classes). Eg: #import "tree20/TTCoreProcessMacros.h" to #import "TTCoreProcessMacros.h". It took very long, to manage all this (even though with a quick replace), but its the only solution, that worked for me! – NicTesla Feb 27 '13 at 11:59
  • @NicTesla you did the the two steps [above](http://stackoverflow.com/a/5318616/766570) as well to make it finally work right? also.. you're talkinga bout Three20* I mean that also would include Three20Core, Three20Network etc right? – abbood Feb 27 '13 at 12:25
  • @NicTesla tried that but didn't work.. at the end i just too three20 out as a subproject/static library from my main project and used cocoapods instead (see [answer](http://stackoverflow.com/a/15120289/766570) above).. – abbood Feb 27 '13 at 19:10
10

I did the following to make it work for me:

  1. for the three20 static library, I used cocoapods to include the files within the main project.. it just got rid of all the trouble three20 was giving me (and they are lots..) btw i tried replacing three20 with Nimbus.. but Nimbus was lacking on some of the features that my project was using three20 for.. so Nimbus wasn't helpful.
  2. set skip install to yes under build settings for all other sub projects/static libraries and switched the copy headers from public to project under build phases
  3. most importantly: under the sub libraries.. under build phases i ensured that copy files destination was changed from Absolute path to products directory.

and that was it!

hint: to get an idea of the offending files that's causing your archive to create an archive file rather than an ipa do this:

  1. Select the archive and click the Distribute button.
  2. Select the 'Save Built Products' option.
  3. Hit Next and Save.
  4. Browse the created directory in Finder.
  5. The 'libraries' subdirectory will identify the libraries that you need to set the Skip Install to Yes.
  6. in some cases usr/local/include will identify the culprit header files you need to move from Public to Project or the files that you have to change from absolute path to products directory. but that directory (ie usr/local/include) varies depending on your sublibrary directory structure
abbood
  • 23,101
  • 16
  • 132
  • 246
  • I would give you 10 stars, the nr of solutions i read till finding the one that helped. I just clicked on the files i found at step 6 and marked them in the target membership area from public to project, no need for anything. – Cristi Băluță Jun 13 '13 at 12:41
  • glad i could help! the reason i wrote it up was b/c i went through what you did.. i read like maybe 20 answers before i started understanding what was going on.. :) – abbood Jun 13 '13 at 16:21
  • Can someone please explain step 6? I don't understand what "usr/local/include will identify the culprit header files" means and where/how should i check those files – Andrei F Jan 13 '20 at 12:26
  • @CristiBăluță How exactly did you find the files and where in the settings/menus? I have the same issue with XCode 11.2.1 and I don't have much experience with xcode. Thank you. – Andrei F Jan 13 '20 at 12:37
  • What i found is that /usr/local/include is a folder inside the archive (along with libraries folder), but my generic archive doesn't have any of those – Andrei F Jan 13 '20 at 16:38
  • @AndreiF Unfortunately i'm looking at the message and have no idea what i was talking about, doesn't sound as something is intended we do. I saw this error over the years on mac apps with launchers and was because of the "Skip Install" option on the launcher. – Cristi Băluță Jan 17 '20 at 07:51
1

I had a copy files build phase I forgot about (copied some fonts into ~/Library/Fonts). After removing this build phase, it worked fine.

If none of the above answers fix the issue, I recommend exporting the archive to the finder and taking a look what's outside the .app bundle.

Edit: see https://github.com/RestKit/RestKit/wiki/Xcode-4-Archiving-Issue:--'Does-not-contain-a-single-bundle'

auco
  • 9,329
  • 4
  • 47
  • 54
0

i also had this same problem "[projectname] does not contain a single–bundle application or contains multiple products. Please select another archive, or adjust your scheme to create a single–bundle application." after upgrading to xcode5.

the problem was that a bunch of fields in my build settings for 'release' were blank. I guess xcode4 automatically switched to the debug setting.

anwyays - my fix was to find all those 'release' settings that were blank and set them to the debug setting. In particular it was the Info.plist file setting.

roocell
  • 2,429
  • 25
  • 28