Close Menu
  • Home
  • AI
  • Big Data
  • Cloud Computing
  • iOS Development
  • IoT
  • IT/ Cybersecurity
  • Tech
    • Nanotechnology
    • Green Technology
    • Apple
    • Software Development
    • Software Engineering

Subscribe to Updates

Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

    What's Hot

    Empowering Protected Area Technicians with IT skills through Cisco Networking Academy

    January 26, 2026

    Apple scores six Academy Award nominations

    January 26, 2026

    Codenotary updates its free SBOM scanning tool with capabilities that better support AI apps

    January 26, 2026
    Facebook X (Twitter) Instagram
    Facebook X (Twitter) Instagram
    Big Tee Tech Hub
    • Home
    • AI
    • Big Data
    • Cloud Computing
    • iOS Development
    • IoT
    • IT/ Cybersecurity
    • Tech
      • Nanotechnology
      • Green Technology
      • Apple
      • Software Development
      • Software Engineering
    Big Tee Tech Hub
    Home»iOS Development»How to access and modify Swift class properties using Frida on iOS?
    iOS Development

    How to access and modify Swift class properties using Frida on iOS?

    big tee tech hubBy big tee tech hubNovember 8, 2025002 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    How to access and modify Swift class properties using Frida on iOS?
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    I’m using Frida to hook into my Swift iOS app called TestApp2. I want to read and modify the class property counter. The class is:

    // ContentView.swift
    class ContentViewModel: ObservableObject {
        @Published var counter: Int = 0
        
        func incrementCounter() {
            counter += 1
        }
    }
    

    I’ve successfully hooked the incrementCounter() method and captured the self pointer, which I assume is the pointer to the ContentViewModel class instance:

    // hook.js
    const TARGET_SYMBOL = '$s8TestApp216ContentViewModelC16incrementCounteryyF';
    const module = Process.findModuleByName('TestApp2');
    const targetAddress = module.findExportByName(TARGET_SYMBOL);
    var selfPtr = null
    
    Interceptor.attach(targetAddress, {
        onEnter: function(args) {
            selfPtr = args[0];  // ContentViewModel instance pointer
            console.log(`[+] Self pointer: ${selfPtr}`);
        }
    });
    

    I run the above script with this frida command:

    frida -U TestApp2 --auto-reload -l hook.js
    

    I open the app and tap the Increment button, which shows this result in Frida:

    [iPhone::TestApp2 ]-> [+] Self pointer: 0x280eb0860
    

    Question

    How do I read and modify the current value of counter given this pointer?

    What I’ve Tried

    1. Using Swift.Object wrapper:
    [iPhone::TestApp2 ]-> var temp = new Swift.Object(selfPtr, "ContentViewModel");
    [iPhone::TestApp2 ]-> temp.counter; // undefined
    [iPhone::TestApp2 ]-> temp
    {
        "handle": "0x280eb0860" // not sure what to do with this handle
    }
    
    1. Accessing through Swift.classes:
    [iPhone::TestApp2 ]-> Swift.classes.ContentViewModel
    {
        "$conformances": [
            "ObservableObject"
        ],
        "$fields": [
            {
                "isVar": true,
                "name": "_counter", // the _counter variable name is shown but the value is not
                "typeName": "Published"
            }
        ],
        "$methods": []
    }
    
    1. Direct memory reading (trying different offsets):
    [iPhone::TestApp2 ]-> selfPtr.add(0x10).readS64() // not sure of correct offset
    "10785265760"
    

    Environment

    • iOS 15.8.5 (jailbroken)
    • Frida 17.3.2
    • Swift class (not @objc exposed)

    Full TestApp2 Code for Context

    The whole app consists of just these two files below.

    ContentView.swift:

    import SwiftUI
    import Combine
    
    
    class ContentViewModel: ObservableObject {
        @Published var counter: Int = 0
        func incrementCounter() {
            counter += 1
        }
    }
    
    struct ContentView: View {
        @StateObject private var viewModel = ContentViewModel()
    
        var body: some View {
            VStack(spacing: 20) {
                TextField("Counter", value: $viewModel.counter, format: .number)
                    .textFieldStyle(RoundedBorderTextFieldStyle())
                    .multilineTextAlignment(.center)
                    .frame(width: 100)
    
                Button("Increment") {
                    viewModel.incrementCounter()
                }
                .buttonStyle(.borderedProminent)
            }
            .padding()
        }
    }
    
    #Preview {
        ContentView()
    }
    

    TestApp2App.swift

    import SwiftUI
    
    @main
    struct TestApp2App: App {
        var body: some Scene {
            WindowGroup {
                ContentView()
            }
        }
    }
    



    Source link

    access Class Frida iOS modify properties Swift
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

    android – Can’t show or schedule notification with flutter workmanager

    January 26, 2026

    ios – Why does my page scroll up when I tap on a button?

    January 25, 2026

    swift – iOS suspends app after BLE discovery even though I start Always-authorized location udpates

    January 24, 2026
    Add A Comment
    Leave A Reply Cancel Reply

    Editors Picks

    Empowering Protected Area Technicians with IT skills through Cisco Networking Academy

    January 26, 2026

    Apple scores six Academy Award nominations

    January 26, 2026

    Codenotary updates its free SBOM scanning tool with capabilities that better support AI apps

    January 26, 2026

    Engineered mucus-tethering bispecific nanobodies enhance mucosal immunity against respiratory pathogens

    January 26, 2026
    About Us
    About Us

    Welcome To big tee tech hub. Big tee tech hub is a Professional seo tools Platform. Here we will provide you only interesting content, which you will like very much. We’re dedicated to providing you the best of seo tools, with a focus on dependability and tools. We’re working to turn our passion for seo tools into a booming online website. We hope you enjoy our seo tools as much as we enjoy offering them to you.

    Don't Miss!

    Empowering Protected Area Technicians with IT skills through Cisco Networking Academy

    January 26, 2026

    Apple scores six Academy Award nominations

    January 26, 2026

    Subscribe to Updates

    Get the latest technology news from Bigteetechhub about IT, Cybersecurity and Big Data.

      • About Us
      • Contact Us
      • Disclaimer
      • Privacy Policy
      • Terms and Conditions
      © 2026 bigteetechhub.All Right Reserved

      Type above and press Enter to search. Press Esc to cancel.