0

I recently converted my iOS project to ARC. Now when I try to archive my app, the process hangs when/after compiling the last source file. In Activity Monitor two clang processes are almost on 100% CPU and I can't even switch off Xcode. If I set the Code Optimization Level to None everything works fine (which of course isn't a final solution).

Any suggestions how to solve this?

Till
  • 27,559
  • 13
  • 88
  • 122
Jochen
  • 606
  • 6
  • 23
  • Have you tried compiling a fresh, clean, blank project just to see if that works? If that doesn't work, it may not be project related. – Anil Jan 08 '14 at 16:30
  • if I compile the project on an old branch (without ARC) everything works fine. – Jochen Jan 08 '14 at 16:33
  • Sledge hammer :-) I have had this happen to me before and it is really annoying. I just shut the Mac down and went home for the night when I came in the next day it worked fine. My guess would be that it was just having a bad day and overheating or too many processes running and it just couldn't handle it. – Popeye Jan 08 '14 at 16:34
  • Archiving on a different Mac doesn't work either :-( – Jochen Jan 08 '14 at 16:35
  • Have you validated your project settings? Reference the "Project Modernization" section here: [What’s New in Xcode](https://developer.apple.com/library/ios/documentation/DeveloperTools/Conceptual/WhatsNewXcode/00-Introduction/Introduction.html#//apple_ref/doc/uid/TP40004635-SW1) – Anil Jan 08 '14 at 16:38
  • 1
    Did you try the sledge hammer? :-P – Popeye Jan 08 '14 at 16:44
  • @SlyRaskal Yes, Xcode says "Project Settings are valid" – Jochen Jan 08 '14 at 16:53
  • Do you have any symbolic links? Reference: [XCode hangs when archiving](http://stackoverflow.com/questions/9116934/xcode-hangs-when-archiving) – Anil Jan 08 '14 at 17:11
  • Also, have you tried cleaning your project before building? – Anil Jan 08 '14 at 17:12
  • I cleaned it and tested it on a newly installed Mac (so no symbolic links) - Thanks for your help by the way! – Jochen Jan 08 '14 at 17:17

1 Answers1

0

It turned out it was a retain circle in an animation block in ARC. Using weakSelf did the trick.

__weak __typeof(self) weakSelf = self;
[UIView animateWithDuration:0.3f
                      delay:0.5f
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     __typeof(weakSelf) strongSelf = weakSelf;
                     [strongSelf doStuff];
                     // ...
                 }
                 completion:^(BOOL finished){
                     // ...
                 }];

I figured this out by archiving the project via command line in verbos mode. It got stuck on one view controller which contained the retain circle.

Jochen
  • 606
  • 6
  • 23