0

I have to use some private functions, like:

SCDynamicStoreRef
SCDynamicStoreCreate            (
                    CFAllocatorRef          allocator,
                    CFStringRef         name,
                    SCDynamicStoreCallBack      callout,
                    SCDynamicStoreContext       *context
                    )               __OSX_AVAILABLE_STARTING(__MAC_10_1,__IPHONE_NA);

By default they are not allowed for iphone, so I've changed declaration of them in my .m file. But now it shows "Availability does not match previous declaration" warning. How to suppress this warning?

enter image description here

Sergey Demchenko
  • 2,924
  • 1
  • 24
  • 26
  • 1
    make it match to previous declaration? – Bryan Chen Apr 17 '14 at 08:20
  • @BryanChen In order to use private api I have to change availability of these functions (by default they are not allowed for iphone) – Sergey Demchenko Apr 17 '14 at 08:30
  • You actually *can* change the original SDK headers, to replace `__IPHONE_NA` with `__IPHONE_2_0`. That should fix this problem. Of course, if you do that, you might not get the warning on other projects, where you are building for the app store. – Nate Apr 18 '14 at 03:15
  • @Nate, yes I can. Also we can copy & paste default framework into project folder, but we need to copy it 2 times (for iphone & simulator architectures) and then change headers. But I think my solution above is more accurately. – Sergey Demchenko Apr 18 '14 at 04:12

1 Answers1

2

With the usual disclaimer that using private APIs might cause your app to be rejected: You can suppress the warning with

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wavailability"
…
#pragma clang diagnostic pop

It might also cause crashes or other failures if that function is present in the iOS frameworks, but with different parameters.

Martin R
  • 529,903
  • 94
  • 1,240
  • 1,382