Python Application Rejected by Apple App Store Due to a Single String?

Follow and star to learn new Python skills every day

Due to changes in the public account’s push rules, please click “View” and add “Star” to get exciting technical shares at the first time

Source from the internet, please delete if infringed

Just because of an upgrade to the programming language version, the developed application was rejected, failed to pass the review, and could not be listed in the app store. This rare occurrence is currently happening to some Python developers.

Recently, according to foreign media LWN, some developers encountered rejection from Apple’s review team when they resubmitted their applications after upgrading the Python version used in their applications from 3.11 to 3.12.

This has attracted the attention of many developers. So, is the problem with Python 3.12 or the Apple review team?

Python Application Rejected by Apple App Store Due to a Single String?

A single string caused the App review failure

Looking back at the incident, it started when a developer named Eric Froemling shared his experience in an issue on the GitHub Python repository, stating:

This is not a traditional bug, but I recently went through a nightmare. My application was updated on Apple’s App Store (specifically the Mac App Store), and because I upgraded the Python version from 3.11 to 3.12, the update was rejected.

Initially, Eric Froemling did not understand why an application that could previously be listed was no longer acceptable after an iteration. Meanwhile, the App Store review team did not directly explain the reason for rejecting Eric Froemling’s app, only coldly replying, “We cannot provide you with more information.”

After much back and forth, Eric Froemling finally could not bear it any longer and submitted an appeal email to the Apple team, which finally provided him with some hints:

According to guideline 2.5.2 – Performance – Software Requirements

The application installs or launches executable code. Specifically, the application uses the itms-services URL scheme to install applications.

To explain briefly, the itms-services URL scheme is a method provided by Apple for distributing and installing iOS applications, typically used for distributing applications not published on the App Store, such as enterprise internal applications or beta applications. It allows users to install applications directly on their iOS devices by clicking a link, without going through the App Store.

Here is a basic structure of an itms-services URL:

itms-services://?action=download-manifest&url=https://example.com/manifest.plist

Where:

  • itms-services://: This is the URL scheme that tells the iOS device that this is an application installation request.

  • ?action=download-manifest: Specifies the action to be performed, which is to download the application manifest file.

  • url=https://example.com/manifest.plist: Specifies the URL of the manifest file, which contains detailed information about the application, including the download address of the application package.

After extensive investigation, Eric Froemling discovered that the problematic file was Lib/urllib/parse.py (the Urllib parser of the Python standard library) and its associated .pyc files. In the Python 3.12 code, it seems that a string “itms-services” was added, and the Apple App Store appears to be scanning for this string and automatically rejecting any content that contains it (at least in Eric Froemling’s case).

Ultimately, after Eric Froemling removed the string from his Python code, the updated app finally passed the review and was successfully listed on the App Store.

Python Application Rejected by Apple App Store Due to a Single String?

Controversial Apple Review and Feedback Rules

What frustrated Eric Froemling was not the “itms-services” string that caused the issue, but the review rules of the Apple App Store.

He stated, “When Apple finally told me that Lib/urllib/parse.py and its associated .pyc files were the problematic files, it was not difficult to trace what happened. Looking back now, I feel very frustrated that I did not think to do a full-text search for itms-services in Python itself earlier, nor did I accidentally discover that others had encountered this situation.”

Currently, Eric Froemling has spent a lot of effort debugging, and just deleting a single string solved the problem. Many developers believe that this could have been avoided through Apple’s transparent review mechanism, but the reality is that Apple’s review mechanism is not transparent.

Python Application Rejected by Apple App Store Due to a Single String?

CPython Core Developer: App Store Review Rules are Paranoid and Elusive!

In response, CPython core developer Russell Keith-Magee, upon seeing the issue submitted by Eric Froemling, immediately published an article titled “Handling Incompatibilities with the App Store Review Process” to address this matter separately.

Python Application Rejected by Apple App Store Due to a Single String?

Russell Keith-Magee stated that this issue also raises an interesting philosophical question for the CPython core development team: How much effort are we willing to put in to adapt to the App Store review process?

Russell Keith-Magee explained that the reason for this situation is that Apple’s macOS App Store automatically rejects any application that contains the itms-services string. The software distributed through Apple’s macOS store is sandboxed, and sandboxed applications are prohibited from using URLs with the itms-services scheme.

Apple’s automatic review process captures the code that handles these URLs in the urllib parser, even if the related application has never used the itms-services:// URL. Since this code exists in the standard library, the application gets rejected.

Some light obfuscation of the string seems to avoid this issue.However, this does not guarantee that it will always solve the problem, and it may cause confusion, nor does it guarantee that this will be the only application validation issue we need to address,” Russell Keith-Magee said, “Although the issue currently arises from a macOS application, similar automatic review processes exist in iOS, Android, and Microsoft platform app stores. Apple’s review is undoubtedly the most… paranoid and elusive… their validation and acceptance processes are completely opaque.”

Returning to the issue itself, the reason for the App review failure was the inclusion of the “itms-services” string in Python 3.12. As for how to resolve this issue officially, Russell Keith-Magee provided two suggestions:

  1. New programming language design goals:Make “compliance with app store requirements” a design goal of CPython and integrate any necessary patches to meet this requirement. This means users do not need to perform any special patching to make CPython “compatible with the app store”; but it also means that sometimes ugly obfuscation code will be merged. If rules change at some point, more patches may be needed; and if an old rule is removed, we will not have a clear signal indicating that a specific obfuscation code is no longer needed.

  2. View this as a distribution issue.During development, use CPython as normal, but later use tools for packaging applications (such as Briefcase, Py2app, Buildozer, etc.) to patch CPython to meet app store requirements. For Briefcase and Buildozer, these tools will also patch and build custom CPython libraries. Historically, this is because CPython does not support iOS and Android; the source code of Python 3.13 can now run without patching… but if we view this as a distribution issue, then patching will become an ongoing requirement.

However, both approaches may lead to the emergence of two new problems, Russell Keith-Magee stated:

  • (1) This approach also means that the distributed Python is not the “official” Python, as it has been modified for distribution; I do not know how we should consider whether there are security or branding risks. I guess the patches that Linux distributions apply when releasing Python are similar to this, and perhaps this is not a problem.

  • For (2), there is an additional question of whether CPython should document the various limitations of App Store reviews that it is aware of.

So, how should CPython handle this obfuscation?

In response, another CPython core developer, Alex Gaynor, proposed a third solution:

Inspired by our experiences with pyca/cryptography. We often receive bug reports saying, “You rejected this certificate, although it is technically invalid, but it was issued by [some widely used device or CA].” Our answer is:

Generally, we will accept PRs that can solve these issues, provided that these PRs are small, localized, and generally not too bad. However, before we merge any PR, someone needs to complain to a third party (such as the Apple App Store) and ensure they are aware of the issue and indicate that they will take some measures to address it. Any solution we accept will have a time limit (i.e., we will remove the solution in a few versions).

This way, users can have a good out-of-the-box experience without large companies simply externalizing their quirky problems onto OSS projects, thus maintaining a balance between the two.

On June 20, Keith-Magee wrote that he thought of another method: instead of obfuscating the source code (which Apple might consider “attempting to evade legitimate security review processes”), it would be better to add an option at build time to remove the code we know is problematic.

The Mac folder would contain a diff describing the changes that need to be applied to the source code tree (in this case, removing support for itms-server URLs in parse.py; but it could be extended if needed).

Configure would gain a –with-app-store-patch option. On most platforms (including macOS), this option would be disabled by default, but enabled on iOS. If enabled, it would apply the patch before building the standard library. This option could also accept a file (i.e., –with-app-store-patch=path/to/patch), so that if the App Store rules change at some point in the future after the maintenance window for a specific Python version closes, distributors still have a supported option to provide updated patches.

Yes, this essentially replicates something that distributors could easily replicate, but the benefit is that CPython, as a project, can provide an official list of changes required for App Store compliance.

Does this sound more acceptable?

Python Application Rejected by Apple App Store Due to a Single String?

In Conclusion

Ultimately, after several days of internal reflection, Keith-Magee replied on June 25, “Thank you for everyone’s opinions, I just submitted #120984 (https://github.com/python/cpython/pull/120984) to implement the –with-app-store-compliance option” to resolve the issue of apps being rejected by the App Store due to the string. He mentioned in the request that this option could be used for platforms other than iOS and macOS, but currently, there are no such use cases. If all goes well, it will be available in Python 3.13.

Frustratingly, many developers have reported that free software projects like Python have to waste time trying to circumvent opaque review processes so that developers can write software for non-free platforms. HN users commented:

It’s not just Apple that plays this trick.

Try compiling Python applications with PyInstaller while having Windows Defender real-time scanning enabled (default settings). If Defender doesn’t block it, you can’t even compile the binary.

Similarly, try running the binary generated by PyInstaller with Windows Defender enabled. Defender will say it’s malware and won’t run it.

Both major operating system platforms spare no effort in blocking you from publishing and running Python applications, which is a bit dystopian.

In this experience, CPython core developer Keith-Magee and other CPython developers have decisively stepped up, and their approach seems to be the most hassle-free option for providing the best experience for Python application developers. However, it is almost certain that this will not be the last time a project encounters this issue.

Source:

https://lwn.net/SubscriberLink/979671/4fb7c1827536d1ae/

https://discuss.python.org/t/handling-incompatibilities-with-app-store-review-processes/56011/15

https://news.ycombinator.com/item?id=40815130

Python Application Rejected by Apple App Store Due to a Single String?

Click to follow the public account below to get free Python open classes and hundreds of GB of learning materials compiled by experts, including but not limited to Python e-books, tutorials, project orders, source code, etc.
▲Click to follow - Free to receive


Recommended Reading
Learn Python, how can you not master these 22 packages?
Jupyter in Python, surprisingly, also has MCP!
Creating a WeChat auto-reply robot with Python, automatically replying to girlfriend messages while playing games
Using Python to find out the big shots who blocked my QQ space


Click to read the original text

Leave a Comment