3

Xcode is behaving rather strange right now:

If I try to "Build for Archive" my app, the build process finishes without any errors or warnings. If I attempt to "Archive" though, it will throw a huge load of build errors at me. The errors (and the number of errors) are different every time I try.

The app still runs fine on the simulator and on the device. I have successfully archived the same app before, although the last successful archive was created using Xcode 4.0.1 (now 4.0.2).

Live update:

Amongst the mass of errors there is one recurring issue: It seems like the app's pch file (precompiled header file) can't be found. I suppose this is the root error for all of the other issues. The question remains why it can't be found while archiving, despite being perfectly available to all other build types (and even "build for archive")?

How can I overcome this error? If this is a bug in Xcode 4.0.2: Is there a way to archive a build without using the "Archive" option?

Edit: This may be another hint: Right after complaining that the pch couldn't be found, another error says "one or more PCH files were found, but they were invalid" - hokay...

Paul R
  • 208,748
  • 37
  • 389
  • 560
Toastor
  • 8,980
  • 4
  • 50
  • 82
  • I have the exact same error. I could archive fine under 4.01 until today's "upgrade" to 4.02. Now "Build for Archive" succeeds but "Archive" fails, with the same exact errors you have. I'm going to try a re-install of 4.01 – ChrisW Apr 20 '11 at 06:17
  • @ChrisW: I actually kind of "resolved" the error, which means I was able to archive successfully, however I don't know for sure why it worked. Have to finish something urgent right away, after that I'll try to find out what it was that made it work again and let you know immediately! – Toastor Apr 20 '11 at 07:02
  • Thanks @Toaster. I resolved the error on my system by deleting the /Developer directory and re-installing 4.01. Works fine, but I'd appreciate any learnings you found. – ChrisW Apr 20 '11 at 16:59

3 Answers3

1

Had a similar issue this morning building for my 4.2.3 device in XCode 4.0.2. Fixed it by running Clean, then building again.

A recent post has been made regarding this:

XCode 4 Archiving Error: one or more PCH files were found, but they were invalid

This may help you.

Community
  • 1
  • 1
MarkPowell
  • 16,482
  • 7
  • 61
  • 77
  • Well, try again! :) Sorry, got no other help. – MarkPowell Apr 19 '11 at 20:48
  • I did, again, and again, and again, and again... Do you happen to know how I can archive a build without relying on the archive option? building for archive succeeds, so all I need to do is wrap it up into an archive and put it into the organizer... – Toastor Apr 19 '11 at 20:53
  • Well, up until this point I thought build for archive and archive were the same thing. So, I don't know. – MarkPowell Apr 19 '11 at 21:08
  • I know this is old and I'm sure you are well beyond the issue, but updated with another solution posted elsewhere. – MarkPowell May 19 '11 at 19:05
  • I'm beyond this as far as occurrences of the problem itself are concerned - because it just didn't happen again, for whatever reason :) Since I lacked the opportunity to test any of the proposed solutions, I refrained from accepting one. But since yours (in the refined version) appears to be the best shot for anyone with the same problem, I'll accept it. Thanks again! – Toastor May 20 '11 at 13:19
0

Exit Xcode.

In Finder, go to ~/Library/Developer/Xcode/DerivedData.

Delete the folder under there that corresponds with your project name.

Restart Xcode: now Archive works.

Graham Perks
  • 23,007
  • 8
  • 61
  • 83
  • I tried this, and though the Archive Builds, nothing gets stored in the Archive Directory or shows up in the Organizer. – mda May 29 '12 at 02:29
0

I had a similar problem. Earlier I had an error about entitlements, so I found a solution that told me to create an Entitlements.plist file in my project, and that solved the problem. After adding devices to my Ad Hoc distribution provisioning profile and downloading/updating in XCode, it turned out that my Entitlements file had gotten truncated. Of course I didn't notice it until after 18 hours of angst and struggle! If you don't already, add a new file to your project. Under iOS, select Code Signing, and pick Entitlements, just call it Entitlements.plist.

Now on the Project (or Target) Properties, make sure you enter the file name in the Build Settings, Code Signing Entitlements setting.

This should work, it solved my issue. Wish I had noticed it had been truncated before spending many hours trying other more complicated solutions!

Jay Imerman
  • 4,475
  • 6
  • 40
  • 55