Original post at http://support.backendless.com/t/ios-sdk-cast-problem , which is marked Cannot reproduce. But I believe I identified the cause of the problem and how you can reproduce now.
Just change $(PROJECT_BUNDLE_IDENTIFIER) $(PROJECT_NAME) in your info.plist file to some text, then you should have this cast problem.
http://support.backendless.com/public/attachments/8b6e222e53f2d457c51b8f20a19477d6.jpg</img>http://support.backendless.com/public/attachments/ce71a81f3bdf9cbba374df0e678e6d51.jpg</img>
Gordon,
I am not sure why the change makes the effect on casting (this will be researched further), however, see this discussion: http://stackoverflow.com/questions/33122484/use-bundle-identifier-instead-of-product-bundle-identifier-with-xcode-7
It sounds like changing bundle identifier in plist is not recommended by Apple
Mark
Thank you Mark. I do not recall change it in the info.plist file at all. Probably got updated from XCode 6 and stayed that way.
Maybe you can add a known issue section to the documentation so next person does not need to spend too much time.
Hi Gordon,
Swift class has a format <TargetName>.<ClassName> at the runtime. Backendless SDK uses a bundle name to get <TargetName> for class object serialization:
+(NSString *)targetName {
NSString *data = [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleName"];
NSMutableCharacterSet *charSet = [NSMutableCharacterSet punctuationCharacterSet];
[charSet addCharactersInString:@"~`$^+=|<> "];
return [[data componentsSeparatedByCharactersInSet:charSet] componentsJoinedByString:@"_"];
}
But it works only if ‘Bundle Name’ == $(PRODUCT_NAME), you shouldn’t change this default option.
Regards,
Slava
I did not change it. It was like that before I switch to use Backendless. It may be an old thing from XCode6. I would suggest you surface a more detailed error message when this problem is detected. Right now, if user has this bad configuration, they will be able to call Backendless successfully but then fail to cast with an error message that is not helpful at all
I know this is marked as solved already. But I would really urge you to consider my suggestion of surface a more detailed error message.
Hi Gordon,
For working with Backendless SDK you should set ‘Bundle Name’ == $(PRODUCT_NAME), now it is important for class casting in swift, because custom class representation contains target name in runtime (its format is <TargetName>.<ClassName>).
We need a time to find a decision which switches off this dependence. We let you know about this remake.
Regards,
Slava
Hi Vyacheslav,
My suggestion is more about documentation. I’m sure you are seeing a surge of Parse developers migrating to your platform recently. A lot of us have old or messed up code, where maybe the ‘Bundle Name’ is messed up. I think the lowest hanging fruit is that you add in your documentation or the Parse migration guide an entry about this problem. This will benefit you to win Parse developers over.
The second thing is that there is a disconnect between the appearance of the problem and the actual cause of the problem. What you should do is when you detect that the Bundle Name is not setup properly, fail immediately. This is the principle of fail early. Currently, you do not fail and project initiate works, retrieve records works, everything works until user try to cast.
Switch off the dependence would be the final solution but that can happen later.
–Gordon