2 ms·
That's not what is meant by private APIs. There's a difference between the ability to call an API and getting a specific result of the API. What you're linking
by vlozko 5y ago
That's not what is meant by private APIs. There's a difference between the ability to call an API and getting a specific result of the API.
What you're linking to are entitlements. The APIs for these entitlements are very much public but will not yield a valid result if the entitlement is missing or the user hasn't provided access. Private APIs, on the other hand, will return valid results each time. However, they are often hidden behind actual public APIs. For example, take these two stack frames:
9 UIKitCore -[UITableView _reuseTableViewCell:withIndexPath:didEndDisplaying:] + 268
10 UIKitCore __25-[UITableView reloadData]_block_invoke + 184
The reloadData call is a valid, public API call. Internally, it then calls the function in frame 9. Calling the function in frame 9 directly from within app code would be a private API violation. The Objective-C runtime makes it pretty easy to call private APIs through use of target/selectors and msgSend. I don't believe checking at runtime if a private API call is made is practical. For one, I'm not sure how technically feasible it would be but worse, there would be a performance penalty accrued with every private API. More importantly, though, the app would already be out in the wild. Compile-time and app review is really the only time to check. To the best of my knowledge, I'm not sure there's a way to force a private API call within Swift, particularly for classes that don't inherit from NSObject or are functions not tagged with @objc.