0

My code uses an external library using dlsym (for reasons out of my control).

In order Xcode to find my library, I had to do 2 things:

  • -force_load "$(SRCROOT)/pathTo/myLibrary.a"
  • Dead-Code Stripping: NO

This works fine when running wit the debug profile. Both on the simulator and on a physical device, the library is loaded and works.

However if I create an AdHoc IPA file and install it on my device, this same library is no longer found.

What could be the difference?

Nathan H
  • 48,033
  • 60
  • 165
  • 247
  • 1
    Are you sure that an ipa has 'myLibrary.a' file inside? App Store won't allow to do that. Just try to link a library to project through Build Phases -> Link libraries and try to add '-ObjC' flag to Other Linked Flags, maybe it will work for you. Delete your library from Copy Bundle Resources if it's there. – Mike Demidov Feb 08 '16 at 10:28
  • Yes if I open the IPA with an archive browser I see the .a file. But why wouldn't I want this? How else can the device receive this library?? – Nathan H Feb 08 '16 at 10:33
  • 1
    You can add only one executable file to an .app, name of which is a value for key 'CFBundleExecutable' from Info.plist. Your library will be compiled into when you run 'build' command at Xcode. – Mike Demidov Feb 08 '16 at 10:39
  • I see what you are saying. So the library.a that I see in my package was indeed because it was in "copy bundle", I removed it. Still the same issue however. Now I'm not sure how to check if the library was really included in the compiled file... – Nathan H Feb 08 '16 at 10:59
  • You can decompile it 'otool -tV -arch arm64 ../my.app/executable_file | grep ClassName', where 'ClassName' is a name of any class from your library. If it there you will see it. – Mike Demidov Feb 08 '16 at 11:05
  • What is supposed to be the output of this? I get nothing, no matter what class name I write, even `AppDelegate`. – Nathan H Feb 08 '16 at 11:53
  • I think I'm onto something. "Strip Linked Product" – Nathan H Feb 08 '16 at 12:23
  • If output gives nothing it means that the executable file was not linked with your library, it's odd, it should have been. – Mike Demidov Feb 08 '16 at 13:22
  • Please try just ''otool -tV ../my.app/executable_file | grep AppDelegate'', maybe the executable doesn't have arm64 architecture. – Mike Demidov Feb 08 '16 at 13:44
  • Yep, better now. It found my library, but it's probably because I solved the issue. Thanks anyway! – Nathan H Feb 08 '16 at 13:54

1 Answers1

0

This is what solved the issue:

In Build Settings → Deployment → Strip Linked Product, select NO.

Nathan H
  • 48,033
  • 60
  • 165
  • 247