ANTIGRAVITY LABJP
Articles/Tips & Best Practices
Tips & Best Practices/2026-05-13Intermediate

4 Steps to Handle Deprecated API Suggestions from Antigravity

A practical 4-step approach to diagnosing, fixing, and preventing deprecated API suggestions from Antigravity — based on real iOS/Android indie development experience since 2014.

antigravity432deprecatedtips36ios36android27troubleshooting105

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 | uniq

For 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.

Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • Copy-paste ready implementation code
  • New advanced guides published daily
  • $5/mo or $10 for lifetime access
View Membership →

If you found this article helpful, a small tip ($1.50) would mean a lot to us. Your support helps keep this site ad-free and covers server and hosting costs.

Related Articles

Tips2026-05-27
Fixing Japanese Mojibake (Garbled Text) in Antigravity's Integrated Terminal
When git log, npm errors, or filenames containing Japanese characters turn into gibberish like 譁?ュ怜喧縺 in Antigravity's integrated terminal, the fix usually takes one or two lines per platform. Here are the Windows, macOS, and WSL2 patterns I keep running into.
Tips2026-05-10
Diagnosing Antigravity's "Failed to fetch" errors when AI chat stops responding
When Antigravity's AI chat or agent runs suddenly halts with "Failed to fetch" or "Network Error," the recovery is faster if you peel layers off in a fixed order. Here is the field-tested checklist I use.
Tips2026-05-03
Retry Isn't Always the Answer in Antigravity — How to Tell When to Retry vs. When to Rethink
Learn when to use Antigravity's Retry feature and when it's time to change your approach entirely. A practical guide to diagnosing root causes before burning time on repeated failed attempts.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →