So despite my having about zero experience in Xcode, and iOS development, I was asked to try to update some config string in an Xcode project that was an app deployed to the iOS marketplace some time ago. In theory it all should just work, but of course it doesn't.
When I build it complains about a class not conforming to protocol NSCopying and it has an option to add a stub to fix.
But that just adds something to the end of the file and i don't know what it is wanting to be in this stub to get it to stop failing.
- (nonnull id)copyWithZone:(nullable NSZone *)zone {
code
}
And the code part is added there by default, which you probably already know.
I'd appreciate any advise on what this is expecting. I suspect there may be other factors for why the build succeeds but the app crashes and points to this line. I don't know when the app was made, what version it was supposed to be targeting or what. I just have an xcode project in the last known state. here is the original ParseClientConfiguration class:
#import "ParseClientConfiguration.h"
#import "ParseClientConfiguration_Private.h"
#import "PFAssert.h"
#import "PFApplication.h"
#import "PFCommandRunningConstants.h"
#import "PFFileManager.h"
#import "PFHash.h"
#import "PFObjectUtilities.h"
NSString *const _ParseDefaultServerURLString = @"https://api.somewhere.com/1";
@implementation ParseClientConfiguration
///--------------------------------------
#pragma mark - Init
///--------------------------------------
+ (instancetype)emptyConfiguration {
return [[super alloc] initEmpty];
}
- (instancetype)initEmpty {
self = [super init];
if (!self) return nil;
_networkRetryAttempts = PFCommandRunningDefaultMaxAttemptsCount;
_URLSessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
_server = [_ParseDefaultServerURLString copy];
return self;
}
- (instancetype)initWithBlock:(void (^)(id<ParseMutableClientConfiguration>))configurationBlock {
self = [self initEmpty];
if (!self) return nil;
configurationBlock(self);
PFParameterAssert(self.applicationId.length, @"`applicationId` should not be nil.");
return self;
}
+ (instancetype)configurationWithBlock:(void (^)(id<ParseMutableClientConfiguration>))configurationBlock {
return [[self alloc] initWithBlock:configurationBlock];
}
///--------------------------------------
#pragma mark - Properties
///--------------------------------------
- (void)setApplicationId:(NSString *)applicationId {
PFParameterAssert(applicationId.length, @"'applicationId' should not be nil.");
_applicationId = [applicationId copy];
}
- (void)setClientKey:(NSString *)clientKey {
_clientKey = [clientKey copy];
}
- (void)setServer:(NSString *)server {
PFParameterAssert(server.length, @"Server should not be `nil`.");
PFParameterAssert([NSURL URLWithString:server], @"Server should be a valid URL.");
_server = [server copy];
}
- (void)setApplicationGroupIdentifier:(NSString *)applicationGroupIdentifier {
PFParameterAssert(applicationGroupIdentifier == nil ||
[PFFileManager isApplicationGroupContainerReachableForGroupIdentifier:applicationGroupIdentifier],
@"ApplicationGroupContainer is unreachable. Please double check your Xcode project settings.");
_applicationGroupIdentifier = [applicationGroupIdentifier copy];
}
- (void)setContainingApplicationBundleIdentifier:(NSString *)containingApplicationBundleIdentifier {
PFParameterAssert([PFApplication currentApplication].extensionEnvironment,
@"'containingApplicationBundleIdentifier' cannot be set in non-extension environment");
PFParameterAssert(containingApplicationBundleIdentifier.length,
@"'containingApplicationBundleIdentifier' should not be nil.");
_containingApplicationBundleIdentifier = containingApplicationBundleIdentifier;
}
- (void)_resetDataSharingIdentifiers {
_applicationGroupIdentifier = nil;
_containingApplicationBundleIdentifier = nil;
}
///--------------------------------------
#pragma mark - NSObject
///--------------------------------------
- (NSUInteger)hash {
return PFIntegerPairHash(self.applicationId.hash, self.clientKey.hash);
}
- (BOOL)isEqual:(id)object {
if (![object isKindOfClass:[ParseClientConfiguration class]]) {
return NO;
}
ParseClientConfiguration *other = object;
return ([PFObjectUtilities isObject:self.applicationId equalToObject:other.applicationId] &&
[PFObjectUtilities isObject:self.clientKey equalToObject:other.clientKey] &&
[self.server isEqualToString:other.server] &&
self.fileUploadController == other.fileUploadController &&
self.localDatastoreEnabled == other.localDatastoreEnabled &&
[PFObjectUtilities isObject:self.applicationGroupIdentifier equalToObject:other.applicationGroupIdentifier] &&
[PFObjectUtilities isObject:self.containingApplicationBundleIdentifier equalToObject:other.containingApplicationBundleIdentifier] &&
[PFObjectUtilities isObject:self.URLSessionConfiguration equalToObject:other.URLSessionConfiguration] &&
self.networkRetryAttempts == other.networkRetryAttempts);
}
///--------------------------------------
#pragma mark - NSCopying
///--------------------------------------
- (nonnull id)copyWithZone:(nullable NSZone *)zone {
code
}
@end
Thanks for looking. By this point I pretty much expect to hand it back to them and say look, hire an iOS developer. But if I can get it working that would be interesting. I'm kind of curious what this app did.