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.