Tag Archives: Xcode

How to avoid “Capturing ‘self’ strongly in this block is likely to lead to a retain cycle”

I was trying to update a UILabel from inside a block the other day, and was puzzled by the above Xcode warning: “Capturing ‘self’ strongly in this block is likely to lead to a retain cycle”. The full code looked like this:

 

self.mainController.controllerPausedHandler = ^(GCController *controller){

        // triggers a warning
        [self displayMessage:@"Pause Button"];

    };

As it turns out, the trouble was that a block executed in self cannot capture a reference to itself (self) without there being a never ending loop involved. It’s probably to complicated for me to understand and/or care about, but thankfully there’s a relatively easy way to correct this problem.

Continue reading





How to fix “no rule to process file” warning in Xcode

The other day Xcode was trying to tell me that it had “no rule to process a file”. It was a simple readme file that I had created on GitHub and subsequently pulled into my working copy.

Even though the project compiled fine, if there is a warning we can eliminate, we definitely should. Turns out it’s easy fix this problem.

Click on your project in the Project Navigator (the blue item on the left where you see all your project files), then head over to Build Phases. You’ll find a section called Compiled Sources. Expand it to see a selection of files.

Select the one Xcode is complaining about and remove it by clicking the little minus sign at the bottom.

Screen Shot 2015-12-09 at 12.51.27

Build the project again and see that warning disappear for good.





How to build WordPress for iOS (2015)

WordPress-LogoThe WordPress for iOS project has changed and grown over the years. While it’s still Open Source, it’s not as easy as “checkout and deploy” anymore. You may encounter several pitfalls along the way.

At the time of writing, the current version of WordPress for iOS is 5.7, with 5.8 just around the corner. In this article I’ll show you how to build the project and deploy it on your own devices.

Continue reading





Getting started with Unit Testing in Xcode 7

Unit Testing, or XCTesting as it’s called since Xcode 5, is a process that lets us test several aspects of our apps. For example, we can see if methods have return values we expect, and if not, flag this up to us. Since Xcode 7 and iOS 9 we can even test user interface events too.

Testing has come a long way in Xcode, but it’s also long been a mystery to me. I decided to explore it and make some notes so I wouldn’t forget.

Turns out that Unit Testing isn’t actually that difficult a concept to comprehend, but it’s usually presented in a way that only those with an IQ of 1000 or greater would understand it. Apple’s new document called Testing with Xcode has certainly helped me understand the basics, which I’ll discuss in this article. Continue reading





Xcode: How to activate code completion for already completed methods

I really like the code completion feature in Xcode. It gives handy clues about the parameters of all methods and their parameters. But as soon as we hit return, the completion disappears. Sometimes I wish I could bring it back and re-read the descriptions.

Well I have great news: you can bring it back at any time simply by positioning your cursor on the method in question and hitting ESC as usual, or CTRL + SPACE. As soon as you’ve satisfied your curiosity, hit ESC to make it go away again.

Code-Completion

Thanks to Rainer Schwarze and mndgs for this tip!





How to increase the font size in the Xcode Debugger

Do the debug messages appear too small for your tired eyes? Fret not, you can change those to something larger if you like:

Head over to Xcode – Preferences and find the Fonts and Colors section. Switch to the Console Tab and select an option you want to change (typically Executable Console Output and Debugger Console Output appear in the debugger).

Now click the tiny little T icon at the bottom and change the font to something more palatable. The default font is Menlo 11.

Alternatively you can switch to either of the Presentation presets, which will increase the font size for the debugger and your code font (good for screencasts).

Debug-Output