Tuesday, 17 October 2017

How to solve pod update fails with RuntimeError - [Xcodeproj] Unknown object version (macOS Sierra and xcode 9.0)


Solve pod update fails with RuntimeError - [Xcodeproj] Unknown object version (macOS Sierra and xcode 9.0)

Solve pod update fails with RuntimeError - [Xcodeproj] Unknown object version (macOS Sierra and xcode 9.0)

As per the heading, in this tutorial we will learn how to solve pod install or pod update error that it fails with run-time error - [Xcodeproj] unknown object version. Also we will, solve another error 
operation not permitted - /usr/bin/pod cocoa-pods. So basically we will solve the below two errors

1) pod install or pod update fails with run-time error - [Xcodeproj] unknown object version

2) operation not permitted - /usr/bin/pod cocoa-pods

Below are the steps to solve the above listed two errors

Step 1: Open terminal and type command   
sudo gem install cocoapods

How to solve pod update fails with RuntimeError - [Xcodeproj] Unknown object version (macOS Sierra and xcode 9.0)
Step 2: It will ask for password, enter your system password.
Step 3: If you get error as shown in the picture below then see step 4.
How to solve pod update fails with RuntimeError - [Xcodeproj] Unknown object version (macOS Sierra and xcode 9.0)
Step 4:  Run the command 

sudo gem install -n /usr/local/bin cocoapods

operation not permitted - /usr/bin/pod cocoapods

Step 5:  Your pods were successfully installed and now you can install pods for your xcode project.

How to solve pod update fails with RuntimeError - [Xcodeproj] Unknown object version (macOS Sierra and xcode 9.0)

Where to go from here

In this tutorial we  learned how to solve pod install or pod update error that it fails with run-time error - [Xcodeproj] unknown object version and second error operation not permitted - /usr/bin/pod cocoa-pods 
Note:
Video tutorial  is also available. You can watch the video tutorial Youtube video link

Sunday, 15 October 2017

Create tag clouds view in swift - Tutorial



Create tag clouds view in iOS


Introduction to tutorial, how to create tag clouds view in swift:

                                       In this tutorial, we will learn how to create tag clouds view in swift. Tag clouds view, we  create will look like as show in the image view.

Cloud tags view in iOS - programmatically using swift
When user taps on cross icon we, will remove the tag and all other tags will be re-adjusted according to the width. 

Steps to create tag clouds view in swift:

Step 1: Create a new single view application and name it "TagsCloud". 

Step 2: Open "ViewController.swift", and create an IBOutlet for UITextField so that we can add a new cloud tag. Secondly, we will declare an array named "tagsArray", who will hold all our tags.


Step 3: Open Main.storyboard file and create user interface that contains one UITextField and a UIButton, as shown in the given below images, you can create your own layout too.

Intial Layout of the screen to add tags
Initial layout of our screen

Constraints used for UIButton
Constraints used for UIButton



Constraints used for UITextField
Constraints used for UITextField


 Step 4: Connect IBOutlet "txtInput" to UITextField.

Step 5: Open ViewController.swift and creates an IBAction for our UIButton.


Step 6: Open "Main.Storyboard", and connect IBAction "addTag" to UITouchUpInside event of the
UIButton.

Step 7: Next we will write definition  for recently created IBAction "addTag", here if our UITextField "txtInput" is not empty then we will add that entry to our array and call our method that we create tags cloud.


Step 8: At this time if runs your app, and press "Add Tag", button the app will gets crashed as we haven't implemented out function that will create clod tags. Copy the below code and add it to your file.



In the above function we will first remove all the sub-views whose tag is not equals to zero. Then we will get width for tags text, the add the spacing and button width as per the designs with respect to tag view. IF our tag is going outside the screen bounds then we will change x position and y position so that it will adjust to new line.
                                            Then we draw, all our elements required to create tag with cross icon and add selector to cross button so that we can remove it.

Step 9 : Last step, we are using String extension that will return string width based upon the font  that our tag is using.


Where to go from here:

     In this tutorial, you learned how to create cloud tags view in ios using swift. If you type anything in the UITextField and press "Add Tag" button. It will create a new tag. When you tap on cross icon the tags will be automatically adjusted in the cloud. If you feel any issue then please feel free to comment. You can download the source code from the given link

Monday, 9 October 2017

Error while uploading app to Itunes Missing Marketing Icon - iOS Apps must include a 1024x1024px Marketing Icon in PNG format



Error while uploading app to Itunes Missing Marketing Icon - iOS Apps must include a 1024x1024px Marketing Icon in PNG format

Error while uploading app to Itunes, Missing Marketing Icon  - iOS Apps must include a 1024x1024px Marketing Icon in PNG format

As the tutorial heading reads out. In this tutorial we will learn how to remove this error and check whether the icon image  has alpha transparency enabled or it is without alpha transparency.
                                                          Apple Inc. recently changes there App developer Agreement and also the requirements that needs to be full-filled prior to uploading app to iTunes app store. If you are trying to upload iOS app from Xcode 9 then your app must include marketing app icon of size 1024*1024 pixels. You have to add this icon in your Assets.xcassets - App icon.

 IMPORTANT: Make sure to use the icon without Alpha/Transparency.

To add it follow the given below steps

Step 1: Select "Assets.xcassets".

Error while uploading app to Itunes Missing Marketing Icon - iOS Apps must include a 1024x1024px Marketing Icon in PNG format

Step 2: Select App Icon.

Step 3: Set your app icon  image of size 1024*1024 pixels to the box as shown in image below. Also make sure your app icon image does not have alpha.

Error while uploading app to Itunes Missing Marketing Icon - iOS Apps must include a 1024x1024px Marketing Icon in PNG format


How to check image alpha transparency 

If you are not sure how to check, whether your image has alpha or not, Then follow below steps

Step 1: Open your image with "Preview app."

How to check wether image has alpha transparency or not using preview app


Step 2: Make a duplicate copy of that image, as shown in image.

How to check wether image has alpha transparency or not using preview app


Step 3: Close the duplicate image window.

How to check wether image has alpha transparency or not using preview app

Step 4: If the pop up that came after closing duplicate window has alpha option then your image has alpha transparency. If no alpha option shown, then your image has no alpha transparency.

How to check wether image has alpha transparency or not using preview app

Where to go from here:

In this tutorial or blog post we learned, how to remove Missing Marketing Icon - iOS Apps must include a 1024x1024px Marketing Icon in PNG format, error while uploading ios app to iTunes store and how to check whether our icon image has transparency enabled or is without transparency as Apple clearly said that image should have without Alpha/Transparency.

Sunday, 24 September 2017

Integrate google map SDK for swift in iOS - Tutorial



How to create Google map for swift in iOS - Tutorial


Introduction:

In this tutorial we will learn how to integrate or add Google map SDK for swift in our iOS app project. Google map provides lots of options to the developer if the app want to show the location on map, navigation routes etc., because Google map is the most common map used by the people around the globe. So let start the tutorial.

Steps to integrate or add Google map SDK:

Step 1: Create a new single view application project and name it as "GoogleMap-Tutorial".

Note: If you are not logged in then please login to your Gmail or Google account.

Step 3: Click on "GET A KEY" button, a pop up will appear. Create a new project or use already existing project. After this click on "Enable API" button.

Get A key Google Map SDK iOS
Get A key Google Map SDK 

Create new project Google map SDK
Create new project to integrate Google map SDK
Step 4: You will get API key and copy it to safe location

Google map API key

Step 5: At this moment we have API key, now time to download SDK and install it into our project. Select "GUIDES" tab. 


Step 6:  There are two options to install the SDK, manually or using pods. We will prefer pods as it is more convenient way to upgrade to latest version of SDK. If you are not familiar with installation of pods, you can have a look at below link that explain how to install pods on mac.


Step 7: Open Terminal, and type command

Creating podfile for the project
Creating podfile for the project
The path above is the location of your project until "GoogleMap-Tutorial.xcodeproj".

Step 8: Create podfile using the command "touch podfile"
Coomand to create podfile xcode
Command to create podfile 
Step 9: Adding pod of Google map iOS SDK. In terminal open pofile using command "open -e podfile"

Opening podfile so taht we can write all the pods our application required to indatll
Opening podfile
Step 10: A podfile will be opened up in TextEdit and you can write pod to be installed in it and then save it. Then run the command "pod install". Shown in images below
Adding Google map SDK pod to our podfile
Editing podfile

Installing pods using command "pod install"
Installing pods using command "pod install"
 Step 11: After successful installation you will see message on terminal "Please close any current Xcode sessions and use `GoogleMap-Tutorial.xcworkspace` for this project from now on."

Step 12: Open ".xcworkspace" file. Don't use ".xcodeproj" file to open the project now onward.

Step 13: Open ViewController.swift and add following code to it.



Step 14: Check that you replaced the API key with your own API key, otherwise the map will not show on the screen. Run your app and you will see map is showing on the simulator/ device.

Google map showing on iPhone simulator

Where to go from here: 

In this tutorial you learned, how to configure Google map SDK in swift for iOS. In the future tutorials, we will cover how to add custom markers and draw poly lines / routes on Google map in swift. Hope the tutorial helped in setting up the Google map SDK for swift in iOS.
Download the source code from here

Tuesday, 12 September 2017

Add event to device calendar in iOS using Swift


Add event to device calendar in iOS using Swift

Introduction to Event-Kit framework:

As per name, create events in calendar using swift this tutorial is revolving around EventKit framework which comes with Xcode. The EventKit framework provides classes for accessing and manipulating calendar events and reminders. Thus, we can add event to calendar using classes provided in EventKit framework. In this tutorial we will learn how to create event in  calendar of iPhone or device calendar in iOS apps programming using swift language.

Looking for objective C version then please visit Add event to device calendar - Objective C

Steps for creating event to device calendar

Step 1: Add EventKit framework under Linked Frameworks and libraries


Step 2: Create Event store object


Step 3: In info.plist file add privacy policy key for calendar usage, as shown in below image other wise your app will crash as soon as you want to access device calendar

Add privacy policy key for accessing device calendar in info.plist

Step 4:  Create a function having three parameter's

1) Event Title - This is the title of the event we want to show in device calendar.
2) Event Start date - This is the event start date.
3) Event end date - This is the event end date.

 Inside the function we, will first request for access to device calendar. On successful access to device calendar, we will use EKEvent class to create and event on device calendar and EKAlarm class to set an alarm or reminder for the event.


Where to go from here:

In this tutorial we learned about how to create event to  calendar in iOS using EventKit framework.  For more tutorial on swift, please stay tune. If any problem arises then please ask your questions via commenting, will try to respond to them as soon as possibly. Happy coding :)






Wednesday, 6 September 2017

Get thumbnail from video url in swift


Get thumbnail from video url in swift  - Tutorial

Get thumbnail from video url in swift :

                                           Generating thumbnail or preview image from video URl in your iOS app seems to be a tough task. In this tutorial we will look at the code snippet to create or generate thumbnail from video url in swift. If you are looking for objective C  code then please go to this link

Swift code to generate thumbnail from video URL:

Below is the code that will generate thumbnail from video URl in swift language. 




Where to go from here:

In this tutorial you learned how to create or generate thumbnail from video url in swift. The code is fully testified at the time of tutorial being written. If any one found issue is code then please post it as comment. We will try to fix it as soon as we can. Thanks for reading. Happy coding

Sunday, 6 August 2017

Update UItableViewCell subviews tag after deleting a row from UITableView in swift3 iOS tutorial


Update UItableViewCell subviews tag after deleting a row from UITableView in swift3 iOS tutorial

Update tags of UItableViewCell without reloading whole UITableView:

In iOS app development, UITableView is most common control used in all apps. While creating list in iOS apps, we use UITableView, and if we want to delete a row from that UITableView when user tap on a button e.g. a delete button on the row than at this time we have below options to full-fill our objective.

1) remove the index based on our button tag from the data-source array
2) After removing the record, reload UITableView
3) use UItableView function deleteRows, reloadRows to load only that particular row

Now, first option is the necessary step, we always need to perform if we want to change or delete an item or row from UITableView. The main limitation of reloading whole UITableView, here i ma talking about the 2nd option in order to update button tags is not a good approach as if we have 100's of records in our UITableView than they all will get reloaded. With 3rd option we will remove the limitation we encountered in option  2nd, but it will only update the tag of row that gets reloaded again, thus left us with all old tags for button intact in other rows of UITableView.

Solution for update tag after deleting row form UITableView:


The only solution is that to get the tag when we called our button action,  rather than giving the tag to button at cellForRowatIndexPath method. One can get the tag by using the below code.



In above code we get the point of our sender, and from that point we get the row index path.

Where to go from here:

In this tutorial, we learned how to update button tag displayed on UITableView cell while deleting or adding a row in the UITableView rather than reloading whole UITableView,