Tutorial : Let's take quick dive in Grouped Notifications - iOS 12

With iOS 12 we can set the group of notifications
grouped notifications

Thread Identifier

Create notification content with threadIdentifier to create group of that notification. Group will be of the application or specific topic from an application.

Notification payload will be like this

Give meaningful name to thread identifier for specific purpose of group.

Summary of group

Simple Notification Group Summary

Hidden Previews Summary Customization

Notification Group Summary with Arguments

Notification Group Summary Argument

Notification Summary with Argument Count

Updated notification payload will be like this

Example with local notifications:

Setup user notifications in the application.

Fire local notifications and look into the thread identifier, summary and summary count…

Conclusion

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.

Tips for update CocoaPods and your project libraries

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects.

CocoaPods Logo
CocoaPods Logo

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

Update your system by following command in terminal.

Above command will install/update rubygems.

Install CocoaPods

Install CocoaPods in your system by following command in terminal.

If you are getting errors above command then use following command.

Check CocoaPods Version

Update CocoaPods Repository

We have to update CocoaPods repository with latest pod updates by developers. Use following command to update CocoaPods repository:

It will take some time to update all sub repositories.

Update pod for your project

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:

Remove all CocoaPods from a project

Install CocoaPods deintegrate and clean commands from terminal.

Now you have to apply both command to remove all CocoaPods from your project:

Happy Coding ?

How to use Alamofire with Codable in Swift?

Hello after long time I am writing this blog regarding use of Alamofire with Codable model object for the ease of MVC architecture.
Let’s rewind with some of the post which is used to cover this point:

  1. How to use Alamofire and SwiftyJSON with Swift?
  2. How to create a wrapper for Alamofire and SwiftyJSON?
  3. Use of Codable and Coding Key with JSONEncoder and JSONDecoder in Swift 4

Let see about use of Alamofire with Codable model object

Step 1 – Create Codable object based on JSON response.

Here I am taking an example of a web service which contains JSON related to the contact.

So, we can create two Codable files from this JSON as per hierarchy. These would be like as follows:

As you can see we have created 2 objects Contact and Phone. Here Phone is in sub hierarchy.

Step 2 – Let’s update AFWrapper

As we have previously revised blogs, there is a blog mentioned about to create a wrapper of the Alamofire and SwiftyJSON. We have to replace the SwiftyJSON code to return normal dictionary objects, and after that we will convert that dictionary to the Codable object.
So here I have updated the AFWrapper class file to do that thing:

Step 3 – Implement and convert the response in object

We will call a web service which contain that kind of JSON response. And after calling the web-service we will decode the object to create the Codable object.

In above sample I have added one text view in the view controller and I am fetching the data from the contacts API. After that using JSONSerialization and JSONDecoder we will get our decoded Contact object with Phone object.

Conclusion

Swift 4 comes with so many updates. We are going to have a great time exploring them all and finding out so much more by using it on further projects. We have learned about Codable and use of it. You too should go check it out and share your experiences with us in the comments section.
Hope you liked the article.
Happy Coding 🙂

What's new in Xcode 8.3?

xcodeicon
Xcode 8.3

Swift 2.3 Deprecation

  • Xcode 8.3 beta 2 no longer supports Swift 2.3. Please migrate your projects containing Swift 2.3 code to Swift 3 syntax by opening the project and choosing Edit > Convert > To Current Swift Syntax.

Other Deprecations and Removal Notices

  • The Automation instrument has been removed from Instruments. Use Xcode’s UI Testing in its place.

Organizer

  • The Xcode Organizer now supports exporting tvOS apps for Enterprise distribution.

Testing

  • Added the XCUISiriService class to XCTest for writing tests which activate Siri with a voice recognition string, and queries for elements in the Siri UI. Use the class to write UI tests for Intents and Intents UI extensions.

Swift Compiler

  • The Swift compiler can now automatically precompile Objective-C bridging headers, which can speed up Debug configuration builds (or other non-WMO builds) of mixed-source projects with large bridging headers. This feature is still experimental, and is disabled by default but can be enabled with the “Precompile Bridging Header” (SWIFT_PRECOMPILE_BRIDGING_HEADER) build configuration setting within Xcode.

Provisioning

  • Changed the user interface for managing signing certificates and provisioning profiles. Certificates are managed from the Accounts preferences pane by selecting a team and clicking Manage Certificates. Automatically managing signing is recommended, however if your app requires manually signing provisioning profiles are managed in the General tab of the project editor. Use the Provisioning Profile dropdown to import or download profiles. In addition it displays profiles that match the current signing configuration of the target.

Simulator

  • You can invoke Siri using Hardware > Siri after enabling Siri in the Settings app on Simulator.

Others

  • Xcode 8.3 includes Swift 3.1 which is intended to be source compatible with Swift 3.0.
  • Constrained extensions allow same-type constraints between generic parameters and concrete types. For example, the following code defines an extension on Array with Int elements:
  • The Swift compiler now raises an error for modifications of a let property or variable of protocol type after initialization. For example, the following code that compiled in previous versions will now raise an error:

    Code that successfully compiled in previous releases may fail after upgrading.

Interface Builder

  • NSTextField objects created in Interface Builder now have allowsCharacterPickerTouchBarItem turned off by default.

Currently latest beta version is Xcode 8.3 Beta 3. I will update this blog as per versions of Beta.
Happy Coding 🙂

SwiftGoingFaster by Precompiled Bridging Headers

Faster Mix-and-Match Builds with Precompiled Bridging Headers

apple_swift_logo

PROBLEM :
Every time a Swift file in a mixed-language target is compiled, the Swift compiler parses the project’s bridging header in order to make Objective-C code visible to Swift code. When the bridging header is large and the Swift compiler runs many times – as in a debug configuration – the cost of repeatedly parsing the bridging header can be a substantial part of the overall build time.

In Swift 3.1, you can reduced debug build time by 30% by using the new -enable-bridging-pch Swift flag for this issue. This mode is still experimental and must be manually enabled, but it will be enabled by default if developer feedback indicates it’s working well and providing significant speedup… so try it out!

Build Settings
Build Settings

Related Link : Faster Mix-and-Match Builds with Precompiled Bridging Headers
Happy Coding 🙂