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

    This week in AI updates: GitHub Copilot SDK, Claude’s new constitution, and more (January 23, 2026)

    January 25, 2026

    Ambient-air power start-up secures £2m seed round funding

    January 25, 2026

    Today’s NYT Connections Hints, Answers for Jan. 25 #959

    January 25, 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»linker – How to prevent C function in iOS app from being stripped when uploaded to TestFlight?
    iOS Development

    linker – How to prevent C function in iOS app from being stripped when uploaded to TestFlight?

    big tee tech hubBy big tee tech hubJanuary 3, 2026012 Mins Read
    Share Facebook Twitter Pinterest Copy Link LinkedIn Tumblr Email Telegram WhatsApp
    Follow Us
    Google News Flipboard
    linker – How to prevent C function in iOS app from being stripped when uploaded to TestFlight?
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link


    1. I have a iOS library that exposes a C function. This function is marked with default visibility and used via attribute tags to prevent the compiler/linker from stripping it

      #ifdef __cplusplus
      #define DYLIB_EXPORT                                                           
        extern "C" __attribute__((visibility("default"))) __attribute__((used))
      #else
      #define DYLIB_EXPORT                                                           
        __attribute__((visibility("default"))) __attribute__((used))
      #endif
      
      DYLIB_EXPORT bool say_hello_world();
      
      #import "helper_functions.h"
      #import 
      
      bool say_hello_world() {
        NSLog(@"Hello WORLD 🟢!");
        return true;
      }
      
    2. From a dynamic library, called sdk, I want to call this function. In this example it’s a Rust lib

      unsafe extern "C" {
          fn say_hello_world() -> bool;
      }
      
      #[unsafe(no_mangle)]
      extern "C" fn sdk_init() -> i32 {
          unsafe {
              say_hello_world();
          }
          return 0;
      }
      
    3. When the app is compiled and launched from Xcode (either on debug or release schemes) then this works, the following snippet works and prints the hello WORLD message:

       #import "Wrapper.h"
       #import "helper_functions.h"
       #import "sdk.h"
      
       @implementation Wrapper
       // This function is called on the main view controller mount
       + (int)initialize {
         NSBundle *frameworkBundle =
             [NSBundle bundleWithIdentifier:@"sdk"];
         if (![frameworkBundle isLoaded]) {
           BOOL success = [frameworkBundle load];
           if (!success) {
             return -1;
           }
      
           int status = sdk_init();
           return status;
         }
      
         return 0;
       }
      
       @end
      
    4. However, when archived and uploaded to TestFlight an extra stripping step happens that gets rid of the say_hello_world function. The dynamic library then crashes with a null pointer exception:

      Thread 3 name:
      Thread 3 Crashed:
      0   ???                              0x0000000000000000 0x0 + 0
      1   sdk                              0x0000000105931ec0 0x105820000 + 1121984
      

    Minimum Reproducible Example

    Besides the snippets, the only way to reproduce the example is with a fully compilable iOS app one can generate a stripped binary that runs on device. Therefore I have reduced the code as much as a I can to reproduce the issue in this repo:

    Then archive the app, then export with the debugging option. Drag and drop to a connected iPhone finder window to directly install on the device.

    Extra notes

    • There has been some discussion on the apple developer forums
    • The Rust library has been compiled with extra flags to prevent the linker from failing when the function is not present during compilation:
      println!("cargo:rustc-link-arg=-Wl,-U,_say_hello_world");
      
    • I know for a fact this is a problem with dead code stripping because if I disable Dead Code Stripping in the project settings then no code is stripped at all, bloating the binary, but the crash does not happen anymore. Yet this only happens when creating a distributable .ipa and not when running directly from Xcode



    Source link

    app function iOS linker Prevent stripped TestFlight uploaded
    Follow on Google News Follow on Flipboard
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email Copy Link
    tonirufai
    big tee tech hub
    • Website

    Related Posts

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

    January 25, 2026

    Your iPhone is out of space again—This app fixes that for $20

    January 24, 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

    This week in AI updates: GitHub Copilot SDK, Claude’s new constitution, and more (January 23, 2026)

    January 25, 2026

    Ambient-air power start-up secures £2m seed round funding

    January 25, 2026

    Today’s NYT Connections Hints, Answers for Jan. 25 #959

    January 25, 2026

    How Data-Driven Third-Party Logistics (3PL) Providers Are Transforming Modern Supply Chains

    January 25, 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!

    This week in AI updates: GitHub Copilot SDK, Claude’s new constitution, and more (January 23, 2026)

    January 25, 2026

    Ambient-air power start-up secures £2m seed round funding

    January 25, 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.