title: Is there a way for dlopen to reload a dylib file on iOS?
body: <p>As the title says... I'm interested in <code>dlopen()</code>. I understand this isn't allowed by the app store but I'm curious about this on iOS.</p>
  
  <p>The issue I have is that I can create a .dylib file and I can load this file at runtime with the following code</p>
  
  <pre><code>char *dylibPath = "/Applications/myapp.app/mydylib2.dylib";
  
  void *libHandle = dlopen(dylibPath, RTLD_NOW);
  if (libHandle != NULL) {
      NSString * (*someMethod)() = dlsym(libHandle, "someMethod");
      if (someMethod != NULL)  {
          NSLog(someMethod());
      }
      dlclose(libHandle);
  }
  </code></pre>
  
  <p>This is taken from <a href="https://stackoverflow.com/questions/4733847/can-you-build-dynamic-libraries-for-ios-and-load-them-at-runtime/10509453#10509453">here</a>.</p>
  
  <p>The problem I have is that if I change mydylib2.dylib, <code>dlopen</code> doesn't load the recompiled .dylib file. Instead, it resolves an old version of the function <code>someMethod</code>.</p>
  
  <p>For example, if <code>someMethod</code> first returns <code>@"Hello"</code> and I change this to be <code>@"Hello World"</code> and recompile, the code above will always return <code>@"Hello"</code> until I restart the app in the simulator.</p>
  
  <p>Do any know why this is the case? and suggest a workaround so the this .dylib can be reloaded at runtime?</p>