0

Crash logs

-

So far I’ve had mixed results in weeding out the good from the bad. One skill that I think is of utmost important for a developer is debugging. You might be saying that all developers do that, but some are far better at it than others. Debugging is one of my best skills and I’ve had a ton of experience at it inheriting other people’s projects. With that in mind, I came up with one technical test that could actually tell me if a candidate could debug and that skill goes a long way in development.

Now you ask, what is the question? The other day as I was poking through crash logs, a few stood out at me. Take a look at the following logs and see if you can spot why the apps crashed:

  1. Thread 0 name:  Dispatch queue: com.apple.main-thread
  2. Thread 0:
  3. 0   libsystem_kernel.dylib            0x35cab054 semaphore_wait_trap + 8
  4. 1   libdispatch.dylib                 0x342961c0 _dispatch_semaphore_wait_slow + 184
  5. 2   libdispatch.dylib                 0x342961f4 dispatch_semaphore_wait$VARIANT$mp + 32
  6. 3   libxpc.dylib                      0x3200e89a xpc_connection_send_message_with_reply_sync + 206
  7. 4   SystemConfiguration               0x374f5be6 _reach_server_target_status + 938
  8. 5   SystemConfiguration               0x374f6d56 __SCNetworkReachabilityServer_targetStatus + 14
  9. 6   SystemConfiguration               0x374dfaee __SCNetworkReachabilityGetFlags + 198
  10. 7   SystemConfiguration               0x374e0f7a SCNetworkReachabilityGetFlags + 190
  11. 8   MSNBC                             0x000cb9ec 0x1000 + 829932
  12. 9   MSNBC                             0x0006f998 0x1000 + 453016
  13. 10  MSNBC                             0x0006abfa 0x1000 + 433146
  14. 11  MSNBC                             0x00014d54 0x1000 + 81236
  15. 12  MSNBC                             0x0006ab6e 0x1000 + 433006
  16. Last Exception Backtrace:
  17. 0   CoreFoundation                    0x3567188f __exceptionPreprocess + 163
  18. 1   libobjc.A.dylib                   0x37a18259 objc_exception_throw + 33
  19. 2   CoreFoundation                    0x356713b3 __NSFastEnumerationMutationHandler + 163
  20. 3   EmSea                             0x001f9c2b 0xe2000 + 1145899
  21. 4   EmSea                             0x00199bed 0xe2000 + 752621
  22. 5   EmSea                             0x00223453 0xe2000 + 1315923
  23. 6   EmSea                             0x002239c9 0xe2000 + 1317321
  24. 7   Foundation                        0x351b6c29 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 17
  25. 8   Foundation                        0x3510e6d9 -[NSURLConnectionInternalConnection invokeForDelegate:] + 29
  26. 9   Foundation                        0x3510e6a3 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199
  27. 10  Foundation                        0x3510e5c5 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 61
Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   libsystem_kernel.dylib            0x35cab054 semaphore_wait_trap + 8
1   libdispatch.dylib                 0x342961c0 _dispatch_semaphore_wait_slow + 184
2   libdispatch.dylib                 0x342961f4 dispatch_semaphore_wait$VARIANT$mp + 32
3   libxpc.dylib                      0x3200e89a xpc_connection_send_message_with_reply_sync + 206
4   SystemConfiguration               0x374f5be6 _reach_server_target_status + 938
5   SystemConfiguration               0x374f6d56 __SCNetworkReachabilityServer_targetStatus + 14
6   SystemConfiguration               0x374dfaee __SCNetworkReachabilityGetFlags + 198
7   SystemConfiguration               0x374e0f7a SCNetworkReachabilityGetFlags + 190
8   MSNBC                             0x000cb9ec 0x1000 + 829932
9   MSNBC                             0x0006f998 0x1000 + 453016
10  MSNBC                             0x0006abfa 0x1000 + 433146
11  MSNBC                             0x00014d54 0x1000 + 81236
12  MSNBC                             0x0006ab6e 0x1000 + 433006
Last Exception Backtrace:
0   CoreFoundation                    0x3567188f __exceptionPreprocess + 163
1   libobjc.A.dylib                   0x37a18259 objc_exception_throw + 33
2   CoreFoundation                    0x356713b3 __NSFastEnumerationMutationHandler + 163
3   EmSea                             0x001f9c2b 0xe2000 + 1145899
4   EmSea                             0x00199bed 0xe2000 + 752621
5   EmSea                             0x00223453 0xe2000 + 1315923
6   EmSea                             0x002239c9 0xe2000 + 1317321
7   Foundation                        0x351b6c29 __65-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 17
8   Foundation                        0x3510e6d9 -[NSURLConnectionInternalConnection invokeForDelegate:] + 29
9   Foundation                        0x3510e6a3 -[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 199
10  Foundation                        0x3510e5c5 -[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 61

 

On the first one, the hint is that the app failed to launch in time. I’m going to use these crash logs as a test to see if a candidate can tell me what went wrong. Neither app is mine and while I can’t see the code, I can immediately spot the problems.

In the first crash log, the app calls SCNetworkReachabilityGetFlags on the main thread. This call is a blocking call which means it won’t return until it is done; this call can take a significant amount of time to return and should never be called on the main thread, especially at app startup.

In the second crash log, it isn’t as obvious. What the developer has done is something like:

  1. for (NSString *string in someMutableArray)
  2. {
  3.     if ([string isEqualToString:@"Yuck"])
  4.     {
  5.         [someMutableArray removeObject:string];
  6.     }
  7. }
for (NSString *string in someMutableArray)
{
    if ([string isEqualToString:@"Yuck"])
    {
        [someMutableArray removeObject:string];
    }
}

The array is getting modified while it is being enumerated. The fix is pretty simple.

  1. NSMutableArray *deleteArray = [NSMutableArray array];
  2. for (NSString *string in someMutableArray)
  3. {
  4.     if ([string isEqualToString:@"Yuck"])
  5.     {
  6.         [deleteArray addObject:string];
  7.     }
  8. }
  9.  
  10. [someMutableArray removeObjectsInArray:deleteArray];
NSMutableArray *deleteArray = [NSMutableArray array];
for (NSString *string in someMutableArray)
{
    if ([string isEqualToString:@"Yuck"])
    {
        [deleteArray addObject:string];
    }
}

[someMutableArray removeObjectsInArray:deleteArray];

 

Are you good at reading crash logs?

0

QR-Code Encoder for Objective-C

-

An implementation of QR code encoder for Objective-C ported from Psytec library

GitHub

0

BButton 2.0 for iOS

-

Twitter Bootstrap (v2.3.1) Buttons for iOS.

Refactored and refined from mattlawer/BButton.

GitHub

0

THLabel for iOS

-

THLabel is a subclass of UILabel, which additionally allows shadow blur, stroke text and fill gradient.

THLabel screenshot

GitHub

0

OWActivityViewController for iOS

-

 

OWActivityViewController is a fork of REActivityViewController, with no external dependence. only support iOS integrated Social Network (for iOS 6: Twitter/Facebook/SinaWeibo, for iOS 5: Twitter).

Here is REActivityViewController dependencies:

  • AFNetworking ~> 1.1
  • Facebook-iOS-SDK ~> 3.2
  • DEFacebookComposeViewController ~> 1.0.0
  • REComposeViewController ~> 2.0
  • PocketAPI ~> 1.0.2
  • SFHFKeychainUtils ~> 0.0.1
  • AFXAuthClient ~> 1.0.5

For some one only want their apps the same behavior as pre installed apps (such as Photos app) under iOS 6 (show Twitter/Facebook/SinaWeibo as share options, even if corresponding account is not set up in iOS Settings.), and provide modern UI under iOS 5, there is no need to depend on lots external libraries.

REActivityViewController is more powerful, but OWActivityViewController is more slim; they are different.

iOS 6.x iOS 5.x
Screenshot under iOS 5.x Screenshot under iOS 6.x

GitHub

0

How can we programmatically detect which iOS version is device running on

-

Best current version, without need to deal with numeric search within NSString is to define macros(See original answer: Check iPhone iOS Version)

Like this:

  1. #define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
  2. #define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
  3. #define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
  4. #define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
  5. #define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) 
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) 
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) 
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

and use them like this:

  1. if (SYSTEM_VERSION_LESS_THAN(@"5.0")) {
  2. // code here
  3. }
  4. if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) {
  5. // code here
  6. }
if (SYSTEM_VERSION_LESS_THAN(@"5.0")) { 
// code here 
} 
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"6.0")) { 
// code here 
}
0

chartee

-

Chartee is a charting library which currently supports ios platform. Can use chartee to draw bar chart, line chart, diagram, plot chart and so on.

GitHub

1 2 3 4 5 6 7 8 9 10 11 12 ... 32 »