-
Send data Between iOS Apps and Extensions Using Darwin Notifications
Aug 27, 2024 • notifications • swift, xcode, xcode16, darwin notifications, CFNotificationCenter
In iOS development, app extensions run in separate processes from their containing apps. This separation poses a challenge when you need to communicate between the main app and its extensions. While
NSNotificationCenter
is a common choice for passing data between view controllers within the same app, it falls short when it comes to inter-process communication. Have you ever thought about how to pass data between the main app and its extension? Darwin notifications provide a powerful solution for this scenario. In this post, we’ll explore how to implement a Darwin Notifications manager and use it to facilitate real-time data transfer between a main app and its extension. -
SwiftUI in 2024: Bridging Perception and Reality
Aug 15, 2024 • WWDC24 • swift, xcode, xcode16, ios simulator, apple silicon, wwdc24, ios18, swiftui
I recently spoke at iOSKetchup2024 hosted by Zomato x Blinkit about the challenges and opportunities of using SwiftUI. The audience seemed to enjoy the session as much as I did! Here, I’m excited to share my experience and provide a detailed write-up of my talk.
-
From viewWillAppear to viewIsAppearing - Perfecting Your iOS View Transitions
Nov 30, 2023 • WWDC23 • swift, xcode, xcode14, ios simulator, apple silicon, t2 processor, wwdc23, ios17, viewIsAppearing, viewWillAppear
In WWDC23, Apple introduced a nuanced addition to the UIViewController lifecycle:
viewIsAppearing
. This instance method is a game-changer for developers looking to fine-tune the presentation and layout of their views. Let’s explore how this method enhances the way we build responsive and dynamic interfaces. -
Exploring the New Push Notifications Console from Apple
Jun 19, 2023 • WWDC23 • swift, xcode, remote push notifications, xcode14, ios simulator, apple silicon, t2 processor, wwdc23, push notification console, ios17
Apple has recently unveiled a powerful new tool for developers: the Apple Push Notifications Console. This innovative console simplifies the task of sending test notifications to Apple devices using the Apple Push Notification service (APNs).
-
How to send Remote Push Notifications to an iOS Simulator with Xcode 14
May 28, 2023 • Debugging • swift, xcode, remote push notifications, xcode14, ios simulator, apple silicon, t2 processor
In the past, testing push notifications on iOS simulators was quite challenging due to certain limitations. Prior to Xcode 14, receiving push notifications in a simulator was not possible and developers had to rely on local simulations using
.apns
payload files and thesimctl push
command. We have already seen how to simulate push notifications in a simulator in the article, Simulating remote push notifications in a simulator
However, Xcode 14 allows iOS simulators running on macOS 13 on Macs with Apple silicon or T2 processors to receive remote push notifications just like a physical device. -
How to Instantly Track a Variable's Value Changes with Xcode Watchpoints
May 26, 2023 • Debugging • swift, xcode, track variable value changes in ios, track variable value changes in swift, watchpoints, breakpoints, debugging, llvm
In the world of programming, tracking variable changes can often turn into a debugging nightmare. In Xcode, you might find yourself frequently relying on breakpoints and manually tracing the changes in your variables’ values. At times, you might also utilize property observers such as
didSet
andwillSet
for this purpose.
But what if I tell you, there’s a powerful tool waiting for you to harness its capabilities: Watchpoints. They allow you to monitor a specific variable or memory address for changes, providing invaluable insights into your program’s execution. -
How to add a loader to an UIButton
Aug 28, 2022 • UIButton • add loader to an uibutton, swift, UIButton, iOS15, UIButtonConfiguration, ios15 button configuration, swift ios 15, customizing uibutton in swift, swift uibutton, implementing button in swift
Sometimes, we would require a button to show a loader with appropriate text when a long-duration task is done, such as downloading an image. Before iOS 15, we had to write a custom button or do some hacks to show a simple loader or an UIActivityIndicator inside an UIButton. Now, it is not the case anymore. UIButtonConfiguration provides
showsActivityIndicator
, a simple property using which we can hide/show a loader inside a button. -
How to filter screenshots, cinematic videos, and depth-effect photos in PHPickerViewController
Jun 26, 2022 • PHPickerViewController • swift, imageassets, phphotopickerviewcontroller, uiimagepikcercontroller, images, phpicker, photolibrary
In iOS 14.0, Apple introduced a new way to pick images from the device’s photo library using PHPickerViewController. (If you are not aware of PHPickerViewController, I strongly recommend you to read about PHPickerViewController first.)
-
Implementing a custom native calendar using UICalendarView in iOS16 and Swift
Jun 12, 2022 • UIKit • swift, UICalendarView, FSCalendar, customize calendar in iOS16, iOS 16, calendar view, single select calendar, multi select calendar, swift calendar implementation
It was WWDC22 week, and I was browsing through my Twitter feed to get some updates about the latest Apple APIs. A person tweeted, “No matter how experienced you are as an iOS developer, you’ll always look it up how to set up a date formatter.” So I humorously replied to the tweet by saying, “Dates are hard 😜 .”
-
Different methods to remove the last item from an array in Swift
Apr 24, 2022 • Array • swift, UIButton, iOS15, remove array elements, iOS 16, swift ios 15, droplast in swift, removeLast in swift, how to remove element from an array
Arrays are one of the most widely used data structures in Swift, and we deal with a lot of array manipulations. One such manipulation is the removal of the last element from an array. The three useful methods to remove an element from an array are dropLast(), popLast(), and removeLast()
-
Customizing UIButton in iOS 15
Aug 23, 2021 • UIButton • swift, UIButton, iOS15, UIButtonConfiguration, ios15 button configuration, swift ios 15, customizing uibutton in swift, swift uibutton, implementing button in swift
Buttons are an essential element in iOS apps. If you are developing an app using UIKit, you will probably use UIButton class to create buttons. Creating a button is a straightforward process, but it becomes problematic when it comes to customizations. Soon you will find yourself writing hacks for achieving your desired result. We all have been there, and we have done it. You are not alone. Luckily, iOS 15.0 gives us a new method to customize Buttons much easier using UIButton.Configuration. Let’s get started!
-
Exploring Deque in Swift Collections
Apr 14, 2021 • Deque • swift, swift ordered dictionary, swift collections, swift deque, swift deque collections, swift ordered set, swift arrays, deque vs arrays, swift deque vs swift arrays
Deque (should be pronounced as “deck”) is a collection implementing double-ended queues. Deques are similar to arrays, but they have efficient insertions and removal of elements at the beginning and at the end.
-
Swap keys and values of a Dictionary
Mar 24, 2021 • Dictionary • swift, swift dictionary, dictionary
Dictionaries are one of the most commonly used data structures. Dictionaries come with keys and values where the keys are unique. Sometimes, there might be a situation where we would want to swap the keys and values of a dictionary. Let’s see how to swap keys and values of a dictionary in swift.
-
Experimenting with Swift async and await pattern using Xcode
Dec 25, 2020 • Concurrency • swift async await, async/await swift, concurrency in swift, swift concurrency, async await, async await swift5
You all might know that async/await is accepted and is available in the main snapshots! Let’s get our hands dirty by trying out some basic example of async/await in Swift.
-
Common problems and workarounds while building apps using Apple Silicon
Dec 18, 2020 • Apple Silicon • apple silicon, cocoapods, cocoapods apple silicon, cocoapods not installing in apple silicon, firebase, firebase not building in apple silicon, firebase in apple silicon, firebase apple silicon, m1 processor, apple silicon project not building
Apple’s new Apple Silicon (M1 processor) is a beast. The apps open pretty quickly, and the slow Xcode build times are a thing of the past. But what does it have in store for the iOS/macOS developers?
-
Closure based actions in UIButton
Nov 1, 2020 • UIButton • swift, uibutton closure, closure, closure uibutton, callbacks closure, closure callbacks
iOS 14.0 brings us many improvements and new APIs using which the developers can write efficient code. One such API is the closure based action API instead of the
addTarget
method in UIControls. Yes, you heard me right—no more usage ofaddTarget
methods,#selector()
, and@objc
annotation in front of methods. More importantly, we can write a closure based code using the action handler. Okay, enough talk, let’s dive into the code. -
Replacing UIImagePickerController with PHPickerViewController
Aug 29, 2020 • PHPickerViewController • swift, imageassets, phphotopickerviewcontroller, uiimagepikcercontroller, images
Almost every app requires photos and video access these days. Before iOS 14.0, the iOS developers used
UIImagePickerController
to access the items from the user’s media library. From iOS 14.0, Apple is providing its developers a brand new way to select images or videos from their apps usingPHPickerViewController
-
Embracing Localization in Image Assets
Jun 14, 2020 • XCAssets • swift, imageassets, localization, image localization
One of the most significant features which make an app stand out is localization. When we hear the term localization, the first thing that comes to mind is localizing the text displayed in UILabels, UITextViews, UIButtons, and other UIElements. It is quite straight forward to localize the text in the UIElements, and most of us think that we have localized the app, and it is ready to go! But wait, there is one more area I would like to highlight, and that is the images used in the app. You heard me right. If the images used in the app contain text, then they should be localized as well. Localizing the image assets is slightly different but not so hard.
-
An effective way to clear entire Userdefaults in Swift
May 19, 2020 • Userdefaults • swift, userdefaults
As a developer, we might use Userdefaults in our apps at some point in time for storing some basic configuration or settings in the app. But as the project gets complex, things can get pretty tough. Especially, when you want to clear all the UserDefaults values from the app. Well, we can use the
removeObject
method to remove the value for a particular key. -
Using UICollectionViewCompositionalLayout in iOS 12 and earlier
Mar 18, 2020 • UICollectionView • swift, uicollectionview, uicollectionviewcompositionallayout, collection view, compositional layouts
At WWDC 2019, Apple added a brand new API “UICollectionViewCompositionalLayout” to the UIKit. Using this powerful API, we can create complex compositional layouts without writing complicated code. At times, It feels tough to create complex collection view UIs using the UICollectionViewFlowLayout. The UICollectionViewCompositionalLayout API eases the process and guess what you can even support orthogonal scrolling UIs with much ease. Well, it sounds great, but practically we cannot use the UICollectionViewCompositionalLayout API until we drop the support for iOS 12.0 and earlier in our apps. (It is not going to happen for the next few years is what I predict.) So how do we use this API in iOS 12.0 and earlier?
-
Send data Between iOS Apps and Extensions Using Darwin Notifications
In iOS development, app extensions run in separate processes from their containing apps. This separation poses a challenge when you need to communicate between the main app and its extensions. While
NSNotificationCenter
is a common choice for passing data between view controllers within the same app, it falls short when it comes to inter-process communication. Have you ever thought about how to pass data between the main app and its extension? Darwin notifications provide a powerful solution for this scenario. In this post, we’ll explore how to implement a Darwin Notifications manager and use it to facilitate real-time data transfer between a main app and its extension. -
SwiftUI in 2024: Bridging Perception and Reality
I recently spoke at iOSKetchup2024 hosted by Zomato x Blinkit about the challenges and opportunities of using SwiftUI. The audience seemed to enjoy the session as much as I did! Here, I’m excited to share my experience and provide a detailed write-up of my talk.
-
From viewWillAppear to viewIsAppearing - Perfecting Your iOS View Transitions
In WWDC23, Apple introduced a nuanced addition to the UIViewController lifecycle:
viewIsAppearing
. This instance method is a game-changer for developers looking to fine-tune the presentation and layout of their views. Let’s explore how this method enhances the way we build responsive and dynamic interfaces. -
Exploring the New Push Notifications Console from Apple
Apple has recently unveiled a powerful new tool for developers: the Apple Push Notifications Console. This innovative console simplifies the task of sending test notifications to Apple devices using the Apple Push Notification service (APNs).
-
How to send Remote Push Notifications to an iOS Simulator with Xcode 14
In the past, testing push notifications on iOS simulators was quite challenging due to certain limitations. Prior to Xcode 14, receiving push notifications in a simulator was not possible and developers had to rely on local simulations using
.apns
payload files and thesimctl push
command. We have already seen how to simulate push notifications in a simulator in the article, Simulating remote push notifications in a simulator
However, Xcode 14 allows iOS simulators running on macOS 13 on Macs with Apple silicon or T2 processors to receive remote push notifications just like a physical device. -
How to Instantly Track a Variable's Value Changes with Xcode Watchpoints
In the world of programming, tracking variable changes can often turn into a debugging nightmare. In Xcode, you might find yourself frequently relying on breakpoints and manually tracing the changes in your variables’ values. At times, you might also utilize property observers such as
didSet
andwillSet
for this purpose.
But what if I tell you, there’s a powerful tool waiting for you to harness its capabilities: Watchpoints. They allow you to monitor a specific variable or memory address for changes, providing invaluable insights into your program’s execution. -
How to add a loader to an UIButton
Sometimes, we would require a button to show a loader with appropriate text when a long-duration task is done, such as downloading an image. Before iOS 15, we had to write a custom button or do some hacks to show a simple loader or an UIActivityIndicator inside an UIButton. Now, it is not the case anymore. UIButtonConfiguration provides
showsActivityIndicator
, a simple property using which we can hide/show a loader inside a button. -
How to filter screenshots, cinematic videos, and depth-effect photos in PHPickerViewController
In iOS 14.0, Apple introduced a new way to pick images from the device’s photo library using PHPickerViewController. (If you are not aware of PHPickerViewController, I strongly recommend you to read about PHPickerViewController first.)
-
Implementing a custom native calendar using UICalendarView in iOS16 and Swift
It was WWDC22 week, and I was browsing through my Twitter feed to get some updates about the latest Apple APIs. A person tweeted, “No matter how experienced you are as an iOS developer, you’ll always look it up how to set up a date formatter.” So I humorously replied to the tweet by saying, “Dates are hard 😜 .”
-
Different methods to remove the last item from an array in Swift
Arrays are one of the most widely used data structures in Swift, and we deal with a lot of array manipulations. One such manipulation is the removal of the last element from an array. The three useful methods to remove an element from an array are dropLast(), popLast(), and removeLast()
-
Customizing UIButton in iOS 15
Buttons are an essential element in iOS apps. If you are developing an app using UIKit, you will probably use UIButton class to create buttons. Creating a button is a straightforward process, but it becomes problematic when it comes to customizations. Soon you will find yourself writing hacks for achieving your desired result. We all have been there, and we have done it. You are not alone. Luckily, iOS 15.0 gives us a new method to customize Buttons much easier using UIButton.Configuration. Let’s get started!
-
Exploring Deque in Swift Collections
Deque (should be pronounced as “deck”) is a collection implementing double-ended queues. Deques are similar to arrays, but they have efficient insertions and removal of elements at the beginning and at the end.
-
Swap keys and values of a Dictionary
Dictionaries are one of the most commonly used data structures. Dictionaries come with keys and values where the keys are unique. Sometimes, there might be a situation where we would want to swap the keys and values of a dictionary. Let’s see how to swap keys and values of a dictionary in swift.
-
Experimenting with Swift async and await pattern using Xcode
You all might know that async/await is accepted and is available in the main snapshots! Let’s get our hands dirty by trying out some basic example of async/await in Swift.
-
Common problems and workarounds while building apps using Apple Silicon
Apple’s new Apple Silicon (M1 processor) is a beast. The apps open pretty quickly, and the slow Xcode build times are a thing of the past. But what does it have in store for the iOS/macOS developers?
-
Closure based actions in UIButton
iOS 14.0 brings us many improvements and new APIs using which the developers can write efficient code. One such API is the closure based action API instead of the
addTarget
method in UIControls. Yes, you heard me right—no more usage ofaddTarget
methods,#selector()
, and@objc
annotation in front of methods. More importantly, we can write a closure based code using the action handler. Okay, enough talk, let’s dive into the code. -
Replacing UIImagePickerController with PHPickerViewController
Almost every app requires photos and video access these days. Before iOS 14.0, the iOS developers used
UIImagePickerController
to access the items from the user’s media library. From iOS 14.0, Apple is providing its developers a brand new way to select images or videos from their apps usingPHPickerViewController
-
Embracing Localization in Image Assets
One of the most significant features which make an app stand out is localization. When we hear the term localization, the first thing that comes to mind is localizing the text displayed in UILabels, UITextViews, UIButtons, and other UIElements. It is quite straight forward to localize the text in the UIElements, and most of us think that we have localized the app, and it is ready to go! But wait, there is one more area I would like to highlight, and that is the images used in the app. You heard me right. If the images used in the app contain text, then they should be localized as well. Localizing the image assets is slightly different but not so hard.
-
An effective way to clear entire Userdefaults in Swift
As a developer, we might use Userdefaults in our apps at some point in time for storing some basic configuration or settings in the app. But as the project gets complex, things can get pretty tough. Especially, when you want to clear all the UserDefaults values from the app. Well, we can use the
removeObject
method to remove the value for a particular key. -
Using UICollectionViewCompositionalLayout in iOS 12 and earlier
At WWDC 2019, Apple added a brand new API “UICollectionViewCompositionalLayout” to the UIKit. Using this powerful API, we can create complex compositional layouts without writing complicated code. At times, It feels tough to create complex collection view UIs using the UICollectionViewFlowLayout. The UICollectionViewCompositionalLayout API eases the process and guess what you can even support orthogonal scrolling UIs with much ease. Well, it sounds great, but practically we cannot use the UICollectionViewCompositionalLayout API until we drop the support for iOS 12.0 and earlier in our apps. (It is not going to happen for the next few years is what I predict.) So how do we use this API in iOS 12.0 and earlier?