Skip to content

Commit 9e751a6

Browse files
authored
Merge pull request #2 from OutSystems/feat/RNMT-4440/review-build-warnings
MABS 7 ::: iOS 14 ::: Review build warnings in Core plugins
2 parents 6380d04 + 5c39b8b commit 9e751a6

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/ios/RSSwizzle.m

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#import "RSSwizzle.h"
1010
#import <objc/runtime.h>
1111
#import <libkern/OSAtomic.h>
12+
#import <os/lock.h>
1213

1314
#if !__has_feature(objc_arc)
1415
#error This code needs ARC. Use compiler option -fobjc-arc
@@ -196,7 +197,8 @@ static void swizzle(Class classToSwizzle,
196197
NSCAssert(blockIsAnImpFactoryBlock(factoryBlock),
197198
@"Wrong type of implementation factory block.");
198199

199-
__block OSSpinLock lock = OS_SPINLOCK_INIT;
200+
__block os_unfair_lock lock = OS_UNFAIR_LOCK_INIT;
201+
200202
// To keep things thread-safe, we fill in the originalIMP later,
201203
// with the result of the class_replaceMethod call below.
202204
__block IMP originalIMP = NULL;
@@ -206,9 +208,9 @@ static void swizzle(Class classToSwizzle,
206208
// It's possible that another thread can call the method between the call to
207209
// class_replaceMethod and its return value being set.
208210
// So to be sure originalIMP has the right value, we need a lock.
209-
OSSpinLockLock(&lock);
211+
os_unfair_lock_lock(&lock);
210212
IMP imp = originalIMP;
211-
OSSpinLockUnlock(&lock);
213+
os_unfair_lock_unlock(&lock);
212214

213215
if (NULL == imp){
214216
// If the class does not implement the method
@@ -244,9 +246,9 @@ static void swizzle(Class classToSwizzle,
244246
//
245247
// We need a lock to be sure that originalIMP has the right value in the
246248
// originalImpProvider block above.
247-
OSSpinLockLock(&lock);
249+
os_unfair_lock_lock(&lock);
248250
originalIMP = class_replaceMethod(classToSwizzle, selector, newIMP, methodType);
249-
OSSpinLockUnlock(&lock);
251+
os_unfair_lock_unlock(&lock);
250252
}
251253

252254
static NSMutableDictionary *swizzledClassesDictionary(){
@@ -319,4 +321,4 @@ +(void)swizzleClassMethod:(SEL)selector
319321
}
320322

321323

322-
@end
324+
@end

0 commit comments

Comments
 (0)