Tim
Tim

Reputation: 1894

Overriding a constant value at runtime

I'm using some external library via cocoapods and was requested to customize its standard behavior. I found out, that this behavior depends on a constant, declared in a library.

Like so

static const NSString *CONSTANT_NAME = @"..";

This constant is used throughout the code, so swizzling every affected method and duplicating the code would be a very dirty workaround.

Certainly, I could just edit the source file, but the constant will be rolled back to its original state every time i do

pod update

So, I wonder if there is a nice way to solve the issue. Perhaps, at runtime.

Thanx in advance!

Upvotes: 2

Views: 216

Answers (1)

trojanfoe
trojanfoe

Reputation: 122421

You'll have to stop using cocoapods and start using your own branch of the git repo, with your modified constant.

Another approach is to modify the source so that this constant can be configured at runtime (i.e. no longer a constant) and send a pull request to the author.

Viva la open source!

Upvotes: 1

Related Questions