Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed - Xcode erros. CDVFileTransfer.m:304:54: Incompatible operand types ('id' and 'CGPathRef' (aka 'const struct CGPath *')) #18

Closed
wants to merge 1 commit into from

Conversation

emarashliev
Copy link

Fixed - Xcode erros. CDVFileTransfer.m:304:54: Incompatible operand types ('id' and 'CGPathRef' (aka 'const struct CGPath *'))

@shortstuffsushi
Copy link

Would someone with authority on this project (@agrieve?) like to take a look and help us out? I'd really like to use the updated CocoaPod, but can't do so until this is fixed.

@agrieve
Copy link
Contributor

agrieve commented Mar 5, 2014

Thanks for the ping. I haven't noticed any compile errors with this plugin. Are you turning on extra compiler flags to reproduce this?

I notice the pull requests switches source to target. Is that intentional?

@shortstuffsushi
Copy link

Sorry, sending from my iPod and sick :(

I don't have any flags, just the Xcode default. I see that the code is technically vlid, but since it returns an ID, Xcode can't tell. If you used alloc init. Instead, it work work.

The pull request is another way you could do it (force cast). The target/source replacement is because he used older source I believe. In earlier versions, it was target, now it's source. Ultimately, it's a typo, but the idea behind it is correct.

Sent from my iPod

On Mar 5, 2014, at 3:20 PM, agrieve [email protected] wrote:

Thanks for the ping. I haven't noticed any compile errors with this plugin. Are you turning on extra compiler flags to reproduce this?

I notice the pull requests switches source to target. Is that intentional?


Reply to this email directly or view it on GitHub.

@agrieve
Copy link
Contributor

agrieve commented Mar 11, 2014

I don't see this error/warning using Xcode 5.0.2. What version do you see this in?

@shortstuffsushi
Copy link

I'm using either 5.0.2 or 3 (most recent). I have a fresh Xcode project with this project added as a Cocoapod dependency. I can attach it if you'd like.

Graham

On Mar 11, 2014, at 1:25 PM, agrieve [email protected] wrote:

I don't see this error/warning using Xcode 5.0.2. What version do you see this in?


Reply to this email directly or view it on GitHub.

@emarashliev
Copy link
Author

Hi, I'm also using this plugging as Pod (CococaPods). This fix represent the same but with other (better) syntax. If we disregard of build errors when we use CocoaPods, also for me it looks really ugly to use ternary operators in Objective-C . Objc is expressive and long naming language, such things are unwelcome.

@shortstuffsushi
Copy link

I don't know that I'd say the existing code is bad, or even wrong. Ternary and coalescing operators are commonly used in Objective-C. There aren't really any standards around the various Cordova repositories, so I don't think it's an issue. In fact, your pull request here is using a variable that doesn't exist, which wouldn't fix the problem either :(

The ultimate problem is that [NSURL URLWithString:source] returns an id which Xcode is incorrectly attempting to cast to a CGPathContext, if I remember correctly. That class does not have a path selector, and consequently Xcode incorrectly assumes the line is invalid.

To fix this, you can use any of these chunks of code, depending on your preference. They'll all work.

NSString *filePath = [source hasPrefix:@"/"] ? [source copy] : [(NSURL *)[NSURL URLWithString:source] path];
NSString *filePath = [source hasPrefix:@"/"] ? [source copy] : [[NSURL alloc] initWithString:source] path];
NSString *filePath;
if ([source hasPrefix:@"/"]) {
    filePath = [source copy];
}
else {
    filePath = [(NSURL *)[NSURL URLWithString:source] path];
    // or
    filePath = [[NSURL alloc] initWithString:source] path];
}
NSURL *url = [NSURL URLWithString:source]; // or [[NSURL alloc] initWithString:source];
NSString *filePath = [url path];

@agrieve, could you choose one and pull it in to close this issue out, please?

@clelland
Copy link
Contributor

I still don't quite understand how you're getting errors in XCode from the default settings (I see the issue as a warning if I use -Wstrict-selector-match, but definitely no errors, and clang has no problem producing correct code here.)

At any rate, I'll make the change, and see about finding other occurrences in the codebase too, if it's possible for this to trip people up.

@shortstuffsushi
Copy link

Here's a fresh project for you. Absolutely no code on my side, all generated. The only pod included is Cordova/Plugins. When I build, I see 4 Warnings and 1 Error -- the above. Hopefully you'll see the same, otherwise... something between our environments must be different some how.

@clelland
Copy link
Contributor

I see the error in your project, without any changes. Still no idea why it shows up in one but not the other. Possibly something to do with the CocoaPods packaging. It's pretty strange, anyway.

@clelland
Copy link
Contributor

Can you test the code on the dev branch, and close the pull request if it's all good now?

@shortstuffsushi
Copy link

Looks good, fixes the issue. Unfortunately, I don't own the pull request, but I approve 👍

@asfgit asfgit closed this in 1adf1c7 Jun 27, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants