A Preflight Script for iOS Builds: Save Cloud Mac Minutes
By Nesim Razon, independent mobile developer · 2026-11-30
I develop on Windows and build my iPhone apps on a rented cloud Mac with a limited monthly allowance. Every failed build that fails for a known reason is a waste. So I wrote a small Python script that reads the project files and refuses the mistakes I have already made once.

Why check before building
My free plan on the cloud build service gives 500 macOS minutes a month, and one build takes roughly eight to ten minutes. A single missing line in a settings file can therefore cost a noticeable share of the month, especially when the error only appears at upload time, after the whole build has finished.
The script does not try to replace the build. It cannot link a framework or compile Swift on Windows. It only reads text files and answers one question: is there anything here that I already know will fail or will be rejected?
Check one: the wrapper must be executable
A Gradle wrapper added on Windows is stored in git without the executable bit. The Mac then stops with a permission denied message before doing anything useful. The script asks git for the file mode and expects the executable one. If it is wrong, the message includes the exact git command that fixes it, because I do not want to search for it again.
Check two: the project description
My iOS projects are generated from a YAML file, so no Xcode project lives in the repository. The script parses that file and looks for the values that have bitten me:
- The marketing version must come from the build setting. Otherwise the store can refuse a second upload because the version train is closed.
- The build number line must be present in the form the build script rewrites.
- Apps with ads must carry real ad identifiers, not the public test ones, and a list of ad network identifiers.
- A script phase that uploads crash symbols must exist, and the analytics package must be the current one.
- The Firebase settings file must exist, belong to this bundle identifier and have analytics switched on.
The last item surprised me. The settings file downloaded from the console can arrive with analytics set to off, and nothing fails. The data is simply missing later.
Check three: the build recipe
The second YAML file describes the cloud workflows. The script requires two of them, one that only builds for the simulator and one that publishes a test build. In the publishing workflow it looks for the signing steps by name, the step that writes the build number into the property list and the publish command.
It also forbids one thing. Archiving without signing and signing later left the embedded frameworks unsigned, and the store rejected the upload with an invalid signature error. If that flag appears again, the script stops me.
Check four: Swift argument labels
Kotlin interfaces become Swift protocols. When two interfaces that Swift implements have a method with the same name but a different signature, the generated labels change and the Swift file no longer compiles. This shows up only on a Mac.
The script compares method names and signatures between the two interface files. At first it complained about any shared name. Then one app with identical signatures compiled without trouble, so I narrowed the rule to names that differ in signature. A check that raises false alarms soon gets ignored.
Check five and six: shared code and store text
Shared Kotlin code compiles for iOS only if it stays away from Java. The script searches the common source set for a few patterns that have slipped in: the Java system clock, any java import, the IO dispatcher and an Android only back handler. Each message names the file and the replacement.
The last check reads my store listing file. The store rejects emoji in several text fields with a vague message about invalid characters, so the script looks for characters outside the basic range in those blocks.
Checks that know about exceptions
Not every app is the same, and a check that ignores that becomes noise. Two of my apps carry no ads at all. The script first looks for the ad library in the project file and skips the ad related checks when it is absent. It only asks for a banner or full screen ad identifier when the project actually declares one.
The same goes for identifiers. A real identifier from my own publisher account is accepted, the public test identifiers are not. A test identifier compiles and runs perfectly, which is exactly why it is dangerous: nothing tells you that the release will earn nothing and may break the ad network rules.
Where the knowledge lives
Next to the script sits a plain document with numbered pitfalls. Each entry says what happened, what the symptom looked like and what fixed it. The script automates the entries that can be detected by reading files, and the document keeps the rest, such as a store form that gets stuck or a name that is already taken.
A new check is added only after a real failure. I do not try to guess what might go wrong someday, because guessed checks tend to be wrong in ways that are hard to see. When a failure happens, I first write the entry, then ask whether a few lines of code could have caught it.
That order also keeps the messages useful. Since I wrote each one right after being bitten, it tells me what to type or what to change, not only that something is wrong.
Running it and what comes after
I pass one or more app folders on the command line. Each gets a line saying clean or problem, followed by the list, and the exit code is non zero if anything failed. When I ran it recently on two older ports, both showed five open items, all of them known work that had never been finished. Better to read that on my laptop than in a build log.
After a clean result the order is: compile the iOS targets locally, which does work on Windows for the Kotlin side, then run the simulator workflow, and only then the test build. The script is not clever. Its value is that every line in it once cost me time, and it remembers so that I do not have to.
Frequently asked questions
Can I build an iOS app on Windows?
You can write and compile much of the Kotlin code, but linking, signing and publishing need macOS, for example through a cloud build service.
What belongs in a preflight script?
Only checks that read files quickly and that match mistakes which really happened. Keep the messages actionable.
Does a clean preflight guarantee a successful build?
No. Swift and Xcode errors can still appear on the Mac. It only removes the known failures.
Should the script run automatically?
It can, for example before a push. I run it by hand right before starting a cloud build, which is when it matters.
More from the blog
- What Stays Platform-Specific in a Kotlin Multiplatform App
- Declaring a Walking Game's Health Data in Play Console
- Blender From the Command Line: Pale Colours and Boolean Order
- Play Games Saved Games: A Merge That Never Goes Backwards
- From Blender Renders to Compose: Sprite Atlas and Layers
- A Four-Language Static Site in Python: hreflang and Sitemap