iPhone App call third-party dylib failed - iphone

Hey, guys! I want to wrap the vlc, importing the vlc dylibs. But this simple iPhone App call those third-party dylibs failed at the beginning of loading without any prompts. I even try to make a 'hello world' xcode project, just add libvlc.2.dylib & libvlccore.0.dylib but not calling, without any 1 more code manually. After download it to the iPhone device(3.1.3), it splash and exit immediately, no info throw out. BTW, all the dylibs imported were put to the right dirs. It really make me confused! Could any body show me the solution, appreciated!
run otool on device:
root# otool -L test1
test1:
/System/Library/Frameworks/Foundation.framework/Foundation (compatibility version 300.0.0, current version 678.51.0)
/System/Library/Frameworks/UIKit.framework/UIKit (compatibility version 1.0.0, current version 1000.0.0)
/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics (compatibility version 64.0.0, current version 359.16.0)
/System/Library/Frameworks/CoreData.framework/CoreData (compatibility version 1.0.0, current version 248.0.0)
#executable_path/PlugIns/libvlccore.0.dylib (compatibility version 1.0.0, current version 1.2.0)
#executable_path/PlugIns/libvlc.2.dylib (compatibility version 3.0.0, current version 3.2.0)
#executable_path/PlugIns/liblive555_plugin.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 1.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 111.2.1)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 227.0.0)
/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation (compatibility version 150.0.0, current version 478.52.0)

iPhone apps cannot link to any additional libraries except those that are on the iPhone already. You need to compile any external libraries into your binary (as a static library).

Related

TestFlight build with error: One or more dynamic libraries that are referenced by your app are not present in the dylib search path

I've been recently trying to overcome the problem mentioned in the email I receive when I upload a build to TestFlight:
ITMS-90562: Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
I have added Google Admob via Cocoapods (it's the only library I have in Cocoapods) and I have several other libraries added via SPM:
I have also tried to validate the IPA generated for which I receive the dreadful email and Xcode says that it's a valid IPA.
I have also tried looking at https://medium.com/360learning-engineering/resolving-itms-90562-invalid-bundle-email-from-the-app-store-d4a1030418e5 and the frameworks that I get with the #rpath are the following, but the problem I have here is that since I'm using Cocoapods and SPM, there's no Frameworks folder:
#rpath/FBLPromises.framework/FBLPromises (compatibility version 1.0.0, current version 1.0.0)
#rpath/GoogleUtilities.framework/GoogleUtilities (compatibility version 1.0.0, current version 1.0.0)
#rpath/nanopb.framework/nanopb (compatibility version 1.0.0, current version 1.0.0)
#rpath/libswift_Concurrency.dylib (compatibility version 1.0.0, current version 5.6.0, weak)
This is the content of the folder:
I have also tried to add those libraries with the #rpath to the Link binary with libraries but I'm still getting the email.
I'm at this point completely stuck since I don't know what else I can do here, nor how to fix this, so any help is very much appreciated!
Thanks in advance!
The solution here is to disable bitcode

How to debug objc runtime linking multiple instances of the same library

I'm working on a Swift project which links agains libSDL2. I had to patch a few things in that library to fit my needs and thus it currently lives in the same directory as my project and is compiled and linked from there. When I run my application, I get a bunch of warning form:
objc[13894]: Class SDLApplication is implemented in both
/opt/local/lib/libSDL2-2.0.0.dylib (0x10f116228) and
/Users/<my-project>/Libraries/SDL-install/lib/libSDL2-2.0.0.dylib
(0x10ef6d240). One of the two will be used. Which one is undefined.
I do have a globally-installed instance of libSDL2 under /opt/local, installed via MacPorts and used by some applications also installed via MacPorts, so I can't remove that.
I tried looking at the libraries that the compiled binary links agains but could not find a reference to the instance installed in /opt/local.
$ otool -L .build/debug/TestLines
.build/debug/TestLines:
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1770.255.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1292.60.1)
/Users/<my-project>/Libraries/SDL-install/lib/libSDL2_image-2.0.0.dylib (compatibility version 3.0.0, current version 3.3.0)
/Users/<my-project>/Libraries/SDL-install/lib/libSDL2-2.0.0.dylib (compatibility version 17.0.0, current version 17.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1770.255.0)
#rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1200.2.41)
<...>
How can I debug this issue?
In the end it was easy to figure out. It turned out that the libSDL2_image-2.0.0.dylib was linked against the instance of libSDL2 from /opt/local. To figure this out I simply had to follow the libraries linked by my binary and inspect those instead of just the main binary:
$ otool -L Libraries/SDL-install/lib/libSDL2_image-2.0.0.dylib
Libraries/SDL-install/lib/libSDL2_image-2.0.0.dylib:
/Users/<my-project>/Libraries/SDL-install/lib/libSDL2_image-2.0.0.dylib (compatibility version 3.0.0, current version 3.3.0)
/opt/local/lib/libSDL2-2.0.0.dylib
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
/opt/local/lib/libiconv.2.dylib (compatibility version 9.0.0, current version 9.1.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices (compatibility version 1.0.0, current version 52.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1677.104.0)
/System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics (compatibility version 64.0.0, current version 1355.22.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1069.24.0)
/System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO (compatibility version 1.0.0, current version 1.0.0)
(The root cause in this instance was that I had to pass --sdl-prefix in addition to --prefix to the ./configure script from SDL_image)

Determine the Swift compiler version used to create a Framework

I want to know what compiler version was used exactly. In my example I tried the following:
otool -L TestFramework
TestFramework:
#rpath/TestFramework.framework/Versions/A/TestFramework (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/Foundation.framework/Versions/C/Foundation (compatibility version 300.0.0, current version 1675.129.0)
/usr/lib/libobjc.A.dylib (compatibility version 1.0.0, current version 228.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)
#rpath/libswiftCore.dylib (compatibility version 1.0.0, current version 1103.8.25)
It looks like 1103.8.25 could be useful, but when I look the version up (on Wikipedia) it doesn't help, as the versions there look like this:
5.3 (swiftlang-1200.0.29.2 clang-1200.0.30.1),
5.3.1 (swiftlang-1200.0.41 clang-1200.0.32.8),
5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
etc..
It looks like that my 1103.8.25 might hint to one of these:
5.2 (swiftlang-1103.0.32.1 clang-1103.0.32.29),
5.2.2 (swiftlang-1103.0.32.6 clang-1103.0.32.51),
5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53),
5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53),
5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)
, because of the 1103 but which one is it?
I am aware that I can check the .swiftinterface file if the binary has been compiled with ABI stability, but let's assume it hasn't been. How does Xcode do it?
Is there a list of libswiftCore.dylib versions somewhere that can be used for lookup?

dyld: Library not loaded when build to iphone 4

I am using a third-party library,say: libABC.dylib
I want use the dylib in an open source application,and want to install into my iphone 4,with ios 6,without jailbroken.
On doing a
$ otool -L libABC.dylib
libABC.dylib:
libABC.dylib (compatibility version 1.0.0, current version 1.0.0)
libXYZ.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
111.1.5)
Now i want to ship the dylib, with my app , install into my iphone 4.
For that i have changed the dylib paths as
$ install_name_tool -id #executable_path/../Frameworks/libABC.dylib libABC.dylib
also,I added libABC.dylib to Frameworks under the project in Xcode.
This changes the inside dylib paths as
$ otool -L libABC.dylib
libABC.dylib:
#executable_path/../Frameworks/libABC.dylib (compatibility version
1.0.0, current version 1.0.0)
libXYZ.dylib (compatibility version 0.0.0, current version 0.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version
111.1.5)
The problem is:
libABC is loaded at app launch time,
i am unable to change this path, to a path relative to my mach-o binary
(inside my app bundle)
So my app is failing to load.
Dyld Error Message:
dyld: Library not loaded: /usr/local/lib/libABC.dylib
Referenced from:
....
Reason: image not found
Please suggest me some direction.
The third party library is only creating dylib, no static libs
I also tried setting XCode options to get dylib from "#executable_path" but
it didnt work.
and I don not load my dylib through code?
Please suggest. I am clueless here.
Advance Thanks :)
Unfortunately NO, you are out of luck, start looking for alternatives. You can't add custom/third party dylibs to an iOS project, iOS project only support addition of built-in dynamic libraries. Moreover any tries and success to add dylibs may cause you app rejected from apple.
Why? Have a look at this post for detailed discussion. specially the 2nd comment on marked answer.
Like you could read in #Adil Soomro's reference, third party frameworks are not supported because of security reasons. That's why you have to delete all the frameworks that appear inside the log when you try to build an app. Normally it should work if these Frameworks are not included. If the debugger will turn on while building you should press play till the app will be installed.
But keep looking what kind of frameworks you are using so you don't get rejected when the app will be reviewed.
Further more, a related error method can occure if you start an app on ios 5.1 or less and some of your frameworks are not supported on these os versions.

iOS simulator slowing osx down and interfering with magic mouse

Has anyone noticed that when using iOS simulator for extended periods of time or during launch of Apps that there is a disturbance in the performance of osx and the magic mouse?
The other day a darkened view loading across the osx screen and it said I needed to restart.
These are the logs for my app from the console - there are stacks more though:
0x954c7000 - 0x954cafe7 libmathCommon.A.dylib 315.0.0 (compatibility 1.0.0) <1622A54F-1A98-2CBE-B6A4-2122981A500E> /usr/lib/system/libmathCommon.A.dylib
0x95598000 - 0x9573fff7 libSystem.B.dylib 125.2.1 (compatibility 1.0.0) <62291026-D016-705D-DC1E-FC2B09D47DE5> /usr/lib/libSystem.B.dylib
0x96675000 - 0x96695fe7 libresolv.9.dylib 41.0.0 (compatibility 1.0.0) <751955F3-21FB-A03A-4E92-1F3D4EFB8C5B> /usr/lib/libresolv.9.dylib
0x96e34000 - 0x96ea3ff7 libvMisc.dylib 268.0.1 (compatibility 1.0.0) <5C3D7DA5-29EB-A745-E32B-26DBF547D532> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
0x98210000 - 0x982edff7 com.apple.vImage 4.0 (4.0) <64597E4B-F144-DBB3-F428-0EC3D9A1219E> /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
0x991e6000 - 0x991f2ff7 libkxld.dylib ??? (???) <F0E915AD-6B32-0D5E-D24B-B188447FDD23> /usr/lib/system/libkxld.dylib
0xffff0000 - 0xffff1fff libSystem.B.dylib ??? (???) <62291026-D016-705D-DC1E-FC2B09D47DE5> /usr/lib/libSystem.B.dylib
This isn't an Xcode/simulator issue. THe "dark view" thing was a kernel panic, indicating something went horribly wrong in the OS.
This should be on superuser.
And they'd need to know more info:
system configuration? Model? Memory? Hard Drive?
anything interesting in the console log?