erikdoe / ocmock

Mock objects for Objective-C
http://ocmock.org
Apache License 2.0
2.16k stars 606 forks source link

Building for macOS 10.9 or iOS 7.0 deployment target fails #344

Closed sdefresne closed 7 years ago

sdefresne commented 7 years ago

The file NSInvocation+OCMAdditions.m uses the function object_isClass that was only made available in iOS 8.0+ and macOS 10.10+ SDKs. This mean that if the project deployment target is below those version (usually macOS 10.9) the build will fail with the following error:

Source/OCMock/NSInvocation+OCMAdditions.m:58:8: error: 'object_isClass' is only available on macOS 10.10 or newer [-Werror,-Wunguarded-availability] !object_isClass(target)) { ^~~~~~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/objc/runtime.h:151:18: note: 'object_isClass' has been explicitly marked partial here OBJC_EXPORT BOOL object_isClass(id obj) ^ Source/OCMock/NSInvocation+OCMAdditions.m:58:8: note: enclose 'object_isClass' in an @available check to silence this warning !object_isClass(target)) { ^~~~~~

This happens when building with -mmacosx-version-min=10.9.0 even if the SDK used is recent enough.

sdefresne commented 7 years ago

The Swift runtime has a re-implementation of object_isClass function to allow compilation with a deployment target of 10.9. Given that Swift is mostly developed by Apple, I guess the re-implementation can be lifted to allow compilation of OCMock for the same deployment target.

Fix is https://github.com/apple/swift/pull/11467/commits/0475307c08.

erikdoe commented 7 years ago

Thanks! Have merged the PR now.