pinterest / PINCache

Fast, non-deadlocking parallel object cache for iOS, tvOS and OS X
Apache License 2.0
2.66k stars 361 forks source link

Fix PINCaching compiling in Xcode 12.0b6 (#275) #281

Closed SAGESSE-CN closed 3 years ago

SAGESSE-CN commented 4 years ago

Reference: https://reviews.llvm.org/D66831#2019125

garrettmoon commented 4 years ago

@sagesse-cn I'm not seeing any errors compiling on Xcode 12 beta 6. Can you provide more info?

garrettmoon commented 4 years ago

Specifically, if you could point out how I can reproduce it, that would be very helpful!

bluemachine commented 4 years ago

When we install the pod PINRemoteImage - it installs with following pods

Installing PINCache (3.0.1-beta.8) Installing PINOperation (1.1.2) Installing PINRemoteImage (3.0.0)

To update as suggested - when we install PINCache it updates to latest version but installs an older version of PINRemoteImage and followings pods.

Installing FLAnimatedImage (1.0.12) Installing PINCache 3.0.1 (was 3.0.1-beta.8) Installing PINOperation 1.2 (was 1.1.2) Installing PINRemoteImage 2.1.4 (was 3.0.0)

This gives 4 build errors - screenshots below Screenshot 2020-09-08 at 20 50 41 Screenshot 2020-09-08 at 20 50 52 Screenshot 2020-09-08 at 20 51 00 Screenshot 2020-09-08 at 20 51 10

Hope this helps in recreating the issue.

SAGESSE-CN commented 4 years ago

Specifically, if you could point out how I can reproduce it, that would be very helpful!

Reproduce

In any dependent PINCache project.

PINMemoryCache *cache = [[PINMemoryCache alloc] init];
cache.didAddObjectBlock = ^(PINMemoryCache *cache, NSString * _Nonnull key, id  _Nullable object) {
    // do something.
};

Reason

The compile error in PINCache project was fixed in #276.

But that solution was not the best, any users for using PINCache may need to make a lot of changes.

The block signature is void(^)(PINMemoryCache *, NSString *, id), this is a correct signature, can't limit users must to use void(^)(id<PINCaching>, NSString *, id).

A better solution is to add the __kindof into id<PINCaching>, user not need to modify code, just simply update the Cocoapods dependency.

About why must to add __kindof, see reference.

Thx!

Plnda commented 3 years ago

Could we get some traction on this PR, What is currently blocking it?

natebirkholz commented 3 years ago

What is holding up approval of this PR? I cannot get my work done without it.

natebirkholz commented 3 years ago

Reference: https://reviews.llvm.org/D66831#2019125

I get the latest with your changes and I still get two incompatible pointers.

PINCache.m line 109; [self->_memoryCache objectForKeyAsync:key completion:^(PINMemoryCache and line 232: [_diskCache synchronouslyLockFileAccessWhileExecutingBlock:^(PINDiskCache *diskCache)

natebirkholz commented 3 years ago

Reference: https://reviews.llvm.org/D66831#2019125

@sagesse-cn

SAGESSE-CN commented 3 years ago

Reference: https://reviews.llvm.org/D66831#2019125

@sagesse-cn

Can you provide more information, a demo that depyon to pincache?

natebirkholz commented 3 years ago

Reference: https://reviews.llvm.org/D66831#2019125

@sagesse-cn

Can you provide more information, a demo that depyon to pincache?

@sagesse-cn My bad, the pod updates but something somewhere in this large legacy project I took over is specifying an earlier version of PINCache, so in my Xcode project it is an old version.