Facebook Twitter Gplus LinkedIn RSS
 
 
Home » Blog » Fix the Warnings in PhoneGap 3.0

Fix the Warnings in PhoneGap 3.0

Published on October 4th, 2013

With the move to PhoneGap 3.0, we are moving to a 64-bit framework, and as such, there are a few legacy bugs that exist. Nothing big of course, just warnings, but for someone that likes to see a clean error log before submitting to the App store, it can be annoying.

Here are the errors:

hello/platforms/ios/CordovaLib/Classes/CDVURLProtocol.m:168:46: Implicit conversion loses integer precision: ‘long long’ to ‘unsigned long’
hello/platforms/ios/CordovaLib/Classes/CDVURLProtocol.m:169:100: Implicit conversion loses integer precision: ‘long long’ to ‘NSUInteger’ (aka ‘unsigned int’)

If you open up the CDVURLProtocol.m file in xcode, you find these two lines of code at lines 168 and 169.

1
2
Byte* buffer = (Byte*)malloc([assetRepresentation size]);
NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:[assetRepresentation size] error:nil];
Byte* buffer = (Byte*)malloc([assetRepresentation size]);
NSUInteger bufferSize = [assetRepresentation getBytes:buffer fromOffset:0.0 length:[assetRepresentation size] error:nil];

The fix is rather easy. All you need to do is typecast the variables as follows.

1
2
Byte* buffer = (Byte*)malloc((unsigned)[assetRepresentation size]);
NSUInteger bufferSize = (NSUInteger)[assetRepresentation getBytes:buffer fromOffset:0.0 length: (NSUInteger)[assetRepresentation size] error:nil];
Byte* buffer = (Byte*)malloc((unsigned)[assetRepresentation size]);
NSUInteger bufferSize = (NSUInteger)[assetRepresentation getBytes:buffer fromOffset:0.0 length:	(NSUInteger)[assetRepresentation size] error:nil];

It really is that simple and cleans up those warnings right quick.

About the Author: Sprawl

Stephen Russell is a Mobile App developer and all around IT geek that spends his days running data centers and his nights coding. This site is the go to place for all of zSprawl's work and the infamous development blog. In his free time, he enjoys tinkering with web code, playing video games, and otherwise plotting to take over the Internets.

 

Leave a Reply

© 2012 zSprawl's zApps

Fork me on GitHub