Thursday, November 5, 2020

Unified logging in iOS

 One of most important use of unified logging is that it facilitates us to see the logs from extensions.

Using apple xcode doesn't show the logs in it from extension.

All we have to do is use the following import

    import os.log

If you want to log something use the below statement

  os_log("")

Now you can see all this logs printed in terminal. 


P.S:

It can be very useful while you are working with extensions. Because we have to attach the extension with xcode for us to actovate the breakpoint inside  extension. Till we attach lot of things can happen we may want to know that's when the unified logging comes to our rescue. 

 

Sunday, November 24, 2019

Uprading to SSD from HDD on mac book pro

Recently my mac book pro has become very slow and found out that my HDD(Hard Disk Drive) has become faulty and that's the reason it's very slow.

I went to apple store to fix it and it was little expensive over there like £230 and they can do only as is replacement for HDD with another HDD and they won't do HDD to SSD(Solid State Drive)

So I went over to third party apple repair shop and they were ready to upgrade my mac book pro with SSD but again it was little expensive like £280.   

So I decided , I would do it myself and fixed it successfully so I thought I would share what I did to do this so that it's helpful for anyone who's looking to do.

1.  Buy the right SSD for your machine. I recommend Cruical.com. Visit this site and it'll ask you to download an app and it'll tell you what are the SSD you can buy for your machine.

2. Buy a Laptop or computer repairing screw driver set. 

3. Remove the screws from lower case.

4. Remove the battery connection cable from the motherboard

5. Remove the battery using pull tab

6. Disconnect the HDD connecting cable

7. Take out the HDD and remove the retaining screws from the side of HDD

8. Attach the retaining screws to SSD 

9. Put the SSD in place of HDD

10.Attach the connecting cable on SSD then attach the battery cable with mother board

11.Put all the screws back

12. Start up your mac and press command + option + R 

13. This will bring internet recovery 

14. After recovery choose disk utility and erase the newly bought SSD with Format: APFS and Partition type: GUID

15. After erasing , choose internet recovery or restore time machine back up

Then follow the normal steps like entering the apple id to sign in once the recovery is over. That's all

Monday, June 25, 2018

how do regular users can install iOS 12 development beta

Public betas for regular users follow the developer betas.

if you are a regular user and want to join the beta test , head to beta.apple.com on the device you want to run the beta on.

you can enrol there, and download a  specific profile that will allow your device to download the beta releases 

after that , new beta releases will be delivered just a regular iOS updates are: You will get a notification when one is ready and can check manually by going to Settings -> General -> Software Update

Monday, May 7, 2018

how to restrict mobile app access to only wifi

In enterprise application , the need for apps to use only wifi comes to picture sometimes as they can access intranet through wifi.

But with the advent of wifi-assist.It's possible sometimes Mobile data will be used for internet connectivity simultaneously along with wifi.

so how to stop this from happening so that app can use only wifi not mobile data.

allowscellularaccess property of NSMutableURLRequest solves the issue.

so if set this value to NO then if there is no wifi then it'll ignore the mobile data and return internet connect offline error message

Here is sample code to test

    NSMutableURLRequest *request=[[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:@"https://www.google.com"]];    [request setAllowsCellularAccess:NO];    NSError *error;
        NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];    NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];        [request setHTTPMethod:@"GET"];
        NSURLSessionDataTask *postDataTask = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
        NSLog(@"error:%@",error);
        NSLog(@"success:%@",response);
    }];
        [postDataTask resume];

Here is the sample error message we get


Error Domain=NSURLErrorDomain Code=-1009 "The Internet connection appears to be offline." UserInfo={NSUnderlyingError=0x1c004b700 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, NSErrorFailingURLStringKey=https://www.google.com/, NSErrorFailingURLKey=https://www.google.com/, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, NSLocalizedDescription=The Internet connection appears to be offline.}

Thursday, March 8, 2018

Multipath tcp in iOS

Multipath TCP enables iOS to use both wifi and data connection simultaneously which increases the user experience and works around common problem network latency,network connection drop out,etc.

It was introduced in iOS 7 itself and it was used by only Siri but it is released for developers.
since iOS 11.

This can be lot more useful when it comes to streaming of audio and video.

One can opt multipath tcp in NSURLSession

var multipathserviceType:URLSessionConfiguration.MultipathServiceType
none =0
handover = 1
interactive=2

None:

It never used multipath acts as usual

Handover:

acts more like how wifi assit works i.e only when wifi is weak it uses data and if wifi signal gets stronger then it uses wifi

Interactive:

It uses both wifi and data at a same time but it will not be very aggressive on data network.
Siri uses interactive mode

Aggregate:

Same as interactive but it'll use data network aggressively

Wednesday, January 31, 2018

Easy to use java decompiler

Recently I had to get java class files out of JAR that was provided to me.

I could get easily class files from JAR by renaming the file from myLib.jar to myLib.zip.

But I couldn't find a easy way to decompile .class file (byte code ) back to java.

I found some online services to do that but its not safe and most of them are blocked due to firewall in corporate network.

and doing this manually with javap which is part of JDK is not good as it displays other information than original source code which makes kind of hard to copy and save as java file.

so I thought like I would use a stand alone desktop program.

I found JD GUI good

because it provides good UI(Tree view explorer) for us to see and shows the actuall source code and easy to export as java file

I tried couple of other Stand along programs but it wouldn't support latest mac.


Thursday, January 25, 2018

Ever wanted to run your windows apps on Android device, now its possible with Wine 3.0

With the introduction of Wine 3.0 now you can run windows 7 apps on Android.

It works better with X86 based processor and with ARM based phone you are limited to programs that runs with Windows RT.

One more thing is it even allows you to run some windows application on mac.

Even though this application is not bugfree,Its still worth a try.