3

OSX has functionality not available in the iOS SDK, and occasionally I'll find an answer like this one: no route.h on the iPhone SDK, that says "just copy the header file from the Simulator (or OSX) SDK and it'll work fine."

That seems suspect to me on multiple levels, including App Store approval, but then I read something like this from an Apple employee who says "if you're using sys/route.h declarations on iOS for an App Store app, please get in touch with me...", which sounds like tacit approval (or a ruse to catch misbehavior :)

Anyone know where the official line really is, and whether something like this is at all safe to do in production code? I'm particularly interested in lower-level BSD functions and whatnot for portability, as opposed to undocumented Objective-C methods.

Community
  • 1
  • 1
Eric McNeill
  • 1,784
  • 1
  • 18
  • 29

2 Answers2

3

I would not regard that comment on the Apple forums as tacit approval. It sounds like they're just trying to decide if some additional BSD APIs should be added for use in iOS apps.

In general, if there isn't an iOS header available for a function, then it's considered a Private API (for example, something under https://developer.apple.com/library/ios/). The official policy on Private APIs is that they're not to be used in apps distributed through the App Store.

Now, you can certainly use them for personal/hobby apps, or apps that you deploy in-house (Enterprise Distribution).

If the APIs you're talking about are APIs that are publically documented for OS X, and you can get them to work for iOS by copying headers, then they're probably part of the Darwin source base. It's very likely that they'll continue to function in future versions of iOS, although that's not guaranteed. Of course, nothing is guaranteed (really), as public APIs get deprecated, too.

Then, there's the issue that not all review checks are automated (I don't work for Apple, but can deduce this from things I've seen get through review). It isn't that unusual for apps to be approved with Private API usage, although if they get popular, Apple frequently pulls those apps from the store within a couple weeks. The review process isn't perfect.

So, my answer is that if you're submitting to the app store, don't expect copying in headers to work.

P.S. If you can tell us specifically which BSD function you're referring to, we might be able to give you a better answer.

P.P.S. The answer you link to about Route.h is from Grant Paul, who writes quite a bit of non-App Store software.

Additional useful information on Private APIs and the App Store

Community
  • 1
  • 1
Nate
  • 31,017
  • 13
  • 83
  • 207
  • Thanks all for the comments. Marking this as the answer for clarifying the situation and the prudent advice "if you're submitting to the app store, don't expect copying in headers to work". It's not something I'm willing to place a big bet (in dev costs) on. – Eric McNeill May 30 '13 at 16:30
  • Yep, you'd be taking a risk. Sometimes, it's worth it, but that depends on your app, its potential payoff, schedule sensitivity, and alternatives for implementing the required features if you **don't** use the undocumented solution. – Nate May 30 '13 at 20:52
1

Apple never knows what header files you use - the danger of course is the definition from the copied file is close to, but not exactly, what iOS uses. If this file is important, or a few select files, post a question on Apple's internal forums and you will surely get an answer to such a question. Failing that, burn a DTS incident (you get two a year, I almost never use mine).

David H
  • 40,852
  • 12
  • 92
  • 138
  • 1
    I honestly avoid using technical support incidents for stuff like this, under the heading of *it's easier to ask for forgiveness than permission*. That's why I think SO is an important resource for asking questions that quite frankly, you don't really want to ask Apple directly. Not an ideal situation, though, I admit. – Nate May 30 '13 at 00:06
  • Posting on the internal site will likely result in some response by Apple. Quinn is very active there, and often responds that some issue should result in a bug report as it is a valid issue. Just laying out the options... – David H May 30 '13 at 11:00
  • Oh, I don't doubt that they'll respond. My point is that *sometimes*, you might not necessarily want to ask them, if it's a gray area (which this question sounds like it might be). – Nate May 30 '13 at 11:35
  • Unless you write them on corporate stationary, send a certified letter, etc - its unimaginable that somehow someone records your name and then a half year later scrutinizes your app for anything that looks odd. There are several things you can do with systl() that work but are undocumented (well, in any place I could ever find). – David H May 30 '13 at 11:59
  • I don't use corporate stationary, but if I did, it would be a considerable amount of work for Apple to search its content. If I post on a user forum, they only need 10 seconds and a web browser to do so. If you (a) already asked for permission, and they told you "no", or (b) they hadn't decided on policy for a given API yet, but your question forced them to, then your app approval could be negatively impacted. I find either of those scenarios rather more likely than *"unimaginable"*. – Nate May 30 '13 at 20:46
  • 1
    @Nate, tell you what - if someone writes the question here (or emails it to me see my profile), I will post it under my name, then if I get an answer I'll update this question with it. – David H May 30 '13 at 21:41