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
Related
I have an iOS project in XCode 11.2 that requires a mix of Frameworks, some of which are available on Cocoapods and some are not. For the non-Cocoapod frameworks, I have the frameworks copied to the root of my project folder.
The trouble comes with getting XCode to be able to find both using the Framework Search Paths setting as shown here:
All of the entries following $(inherited) are actually the ones inherited from Cocoapods (these are not explicitly specified).
If I don't add the $(PROJECT_DIR) at the end then Cococapod frameworks are found fine, but my embedded non-Cocoapod frameworks get compiler errors that their header files are not found.
If I do add the $(PROJECT_DIR) at the end, then the Cocoapod frameworks are not found and I get a build error like:
ld: warning: directory not found for option '-F/Users/dyoung/Library/Developer/Xcode/DerivedData/MyApp-acdmyjbbrpbhlkfiyypetovwacrz/Build/Products/Debug-iphoneos/AWSAuthCore'
...
ld: framework not found AWSAuthCore
Why? How do I get XCode to find frameworks in both places?
Here's one way:
pod deintegrate
Open the .xcodeproj
Add the non-CocoaPods frameworks.
pod install
Open the .xcworkspace
The problem was that the CocoaPods Frameworks that I was trying to add were built only for iOS 11+, but my very old project had a deployment target of iOS 8.4.
Looking at error details in the Report Navigator as #paul-beusterien suggested was critical. I found this:
Ld /Users/dyoung/Library/Developer/Xcode/DerivedData/MyApp-acdmyjbbrpbhlkfiyypetovwacrz/Build/Intermediates.noindex/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/Binary/MyApp normal armv7 (in target 'MyApp' from project 'MyApp')
The key thing there is the armv7 architecture. This architecture is only part of the build process if you have a deployment target of 10.x or earlier but not if you have 11.x or later. And if the frameworks you are including don't have armv7 architecture (e.g. if they are built for 11.0+), XCode gives very misleading error messages about the frameworks not being found. What really isn't found is that specific architecture inside the framework.
Bottom line: My problem had nothing to do with framework search paths. Removing $(PROJECT_DIR) from the framework search path only appeared to solve the problem by triggering a different compile-time problem to happen before it got to the linker problem.
The solution in this case is that I must change my deployment target to 11.0, then everything builds properly.
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 stuck with including a 3rd party framework (written in Objective-C) into my Swift application. I did the following (which should be sufficient):
Include the framework into the project
Add the framework to the "Link Binary with Libraries" build phase
Add the framework to the "Copy Files" build phase (destination: "Frameworks")
Import the main header of the framework into the bridging header
Compiling the project succeeds. But as soon as I try to run it I receive the following error:
dyld: Library not loaded: /Library/Frameworks/ZipKit.framework/Versions/A/ZipKit
Additionally I set the following settings:
Runpath Search Paths: #executable_path/../Frameworks
Framework Search Paths: #executable_path/../Frameworks (in addition to the source location of the framework)
Library Search Paths: #executable_path/../Frameworks
Nothing seems to work and I don't have any clue why the runtime keeps looking in the /Library folder.
I'm currently using Xcode 6 Beta 6 (as the GM does not support Swift on OS X).
Edit
Just to clarify: The app bundle contains the linked framework after compilation (I've checked that).
Found it.
Fortunately I have the source code of the framework I want to include.
I stumbled upon the install path setting of the framework project which was set to /Library/Frameworks.
I changed this to #executable_path/../Frameworks re-compiled it, re-compiled my project and now it works.
I have build a App based on OS X FUSE (ie I have my own file system based on OS X FUSE).
When OSXFUSE is installed I can of course include the OSXFUSE.framework from /Library/Frameworks.
However when I distribute the App I cannot expect the user to already have it installed, so I tried to include the framework with the bundle as follows:
dragged the framework from /Library/Frameworks to my project
created a new Copy Files build phase (with target Frameworks)
added the framework to that copy build phase
However when I run that on a system without FUSE installed I get an error:
dyld: Library not loaded: /Library/Frameworks/OSXFUSE.framework/Versions/A/OSXFUSE
Referenced from: /Users/me/Library/Developer/Xcode/DerivedData/
Shouldn't the copy build phase prevent this? What am I missing here?
I finally found out that I can tell XCode explicitly to weakly link a framework by changing the required flag to optional.
This can be done in Project Overview > Target > Linked Frameworks and Libraries. Next to each framework is a dropdown-menu where you can select optional.
So my question is actually a duplicate of this How do I weak link frameworks on Xcode 4?
I believe that the OSXFuse framework needs a corresponding kernel module to work. This has to be installed separately so you would have to put together an installer package that first installs the kernel module and the preferences pane, and then installs your application.
Alternatively, you could notify the user that the module needs to be installed separately and provide a download link or something to that effect.
I have a working application which relies on several static libraries, which I've added as dependencies to the application and added to the link with static libraries bit in build phases. Everything builds and runs fine in the simulator and on my attached iPad.
I wanted to create an .ipa for use with test flight so I followed the instructions on test flight's site (http://support.testflightapp.com/kb/tutorials/how-to-create-an-ipa-xcode-4) and some other tutorials relating to creating an archive with an app that uses static libraries (http://diaryofacodemonkey.ruprect.com/2011/03/18/ad-hoc-app-distribution-with-xcode-4/, http://www.musicalgeometry.com/?p=1237).
Following these tutorials, when I create an archive I get linker errors about not being able to find various libraries, for example:
ld: library not found for -lOAuthTouch
(I've also tried using a new project and a new static library project to make sure it's not some setting I've changed and I get the same problem).
This seems to be because I added a build configuration called "Ad Hoc" to my app for creating an archive, and based on the linker command and the fact that adding an "Ad Hoc" configuration to all the static libraries I use allows the archive to be created I'm assuming that the static libraries are being built to a different directory.
I'd rather not have to add a new build configuration to all the libraries I use, so my question is, what should I do to create an archive of my app without tinkering with every library I use?
A second related question: all the tutorials I mentioned say to set the "Skip install" build setting to yes for static libraries, but the Apple documentation (http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/DistApps/DistApps.html) seems to indicate setting it for the application, rather than the libraries. Anyone know which is right?
It will work, you must simply get the paths correct and make sure you have set Skip install to NO on each of the static libraries in the workspace. I recently went through this and ended up deleting the existing Ad hoc distribution configuration from both my main target and each of the static library targets. The I created a new ad hoc configuration on the main project and each static library project and verified all of the settings in each of them.
See this link, this, and this all of which helped with sort through this.