I am using Carthage.
I have a project named, A-Framework which has a framework inside, named E-Framework, with all code and a header.
In A-Framework -> Linked frameworks and Libraries
A project a-ios uses framework A-Framework. I got this at run time:
dyld: Library not loaded: #rpath/E-Framework.framework.
How come that main project a-ios, knows something about the implementation detail of the framework A-Framework ?
Related
I am trying to write a Xamarin Android binding library for a library that is loaded in the app during runtime. When using this library in a normal Android project, you would use "compileOnly".
compileOnly 'de.robv.android.xposed:api:82'
compileOnly 'de.robv.android.xposed:api:82:sources'
From my understanding, "compileOnly" makes the code from the library available for compilation but does not add it to the resulting apk. Meaning it needs to be provided in runtime for the app to work.
When reading the Xamarin binding Build Action docs, "compileOnly" sounds very similar to "InputJar".
Does not embed the .jar into the resulting Bindings Library .DLL. Your Bindings Library .DLL will have a dependency on this .jar at runtime. Use this option when you do not want to include the .jar in your Bindings Library (for example, for licensing reasons). If you use this option, you must ensure that the input .jar is available on the device that runs your app.
However, when compiling my application while using methods provided by the runtime library, I get errors from the generated java code that the packages do not exist.
javac.exe error : error: package de.robv.android.xposed does not exist
javac.exe error : de.robv.android.xposed.IXposedHookLoadPackage
javac.exe error : error: package de.robv.android.xposed.callbacks.XC_LoadPackage does not exist
javac.exe error : public void handleLoadPackage (de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam p0)
error : error: package de.robv.android.xposed.callbacks.XC_LoadPackage does not exist
error : private native void n_handleLoadPackage (de.robv.android.xposed.callbacks.XC_LoadPackage.LoadPackageParam p0);
Meaning that the code was not made available during compilation. How can I make sure the code is made available during compilation but not embedded into application?
See my answer at https://stackoverflow.com/a/64973909/4374462
Either using AndroidExternalJavaLibrary or [assembly: Java.Interop.DoNotPackage("ref.jar")].
I've got three layers:
- core C++ engine
- iOS audio wrapper
- demo iOS consumer project
So I am:
1) compiling engine.a, which links against accelerate framework.
2) compiling wrapper.a, with a dependency on engine and linking against engine.a AND accelerate framework.
So far so good. I can build wrapper.a. But something looks wrong. My wrapper code is using CoreAudio calls. It is fetching real-time microphone data. It should be reporting errors, surely? It should be requiring me to link AudioToolbox or AudioUnit frameworks.
So I don't see why that library even compiles.
3) create a fresh iOS project that links against wrapper.a.
Now I'm getting a 30+ build errors:
```
Undefined symbols for architecture x86_64:
"vtable for std::exception", referenced from:
std::__1::bad_function_call::bad_function_call() in libfftDecoder.a(FFTDecoder.o)
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"std::__1::__thread_struct::__thread_struct()", referenced from:
std::__1::thread::thread(void (DecoderThread::&&)(), DecoderThread&&) in libfftDecoder.a(FFTDecoder.o)
"std::__1::__throw_system_error(int, char const*)", referenced from:
std::__1::thread::thread(void (DecoderThread::&&)(), DecoderThread&&) in libfftDecoder.a(FFTDecoder.o)
:
```
Can anyone suggest what might be the problem? That first error kind of looks like 'failing to process a C++ construct'.
I should mention that Xcode is very disappointing in the context of this task. The items I link against in the 'build phases' tab are not consistently reflected in the project navigator's "frameworks" folder for the respective project. Also sometimes a .a appears red even when it built successfully.
First point (thanks #wiliz on #iphonedev Freenode) is that a static library has no concept of linking against something. So I should be removing all the links from my .a files and putting all of the dependencies in my consumer app.
The problem was that the library contains compiled C++ code. And the consumer app doesn't have any .mm files. So it isn't using ObjC++ anywhere. So it isn't linking against the C++ stdlib.
Simply renaming one of the .m files (say ViewController.m) to .mm fixes the problem.
So I followed this tutorial:
http://locomoviles.com/ios-tutorials/create-ios-cocoa-touch-framework-using-xcode/
Everything went fine except when I went to run the program I got the following error:
> dyld: Library not loaded:
> #rpath/SwiftFramework.framework/SwiftFramework Referenced from:
> /Users/bluke/Library/Developer/CoreSimulator/Devices/40677D10-F22B-4AE4-B767-06439AB7887A/data/Containers/Bundle/Application/8C6A5F76-C666-4B69-9353-A0ABD7DA085B/UseFramework.app/UseFramework
> Reason: image not found
I was able to solve this problem by adding the framework as an embedded binary, but I don't understand why this was needed to solve the problem.
I thought that the framework would be included in my application bundle as a dynamically linked library (i.e. not embedded in my application's binary directly) and then linked at run time. Is this assumption incorrect?
Just in case my question was unclear, I've added the following pictures.
This is what was producing the error:
If I add the framework to the embedded binaries it works:
I thought that the framework would be included in my application
bundle as a dynamically linked library (i.e. not embedded in my
application's binary directly) and then linked at run time. Is this
assumption incorrect?
Yes, it's incorrect. iOS apps link 3rd party frameworks statically, not dynamically. This prevents apps from downloading and dynamically linking code that hasn't been vetted by the app store review process.
This allows apps coded in Swift to run on devices running a version of iOS pre-dating Swift (earlier than iOS8).
Non-Apple frameworks can be embedded on iOS8 and above only.
It is also nice to add a prefix the the name identifying the developer organization so as to avoid comflicts and confusion. "SwiftFramework" looks so much like an Apple framework.
I'm trying to write a simple game engine for iOS in Objective C and C++ using Xcode.
I've made a game project and a game engine project. The latter is added to the former as a subproject. The engine is also added as a target dependency and as a binary to be linked in the game project.
My engine uses CADisplayLink so I add QuartzCore.framework in the engine project's "Link binary with libraries list" (found in Build phases).
Now, when I try to build my game project (the project with the subproject), I get this error:
Undefined symbols for architecture i386: "_OBJC_CLASS_$_CADisplayLink", referenced from: objc-class-ref in libVoya-iOS.a
This error only happens when building from the game project - doing it from the engine project works fine. If I add QuartzCore.framework to the game project building works fine.
Can it really be true I have to specifically require frameworks that one of my target dependencies already have required? In this case: My engine (sub project) already links QuartzCore - is it really necessary to also do this in the projects using this engine? It feels like double work for no reason.
Or perhaps I've just completely misunderstood something? :)
Add QuartzCore framework to fix this issue.
I've now found the answer to my question and I'd like to share it.
Static libraries are nothing more than a grouping of the compiled versions of the library's source files. They do not include any libraries they themselves might depend on.
Fusing all dependencies together happens only when you build the actual executable in the very end. For this reason, your application should indeed link against your dependencies' dependencies.
As for the example in my question, that means that my game should link QuartzCore while my game engine should not (even though it is my GameEngine who is using it).
Learn more here:
Duplicate symbol: Include static lib A in static lib B, also include lib A and B in XCode Project
Linking static libraries, that share another static library
I believe this is because you're using a target dependency instead of linking against a precompiled library.
I'm trying to install a testing library for a project on top of SenTestingKit.
Prior to installing, the project builds fine and runs the test suite using SenTestingKit.
However, after using cocoapods to install another testing framework like Specta or Kiwi (which apparently depend on SenTestingKit), the project builds, but then immediately throws this error:
dyld: Library not loaded: #rpath/SenTestingKit.framework/Versions/A/SenTestingKit
Referenced from: [...]
Reason: image not found
I've tried about a dozen different suggestions from people with similar problems (changing the target build settings test host, changing the target framework search paths, etc, making sure pods are configured for the test target, etc.), all to no avail. Any suggestions?
Try with the following steps to link the static library to our project (which inturn uses a framework or static library):
Include the static library in the main projects "link binary with library".
Provided the header path at HEADER_SEARCH_PATH as well as LIBRARY_SEARCH_PATH (Inside Build Settings of app's target).
Most important:
In the target's build phases - > Link binaries with libraries set the relevant framework (SenTestKit.framework in our case) to "Optional" instead of "Required".
Hope this will fix your issue
Finally tracked down the answer.
Following the steps laid out in the answer here fixed the issue:
How to set dyld_library_path in Xcode