Skip to main content

How to update your CocoaPod (when you forgot how to do it)

CocoaPod is wonderful but, let’s just face it, their documentation sucks. The whole guide website is mostly inaccurate and implies you already have an extensive know-how of their interface and terminology, which tend to be unfriendly and differ from almost any other developer environment, be it linux, windows or even mac. Hence why there is a recurring scenario, for me at least, when I have to create a new Pod – or update my existing one – and I simply cannot remember how to effectively do that. Not even a clue. Not at all.

That’s why I resolved to write it down, at least for the update process. Here it is, hoping to save someone else’s day other than mine. Read More

imageNamed not found and other Assets/Resource Files issues after creating a new CocoaPod library

Some days ago i wrote a post to announce that my DownPicker component library just became available on CocoaPods. Shortly after the pull of the refactoring I made to make everything compliant with the CocoaPods public trunk interface, some users noticed that the component – only when installed as a pod using the pod install  command –  was unable to properly display the embedded images. A strange behaviour indeed, since I had them included in the  /Assets/ folder, which path is obviously included in the wildcard reference i set to the resource_bundle  property of the  .podspec file:

After a quick check it turned out that the issue was related to the component code itself: the method I used to reference my image wasn’t referencing any bundle, expecting the resource files to be in the root path.

This is something that would work on a manually added component – such as it was until few days ago – but not for a CocoaPod.

Luckily enough, the fix was quite straightforward: all I had to do was creating a reference to the bundle itself and passing it to the imageNamed method using the additional overload which serves this exact purpose:

This small update can be used for any other asset / resource file not found, it won’t break your existing code and it will work even for manual installations. If you’re also facing a similar issue, chances are that it will save your day too.

Happy coding!

EDIT: just found this thread on StackOverflow containing an almost identical approach. You might want to check it out for future updates regarding this issue.

 

DownPicker: A lightweight DropDownList / ComboBox for iOS written in Objective-C

Quick links: Project Page – GitHub – Pod

Eventually, while developing in iOS, you’re going to find yourself looking for a control allowing the user to pick an option from a drop-down, selectable list of items: any UI has something like that: drop down lists, combo boxes, expand & collapse views or anything that could resemble the behaviour of an HTML <select>  element.

Problem is, iOS doesn’t feature anything like that. Except for the UIPickerView control, which often isn’t what we really need because of its excessive height and its heavy-impact look, which isn’t always as pretty as Apple designers thought it would be, at least in real-case scenarios. Conversely, we often need it to be simpler, taking less space and/or decently blending with other TextField elements.

 

UIPickerView in action: not always pretty.
UIPickerView in action: not always pretty.

With that thought in mind I pulled out DownPicker, an iOS control who can mimic the behaviour of a DropDownList/ComboBox using default iOS UI elements only: an UITextField to prompt the user to tap (and then show the selected item) and an UIPickerView to handle the selecting.

Read More

Objective-C: Programmatically set UIView alignment without using Storyboard

I recently wrote an article about removing Storyboards constraints programmatically. When you do that, you’ll often also want to replace the removed constraints with new ones: you can do that – programmatically as well – by using the addConstraint method, which allows to set one or more constraints between any two UIView items.

Let’s see some example by taking a standard UIButton item as the first object and its Parent View (or superview, as it is called by Objective-C) as the second one.

Read More

Objective C: removing UIStoryboard constraints programmatically

Since XCode made them available, Storyboards became a key concept for almost any GUI-oriented app: there’s nothing wrong about it – there isn’t a better way to design & arrange your views, objects and your whole UI in timely fashion. Expecially if you properly learn to use the Storyboard constraints, which are a powerful way to place your items around and ensure they’ll stay in their place.

Nonetheless, there could be situations where you need to programmatically remove the Storyboard-defined constraints: for example, if you need to change an item position right after an user interaction.

Read More

Close