Since I started building iOS and Android apps independently in 2014, one issue that became more common after AI coding tools went mainstream was this: the generated code causes a build error because it uses a deprecated API.
When I asked Antigravity to write AdMob monetization code, it casually suggested a class that had already been removed from the SDK. I didn't catch it right away and only found out during a build check before submission. The debugging time that followed is what prompted me to write this guide.
Antigravity is trained on a massive codebase — but that training data naturally includes older versions of code. Suggestions that don't reflect the latest SDK or language spec still happen. Here's the 4-step process I've settled into.
Why Antigravity Suggests Deprecated APIs
There are three main reasons this happens.
Training data lag
There's an inherent delay between when a new SDK version releases and when an AI model learns from code written for it. iOS SDKs go through major changes at every WWDC, and the months immediately after are the riskiest window for stale suggestions.
Missing project context
If Antigravity doesn't know which SDK version your project targets, it will default to generic suggestions. Without access to your Package.swift, Podfile, or build.gradle, it has no way to know "this project supports iOS 16 and above."
Outdated sample code in training
Stack Overflow answers and blog posts get baked into model training. A highly upvoted answer from a few years ago is often using an API that's since been deprecated.
Step 1 — Find the Deprecated API in Your Build Log
Start by reading the build output. In Xcode, deprecation warnings appear in the Issues Navigator. In Android Studio, look for This API has been deprecated in the Gradle output.
// ❌ What Antigravity suggested (deprecated since iOS 14.0)
let interstitial = GADInterstitial(adUnitID: "ca-app-pub-xxxx")
interstitial.load(GADRequest())
// ✅ Current correct implementation using GADInterstitialAd
GADInterstitialAd.load(
withAdUnitID: "ca-app-pub-xxxx",
request: GADRequest()
) { ad, error in
if let error = error {
print("Failed to load ad: \(error)")
return
}
self.interstitialAd = ad
}Note the deprecated class or method name from the error message — you'll use it in Step 2 when asking Antigravity for the fix.
Step 2 — Ask Antigravity for the Modern Replacement
In the Antigravity chat, phrase your question like this:
I'm getting this build error:
'GADInterstitial' was deprecated in iOS 14.0
Please write a replacement using the current GADInterstitialAd API.
This project targets iOS 16 minimum. Use Swift Concurrency (async/await).
The key is to provide three things: the deprecated API name, the OS version context, and the minimum deployment target. With those three, Antigravity will return code that's much closer to the current official docs.
If you need an API that was only introduced in a specific OS version, ask Antigravity to include proper @available(iOS 16, *) guards — it will usually add them correctly when you ask explicitly.
Step 3 — Add Banned APIs to INSTRUCTIONS.md
One-off fixes don't stop the same problem from coming back. Create (or update) an INSTRUCTIONS.md at your project root with rules like these:
# Coding Rules
## SDK Versions
- iOS minimum target: 16.0
- Android minimum SDK: 26 (Android 8.0)
- Swift: 5.10+
## Banned APIs (deprecated — do not use)
- `GADInterstitial` → use `GADInterstitialAd`
- `UIWebView` → use `WKWebView`
- `NSUserNotificationCenter` → use `UNUserNotificationCenter`
## Preferred Patterns
- Use async/await over completion handlers
- Initialize AdMob with `GADMobileAds.sharedInstance().start()`Once this file is loaded as context, Antigravity will reference it when generating code and avoid suggesting the listed APIs. For more on structuring effective instructions, see Antigravity Prompt Engineering Basics.
Step 4 — Add a Deprecation Check to Your Build Tasks
In Xcode, you can set the -warnings-as-errors flag to turn deprecation warnings into hard build errors. I'd recommend introducing this gradually rather than all at once — the first run tends to surface a lot.
# List all deprecation warnings in your Xcode project (useful in CI)
xcodebuild -scheme MyApp -configuration Debug build \
2>&1 | grep "deprecated" | sort | uniqFor Android, add this to your build.gradle to record deprecation warnings via lint:
android {
lintOptions {
// Log deprecated API usage as warnings
warning 'Deprecation'
// Uncomment to treat as errors in CI
// error 'Deprecation'
}
}Setting up a weekly build task in Antigravity to surface these warnings keeps problems small before they accumulate. You can find a detailed walkthrough of Antigravity task automation in Antigravity tasks.json and launch.json: One-Key Dev Environment Setup.
Prevention Beats Fixing
When Antigravity suggests an outdated API, resist the urge to paste it in and hope for the best.
After more than a decade of shipping apps independently — including monetized apps that went through many SDK cycles — my clearest lesson is that prevention scales better than reactive fixes. One well-maintained INSTRUCTIONS.md with your banned API list will quietly save you hours across every project it touches.
Start by adding one deprecated API to your project's INSTRUCTIONS.md today. That first line takes two minutes and pays for itself the next time Antigravity opens a file.
I hope this saves someone the same debugging session I went through. Good luck with your builds.