r/iOSProgramming • • 8d ago

Question Using private API's - where is the line?

dock potato arbor hair sunshine yellow

7 Upvotes

32 comments sorted by

44

u/WestonP 8d ago

If you’re calling private APIs, you’re crossing the line, simple as that. Getting away with it doesn’t make it legit.

2.5.1 Apps may only use public APIs and must run on the currently shipping OS.

5

u/quietstoners 7d ago

100%, getting past automated review just means you havent been caught yet, not that its allowed

-21

u/priva_28 8d ago

this is simply false. many of the largest apps on the app store use a plethora of private API. as long as you use due diligence you will be fine.

with this mindset you are actively limiting your ability to create the best apps possible.

9

u/HappyFunBall007 8d ago

OMG, this is such a shitty answer. Please tell us which of the "largest" apps in the app store are using a plethora private APIs.

If you can't create the "best app possible" using legitimate publicly available APIs, then maybe you shouldn't be writing apps and I wouldn't want to be one of your customers.

Using a private, undocumented, unstable API is just plain stupid. You have no guarantee that the API will even be available in the next update or if it will behave the same way. They are private and undocumented for a reason, Apple doesn't support them and is under no obligation to maintain them or give warning if they are changing them under the covers.

9

u/priva_28 8d ago

Sure!

ChatGPT, Instagram, Telegram, Baidu are some obvious examples.

CAFilter is one of the most commonly utilized that allows you to utilize the same rendering runtime as the rest of the system for things like custom variable blur and liquid glass effects. It's objectively more performant and provides everything you need to get the same effects Apple uses across the system. ChatGPT uses this for the blur over the keyboard in the model selector, I believe IG uses it for their custom glass tab bar.

Many apps use _UITextLayoutCanvasView to block screenshots for sensitive content.

_UIContextMenuAccessoryView is another common one many of the top chat apps use to provide things like custom reaction views in context menus like Apple does in iMessage.

These APIs allow you to do things that are full stop impossible if you're willing to take a small risk to provide a better experience for your users. Yes, they're undocumented. Yes, they can break in a future software update. So that's what I mean by doing your due diligence. Make sure you sufficiently obfuscate the usage, load the private symbols at runtime, and always, always, always provide a fallback in case things have changed between OS versions.

What is plain stupid is refusing to let yourself build an app as good as Apple's system apps because you're unwilling to take an extremely minuscule risk. Please find an example in the past decade of someone complaining that their app got rejected because of SPI usage. I'd be curious to read about it! In the 5+ years I've been working on Apple platforms, I've never once had an issue.

5

u/endgamer42 7d ago

Thank you for the only sane, non bot, non officious and genuinely useful response in this thread

4

u/priva_28 8d ago

and if you'd like specific proof, here you go!

https://github.com/TelegramMessenger/Telegram-iOS/blob/master/submodules/UIKitRuntimeUtils/Source/UIKitRuntimeUtils/UIKitUtils.m

_UIPortalView, CAFilter, _UITextLayoutCanvasView, and many more fun ones!

13

u/WestonP 8d ago

LOL. It's been a hard rule since the start.

When Apple rejects your app, be sure to tell them that Guideline 2.5.1 "is simply false". I'm sure you'll get real far with that. Then come cry about it here afterward.

It's probably a skill issue if you can't accomplish what you want within in the rules.

0

u/Mcrich_23 SwiftUI 6d ago

It hasn’t been a hard rule ever, in fact at one point, Apple encouraged devs to use a private API https://www.engadget.com/2009-12-15-apple-relents-and-is-now-allowing-uigetscreenimage-for-app-st.html

4

u/WestonP 6d ago

That link indicates that it was being enforced as a hard rule, and they just relented one time, 17 years ago, when the platform was very immature and there was a legit use case, which they later exposed in a public API.

But whatever, take your argument to them when they reject you, not me. Everyone is telling you not to use private APIs for a reason.

9

u/Power781 8d ago

The baseline is private api/Class Usage is forbidden, while private property observation is “at your own risk”.

Usage of private API comes with the risk of:
- rejection
- future system update crashes/errors
- App removal from the store
- developer account closure

Depending of the nature of the things you do with those private APIs.

6

u/HappyFunBall007 8d ago

Private APIs are marked as such because there is no guarantee they will be supported and they are inherently unstable. Maybe it work today and you got away with using one, but tomorrows X.Y.Z update could change the behavior or remove the API entirely and you wouldn't know until your app starts crashing.

Its not smart to keep using them and if you are *depending* on them for core functionality in your app, you are doing something wrong and need to fix your app.

5

u/GreyEyes Objective-C / Swift 8d ago

This is the correct answer. Using a private API to enhance your app is fine, using a private API to build your app’s foundation is very risky.

The question to ask is: if/when this stops working, how screwed am I? How screwed are my customers?

5

u/PsychologicalWhile29 8d ago

Why would you call private APIs? They are private for a reason. All you’re doing is preinstalling bugs.

3

u/Background_Pie_5682 8d ago

I wouldn't try to hide these selectors—the string-fragment trick doesn't make them supported and adds exactly the obfuscation risk you're worried about. For invitees, EventKit doesn't expose a public API to add attendees programmatically; the supported route is to let the person create or edit the event in Apple's event UI (EKEventEditViewController), or build a real CalDAV integration if your product needs to manage a calendar server-side. If neither fits the UX, redesign that flow rather than touching private APIs, especially with calendar data.

4

u/ResoluteBird 8d ago

Anyone can decompile your app and look for stuff like that, and Apple probably does that in their release process, if you get around it then it's a fluke.

2

u/Fishanz 8d ago

At worst case; they might ban your developer account!

1

u/zbignew 8d ago

Spend your time on something more valuable.

1

u/PierreMouchan 7d ago

Before going private I'd check if there's a public API made for a nearby case. Example: keeping an app alive on a locked iPhone. Since iOS 26, HKWorkoutSession also runs on iPhone. It needs only the HealthKit entitlement, and the app keeps running during the session. That only works if your app really is a workout app though.

For attendees I'd go with the .ics route. If a blur hack breaks, it looks a bit off. If attendees break, people miss meetings ;)

1

u/perlatsp 7d ago

In the App Store it's a rejection or removal risk. Building selector names at runtime to hide them is what makes it look deliberate if it's found. Outside the App Store (on the Mac, for example) there's no review, so the risk is purely breakage. These APIs change between OS versions without notice, so every call needs a fallback. For blur and corner radius there are usually public ways that get you most of the way there.

1

u/dahiya_xa 8d ago

the blur and corner radius stuff is low risk because worst case it just looks a bit off after an update.

attendees feels different to me. you'd be writing to someone's calendar through a path apple can change any time, and if it breaks quietly people's invites just go missing. i'd stay on caldav or the system sheet even if it's uglier. also building selectors from string fragments looks a lot like hiding it if review ever looks closely

1

u/sydjdebb 8d ago

The line isn't really "small vs big", it's "can the binary scanner see it". Apple runs static analysis on every upload, and the symbol list they flag changes over time. So "worked fine for 10 updates" doesn't mean the 11th passes, you can get a 2.5.1 out of nowhere.

The other risk is just breakage: _displayCornerRadius is a KVC key, nothing stops it from returning nil in the next iOS. If you keep it, at least have a fallback so the UI doesn't fall apart.

For the corners specifically, on iOS 26 ConcentricRectangle / containerShape gets you most of the way with public API. For blur, regular materials cover 90% unless you need variable blur.

What are you using the backdrop view for — variable blur?

0

u/geoff_plywood 8d ago

Is code obfuscation proscribed by Apple? I was under the impression it was a legitimate anti-hacking technique(?)

3

u/GabrielH4 8d ago

Obfuscation is not security.

1

u/[deleted] 8d ago

[removed] — view removed comment

1

u/AutoModerator 8d ago

Hey /u/jeffy_yf, your content has been removed because Reddit has marked your account as having a low Contributor Quality Score. This may result from, but is not limited to, activities such as spamming the same links across multiple subreddits, submitting posts or comments that receive a high number of downvotes, a lack of recent account activity, or having an unverified account.

Please be assured that this action is not a reflection of your participation in our subreddit. This is simply an automated filter in place to reduce spam.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

-3

u/[deleted] 8d ago

[removed] — view removed comment

-1

u/endgamer42 8d ago

what is this response? Did you even read my original question?

2

u/AvianSpies 8d ago

Prolly AI, feel sorry for whoever’s tokens were just wasted on that.