SwiftUI comes with easiest way of coding!
In SwiftUI they have given 3 types of gradients, you can easily show gradients on any of the view.
- Linear Gradient
- Radial Gradient
- Angular Gradient

In gradient option we have to pass array of colors.
Technology Makes A Wonderful World
SwiftUI comes with easiest way of coding!
In SwiftUI they have given 3 types of gradients, you can easily show gradients on any of the view.
In gradient option we have to pass array of colors.
SwiftUI announced in WWDC 2019. It’s an innovative, exceptionally simple way to build user interfaces across all Apple platforms with the power of Swift. In previous blog I have shared some references from apple documents.
We will learn it by examples. First of all let’s start with simple UI.
Apple just announced SwiftUI today.
SwiftUI will be used to declare the user interface and behavior for your app on every platform.
Here are some basic resources to understand SwiftUI:
Apple Documentation
Tutorials for SwiftUI
Sample from WWDC 2019 Event:
Hope it will help you to look into it.
Happy Coding 🙂
Swift 5 comes with enhancement in string literals delimiters to support Raw Text.
I found little snippet from twitter about how to know if application is installed via TestFlight.
Here, appStoreReceiptURL
is an instance property, which we can find from main bundle.
Here, I am adding snippet for both Objective-C and Swift.
Following are warnings and errors will come while upgrading from Swift 4.x to Swift 4.2 in Xcode 10.0
With iOS 12 we can set the group of notifications
Create notification content with threadIdentifier
to create group of that notification. Group will be of the application or specific topic from an application.
1 2 3 4 5 |
// Creating Groups with Thread Identifiers let content = UNMutableNotificationContent() content.title = "Notifications Group" content.body = "Tutorial by Ashish Kakkad" content.threadIdentifier = "notify-team-ios" |
Notification payload will be like this
1 2 3 4 5 6 7 8 9 |
{ "aps" : { "alert" : { "title" : "Notifications Group", "body" : "Tutorial by Ashish Kakkad" } "thread-id" : "notify-team-ios" } } |
Give meaningful name to thread identifier for specific purpose of group.
Simple Notification Group Summary
1 2 |
let summaryFormat = "%u more messages" return UNNotificationCategory(identifier: "category-identifier", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: nil, categorySummaryFormat: summaryFormat, options: []) |
Hidden Previews Summary Customization
1 2 3 |
let summaryFormat = "%u more messages" let hiddenPreviewsPlaceholder = "%u messages" return UNNotificationCategory(identifier: "category-identifier", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: hiddenPreviewsPlaceholder, categorySummaryFormat: summaryFormat, options: []) |
Notification Group Summary with Arguments
1 2 |
let summaryFormat = "%u more messages from %@" return UNNotificationCategory(identifier: "group-messages", actions: [], intentIdentifiers: [], hiddenPreviewsBodyPlaceholder: nil, categorySummaryFormat: summaryFormat, options: []) |
Notification Group Summary Argument
1 2 3 4 |
let content = UNMutableNotificationContent() content.body = "…" content.threadIdentifier = "notify-team-ios" content.summaryArgument = "Ashish" |
Notification Summary with Argument Count
1 2 3 4 5 |
let content = UNMutableNotificationContent() content.body = "…" content.threadIdentifier = "notify-team-ios" content.summaryArgument = "Ashish" content.summaryArgumentCount = 2 |
Updated notification payload will be like this
1 2 3 4 5 6 7 8 9 10 |
{ "aps" : { "alert" : { "body" : "…", "summary-arg" : "Ashish", "summary-arg-count" : 2 }, "thread-id" : "notify-team-ios" } } |
Setup user notifications in the application.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
// // AppDelegate.swift // AKGroupedNotifications // // Created by Ashish Kakkad on 21/06/18. // Copyright © 2018 Kode. All rights reserved. // import UIKit import UserNotifications @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. let center = UNUserNotificationCenter.current() center.delegate = self let options: UNAuthorizationOptions = [.alert, .sound] center.requestAuthorization(options: options) { (granted, error) in if !granted { print("Something went wrong") } } center.getNotificationSettings { (settings) in if settings.authorizationStatus != .authorized { // Notifications not allowed } } return true } } extension AppDelegate : UNUserNotificationCenterDelegate { func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) { completionHandler([.alert, .sound]) } } |
Fire local notifications and look into the thread identifier, summary and summary count…
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
if #available(iOS 10.0, *) { for i in 1...5 { let content = UNMutableNotificationContent() content.categoryIdentifier = "AKNotification" content.title = "Notification \(i)" content.body = "\(Date())" if i == 2 { content.threadIdentifier = "ak-notingroup" } else { content.threadIdentifier = "ak-group-website" content.summaryArgumentCount = 1 content.summaryArgument = "by ashishkakkad.com" } let trigger = UNTimeIntervalNotificationTrigger(timeInterval: TimeInterval(10*i), repeats: false) let request = UNNotificationRequest(identifier: "NotificationID\(i)", content: content, trigger: trigger) let center = UNUserNotificationCenter.current() center.add(request) { (error) in print(error?.localizedDescription ?? "") } } } |
I know that I haven’t described anything in detail. If I get time I will update this blog with details.
Happy Coding ?
If you have any questions, comments, suggestions or feedback then contact me on Twitter @ashishkakkad8.
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.
CocoaPods is built with Ruby and is installable with the default Ruby available on OS X. We recommend you use the default ruby.
Update your system by following command in terminal.
1 |
$ sudo gem update --system |
Above command will install/update rubygems.
Install CocoaPods in your system by following command in terminal.
1 |
$ sudo gem install cocoapods |
If you are getting errors above command then use following command.
1 |
$ sudo gem install -n /usr/local/bin cocoapods |
1 |
$ pod --version |
We have to update CocoaPods repository with latest pod updates by developers. Use following command to update CocoaPods repository:
1 |
$ pod repo update |
It will take some time to update all sub repositories.
If you directly apply the command pod install then some time new pods will not be updated in your project. For that you have to remove that specific pod information from the pod file and you have to apply pod install command. It will remove pod from the project. After that again you have to add the pod information in the pod file. Again you have to apply pod install command to install new version of pod.
Follow the next steps:
1. Remove SomePod
from the Podfile
2. Run pod install
pods will now remove SomePod
from our project and from the Podfile.lock
file.
3. Put back SomePod
into the Podfile
4. Run pod install
again
This time the latest version of our pod will be installed and saved in the Podfile.lock
.
You can update single pod file as follows:
1 |
$ pod update 'POD_NAME' |
Install CocoaPods deintegrate and clean commands from terminal.
1 |
$ sudo gem install cocoapods-deintegrate cocoapods-clean |
Now you have to apply both command to remove all CocoaPods from your project:
1 2 |
$ pod deintegrate $ pod clean |
Happy Coding ?
Xcode is IDE for development of the iOS, macOS, tvOS and watchOS applications. Every year apple comes up with so many changes in this IDE. Xcode 9.3 released on March 29, 2018.
Here, I am listing out all the issues with the workaround.