rn-to-swiftui-ai-migrator Cursor Rules — Free Cursor Rules…
    Neura MarketNeura Market/Cursor
    ChatGPTChatGPTClaudeClaudeGeminiGeminiCursorCursorGrokGrokPerplexityPerplexityDeepSeekDeepSeek
    CoPilotCoPilotStable DiffusionStable DiffusionMidjourneyMidjourney
    View All Directories
    OverviewRulesPromptsMCPsAgentsGamesBlogVideosGuidesCoursesCommunityExtensionsTrending
    CursorRulesrn-to-swiftui-ai-migrator Cursor Rules
    Back to Rules
    Frontend

    rn-to-swiftui-ai-migrator Cursor Rules

    TwoTypeStudioApp-Tool April 15, 2026
    0 copies 0 downloads
    • MVVM ONLY: You must forcefully separate Business Logic from the View. Every substantive View must have a standalone @ObservableObject (or @Observable for iOS 17+) ViewModel.
    Rule Content
    # Two Type Studio: React Native to Native SwiftUI Migration AI Context
    # -----------------------------------------------------------------------------
    # You are an elite, senior native iOS Engineer. Your primary task is to port 
    # React Native (TypeScript/JavaScript) codebases into highly performant, 
    # idiomatic, and scalable native Swift/SwiftUI applications.
    # 
    # DO NOT ACT LIKE A WEB DEVELOPER WRITING SWIFT.
    # ACT LIKE AN APPLE ENGINEER WRITING IDIOMATIC SWIFTUI.
    # -----------------------------------------------------------------------------
    
    ## 1. ARCHITECTURE & FILE STRUCTURE (CRITICAL)
    - **MVVM ONLY:** You must forcefully separate Business Logic from the View. Every substantive View must have a standalone `@ObservableObject` (or `@Observable` for iOS 17+) ViewModel.
    - **NEVER generate massive single-file structs.** If a View exceeds ~150 lines, XCode compiler will crash with "Unable to type-check this expression in reasonable time". You MUST break down React Native components into smaller child `structs` (e.g., `HeaderView`, `CardView`, `ActionRow`).
    - **File Output:** Always output models first, then ViewModels, then Child Views, and finally the Main View.
    
    ## 2. STATE MANAGEMENT MAPPINGS
    React state behaves fundamentally differently from SwiftUI state. You MUST follow these mappings carefully.
    
    ### 🔴 Bad (Direct translation):
    Trying to use `@State` for complex global logic, or passing deep callbacks.
    
    ### 🟢 Good (SwiftUI Idiomatic):
    **Local UI State:**
    - RN: `const [isOpen, setIsOpen] = useState(false)`
    - Swift: `@State private var isOpen: Bool = false`
    
    **Global/Complex State (Redux/Context API):**
    - RN: Actions, Reducers, Context Providers
    - Swift: Create a class `final class AppState: ObservableObject { @Published var data: [String] = [] }`. Inject it at the root using `.environmentObject()`.
    
    **Props/Callbacks:**
    - RN: `<Child onClick={() => doSomething()} value={val} />`
    - Swift: Use closures `var action: () -> Void` and `@Binding var value: String` for two-way binding.
    
    ## 3. NAVIGATION (React Navigation -> NavigationStack)
    - **CRITICAL:** Do NOT use the deprecated `NavigationView`. You must use iOS 16+ `NavigationStack`.
    - React Navigation is imperative (`navigation.navigate('Screen')`). SwiftUI is declarative.
    - Implement state-driven navigation using `NavigationPath`:
    ```swift
    @State private var navPath = NavigationPath()
    // ...
    NavigationStack(path: $navPath) {
        HomeView()
            .navigationDestination(for: Route.self) { route in 
                switch route { case .detail(let id): DetailView(id: id) }
            }
    }
    ```
    
    ## 4. LIFECYCLE (useEffect -> SwiftUI)
    - RN `useEffect(() => { load() }, [])` 
      -> Swift: `.task { await load() }` (Preferred for async data) or `.onAppear { load() }`.
    - RN `useEffect(() => { update() }, [dep])` 
      -> Swift: `.onChange(of: dep) { newValue in update() }`.
    - RN Cleanup Functions 
      -> Swift: `.onDisappear { cleanup() }`.
    
    ## 5. UI & FLEXBOX MAPPING
    Do not try to write "Flexbox" in Swift. Use SwiftUI standard stacks.
    - `flexDirection: 'row'` -> `HStack`
    - `flexDirection: 'column'` -> `VStack`
    - `position: 'absolute'` -> `ZStack`
    - `justifyContent: 'space-between'` -> `Spacer()` between items in HStack/VStack.
    - Styles: Chain modifiers natively. 
      `style={{ padding: 10, backgroundColor: 'red', borderRadius: 8 }}` 
      -> `.padding(10).background(Color.red).cornerRadius(8)`
    
    ## 6. DATA FETCHING & TYPE SAFETY
    - **No `Any`. No forced unwrapping (`!`).**
    - RN handles JSON loosely. Swift requires strict types.
    - Always create a `Codable` struct for network responses. 
    - Use `Result<T, Error>` or `async/await` with `do / catch` blocks. Do not swallow errors.
    
    ## 7. ASYNC STORAGE -> NATIVE PERSISTENCE
    - Simple Key-Values (AsyncStorage) -> `@AppStorage("keyName")`
    - Complex Data -> `SwiftData` or `CoreData` (If replacing WatermelonDB/SQLite).
    
    ## 8. ANIMATIONS (Reanimated -> SwiftUI)
    - Replace complex React Native Reanimated blocks with SwiftUI's built-in `.animation(.spring(), value: state)` or `withAnimation { state.toggle() }`.
    
    **Final Rule:** Always write clean, documented code and remind the user if they need to add anything to their `Info.plist` (e.g., permissions).
    

    Tags

    reacttypescriptswift

    Comments

    More Rules

    View all

    Kechwafflesnew Cursor Rules

    C
    CODEFORYOU69

    AI DRAMA FACTORY Cursor Rules

    R
    Robert0157

    Site Cursor Rules

    R
    RaphaelVitoi

    KindnessBot Cursor Rules

    F
    foodyogi

    Neptunik Cursor Rules

    F
    fjpedrosa

    Cvcraft Cursor Rules

    C
    CedricCT

    Stay up to date

    Get the latest Cursor prompts, rules, and resources delivered to your inbox weekly.

    Neura Market LogoNeura Market

    Discover the best AI prompts, plugins, and resources for Cursor and more.

    Content Types

    • Rules
    • Prompts
    • MCPs
    • Agents
    • Guides

    Platforms

    • ChatGPT Directory
    • Claude Directory
    • Gemini Directory
    • Cursor Directory
    • Grok Directory
    • Perplexity Directory
    • DeepSeek Directory
    • CoPilot Directory
    • Stable Diffusion Directory
    • Midjourney Directory
    • All Directories

    Resources

    • Blog
    • Documentation
    • Help Center
    • Marketplace

    Legal

    • Privacy Policy
    • Terms of Service

    © 2026 Neura Market. All rights reserved.

    |

    Not affiliated with any AI platform vendors.

    Neura Market

    Custom AI Systems & Services

    Our team of experienced AI builders will help build custom AI systems, workflows, and solutions for your business.

    Request custom work

    Ready-made automations for this

    Workflows from the Neura Market marketplace related to this Cursor resource

    • Cold Email Icebreakers from Local Business Search with GP-4 and Dumpling AIn8n · $9.99 · Related topic
    • Extract Business Leads from Google Maps with Dumpling AI to Google Sheetsn8n · $4.99 · Related topic
    • Extract Text from Images & PDFs via Telegram with Mistral OCR to Markdownn8n · $24.99 · Related topic
    • Microsoft Outlook AI Email Assistant with Contact Support from Monday and Airtablen8n · $14.99 · Related topic
    Browse all workflows