Skip to main content

HTTP Connection problems on iOS 9 for Apps built with XCode 7 – How to fix that

Guess what? iOS 9 and XCode 7 are finally out, and – like almost always – there’s the usual number of breaking changes that will drive most developers mad. Among the biggest ones there’s the new Apple Transport Security (ATS) feature, which happens to be enabled by default starting from iOS 9.0 and OSX 10.11 and will basically block any non-HTTPS connection for your App.

Yeah, you’ve read it right. Here’s the Apple official statement about that:

It improves the privacy and data integrity of connections between an app and web services by enforcing additional security requirements for HTTP-based networking requests. Specifically, with ATS enabled, HTTP connections must use HTTPS (RFC 2818). Attempts to connect using insecure HTTP fail. Furthermore, HTTPS requests must use best practices for secure communications.

This will undoubtely translate into tears of joy for a lot of developers relying to home-made web services hosted on non-HTTPS environments or non-TLS based storage services (such as Amazon AWS).

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