Library not loaded: #rpath/libswiftMetalKit.dylib in UITests in Xcode10 - swift

When running my UITests Target in Xcode10, I now get:
Library not loaded: #rpath/libswiftMetalKit.dylib . <--- (Library varies)
Referenced from: ../MyApp.app/PlugIns/MyAppUITests.xctest/Frameworks/Hero.framework/Hero <-- (Framework varies, all installed with Cocoapods 1.6.0beta1)
Reason: image not found)
My regular target works fine. My Regular target and UITests targets both have "Always Embed Swift Standard Libraries" set to Yes, though I noticed the Pods Project and frameworks have this set to No.
Things I've tried:
Cleaning project, deleting derived data, and rebuilding project
Verifying my code signing is working
Setting "Always Embed Swift Standard Libraries" to Yes on the Pods Project and frameworks.
adding #rpath to the Runpath Search paths for the UI Tests Target
So far nothing has worked. Anyone else encountering this issue or have insight into what might help?
EDIT:
Thanks #matt for pointing me in the direction of the related isue.
I tried importing UIKit and recreating target, both to no avail.
Importing the specific frameworks (i.e. Hero) or the libraries (i.e. MetalKit) in one of my UITest targets allows it to build, but mysteriously my other UITest target will still not build due to libswiftSwiftOnoneSupport (referenced by Alamofire) not building.
Still not sure if this is due to my Cocoapods setup (All my targets including UITest targets import all pods, which I think should be unnecessary but I get missing frameworks for my pods if I don't), but the exact same setup worked fine prior to XCode 10.

What worked for me was the followings:
Copy from your TARGETS from your basic project let say 'sample_app' > Build Phases the section [CP] Embed Pods Frameworks.
Now In the UITest TARGETS, let say 'sample_app_UITests' create a new Run Script and copy everything.
Clean/Build

Setting the workspace setting to Legacy build fixed it for me: File > Workspace Settings > Build System: Legacy Build System

Related

No such module 'IQKeyboardManagerSwift'

New to Xcode (dabble a little). I paid a developer to build an iOS app for me. He sent me the source code and I have opened it in Xcode 13.2.1. I needed to edit the info.plist to include a description why location was required (got this done). When I try to run the build, I get the error 'no such module 'IQKeyboardManagerSwift'. In AppDelegate, I see 'import IQKeyboardManagerSwift --- No such module 'IQKeyboardManagerSwift'. I went to the Podfile directory and ran 'pod install'. Output says:
Analyzing dependencies
Downloading dependencies
Generating Pods project
Integrating client project
Pod installation complete! There are 7 dependencies from the Podfile and 8 total pods installed.
I'm still getting the error when trying to run the build. I tried cleaning the build folder and running the build again but still, same error. What am I missing?
I'm not sure why this happens, but one way to solve your issue is to go into your build settings and define the Framework Search Paths to a folder that contains the frameworks in question. If the frameworks are placed in your project directory, simply set the framework search path to $(SRCROOT) and set it to recursive.
Is the codebase completely in Swift?, else you will have to include import in the Bridging header file
If in swift you can try:
Select project name -> Select Build Settings(tab) and search Framework Search Paths double click and set the desired path($(SRCROOT)) to recursive
The missing module handles a number of keyboard behaviors so you don't have to reinvent that wheel. Check out the developer's website and get it for yourself. I've been using it for years. The developer has helped me more than once get past some obstacles.

How to link custom framework within UITest target in Xcode - another "Library not loaded - #rpath"-issue

My project uses Xcode 11.3.1 and is structured as followed:
MyProject
- MyProject.xcworkscapce
- MyFramework
- MyApp
-MyApp (main-target)
-MyAppUITests (uiTest-target)
MyApp imports MyFramework and can be built und run just fine. For this to work I added MyFramework to main-target into main-targets General/Frameworks and Libraries.
In my UITest target I need to access some classes (Accessibility-Identifier-Definitions) from MyFramework, so I need to import these somehow.
Both targets are building and the main-target works without any issues. I am also able to run ui-tests on a simulator. Unfortunately I am forced to run my tests on real devices, and here I get this runtime error:
The bundle “MyAppUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
(dlopen_preflight(/var/containers/Bundle/Application/E581B3BA-A9A2-4AA3-A1BA-91C57DCD3846/MyAppUITests-Runner.app/PlugIns/MyAppUITests.xctest/FHCommunityUITests): Library not loaded: #rpath/MyFramework.framework/MyFramework
Referenced from: /var/containers/Bundle/Application/E581B3BA-A9A2-4AA3-A1BA-91C57DCD3846/MyAppUITests-Runner.app/PlugIns/MyAppUITests.xctest/MyAppUITests
Reason: image not found)
I am fairly new to this framework-thing (and also to ui-tests) and it's been two days I am dealing with this issue now. Most posts about similar issues are related to misspecified Podfiles, but in my barebone sample project which I setup to not destroy my real project I am not using any Pods. I tried probably all of the suggested solutions (and almost all combinations :() and none of them seem to work.
It took me a while to figure out that in my uiTest-target build phases I can actually add a New Run Script Phase and I assume I need to somehow link MyFramework here.
Is this correct? Can someone help me defining the run script?
And yes, I tried to clean my app (and I also deleted derived data).
Help is highly appreciated. Thank you!
Ok, finally I figured it out. The solution is fairly simple and I haven't seen anyone suggesting this. Here we go:
To use your custom framework in your app target simply add it under Frameworks, Libraries, and Embedded Content:
Now you can access MyFramework from the main target.
I could also run my ui-tests from the simulator, but still got the error described above when executing my ui-tests from my real devices.
To get rid of the The bundle “xxxUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.-Error I had to go to my uiTest-target and link the framework in my build phases.
As Destination choose Frameworks and select the Framework you want to use in your uiTest-target.
Now you should be able to run your ui-Test from your device.

Xcode 10 archive build compile failure

Building on devices and simulator works fine in Xcode 10 but an archive build in Xcode 10 hangs up at the same spot each time (cpu maxes out too), at the very end of "Compile Sources" but never goes to the next build phase. Of course, when I quit the build I get an uncategorized SwiftCodeGeneration warning (also using legacy build system also fails, also same happens before and after updating to swift 4.2). Anyone else running into this?
Another note, not using cocoapods, tried removing all my embedded frameworks and still had the same issue.
remove the armv7 from supported architecture works for me
I found some answers to this problem.
I adjusted the level of optimization, this allowed me to get past the "compile sources" build phase (in particular "fastest and smallest" and "optimize for speed").
the compiling then got stuck on the "copy bundle resources" phase. making sure my project folder names matched the actual folder names and making sure all my resources were linked properly by deleting the reference to a few and re-entering them into the project I was able to successfully compile. Again this was a project that worked a couple days ago on Xcode 9. Hope this helps someone, cheers.

Getting dyld_fatal_error after updating to Xcode 6 beta 4 using swift

I just recently downloaded Xcode 6 beta 4, and my swift project compiles with no errors but before it gets to my code I get a dyld_fatal_error just above start in the call stack.
and a breakpoint in some assembly code with a nop instruction
The console error I get is
dyld: lazy symbol binding failed: Symbol not found: __TFSsa6C_ARGVGVSs13UnsafePointerGS_VSs4Int8__
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/Sudoku
Expected in: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/../Frameworks/libswift_stdlib_core.dylib
dyld: Symbol not found: __TFSsa6C_ARGVGVSs13UnsafePointerGS_VSs4Int8__
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/Sudoku
Expected in: /Users/username/Library/Developer/Xcode/DerivedData/Sudoku-dhrdonaeqzsgcvewndimxbbsltnc/Build/Products/Debug/Sudoku.app/Contents/MacOS/../Frameworks/libswift_stdlib_core.dylib
Just so you know the project still compiles, and runs fine with Xcode 6 beta 3.
Most extremely weird problems like this can be solved with a Clean & Build (or perhaps relaunch Xcode). You might also consider deleting the relevant folders from ~/Library/Developer/Xcode/DerivedData.
For sure this error is very unhelpful:
dyld`dyld_fatal_error:
-> 0x1200ad088 <+0>: brk #0x3
This of course occurs only on device, not the simulator. Another good reason to always test on a device.
Anyway, having had the same issue, a clean didn't work for me. Deleting DerivedData didn't help either. Also tried synchronising the Deployment Target versions. That didn't seem make any difference but I did it anyway.
Solution was to add any dynamic frameworks to Embedded Binaries setting under Target -> General:
Now I know that has been mentioned in other answers. However, if I can supplement by saying that any dependent dynamic frameworks must also be included.
So for example if you have a dynamic framework A that depends upon dynamic framework B, then it's necessary to have A and B added to Embedded Binaries.
Note that if the dynamic framework A depends upon any static library or framework, you will almost certainly be forced to create A as an umbrella framework that includes the dependant binaries.
Other considerations that may or may not be important. However did personally for me result in success were;
paths of each dynamic library in the Inspector were set to "Relative
to Group". In the screen grab above the path of the embedded binary
appears correct terminating with "build/Debug-iphoneos".
dynamic frameworks are in embedded binaries section. Static libs and
static libs wrapped up as frameworks are in Linked Frameworks
and Libraries. Nothing appears in both sections.
In setting this up XCode behaved strangely. The following proved successful:
Add the dynamic framework to the embedded binaries.
Find the new framework in XCode groups on the left and update the path to be
"Relative to Group" as described previously.
Delete the dynamic framework from embedded binaries.
Add the dynamic framework to the embedded binaries again. The path should now appear correctly.
Delete all references to the dynamic framework from the Linked Frameworks
and Libraries section.
I have just had this problem trying to link a custom iOS framework to my project, so for anyone out there who has this problem, it's to do with the copy files build phase.
I think that this error results when a file cannot be found. So create a copy files build phase in the appropriate target in your project. Then add the file (in my case the custom framework) to this phase (if it's a framework make sure to select the 'Frameworks' destination).
Cleaning, restarting, deleting etc didn't work for me.
I have a project containing another project. When I ran the project on iOS 7 and the contained project was accessed in code, the app stopped at the line below:
After many days, I saw that the deployment target for the container project was 7.0 (as can be seen below).
The contained project on the other hand, had a deployment target of 8.1 (as can be seen below).
Changing the deployment target of the contained project to 7.0 solved my problem!
The project was working fine on iOS 8 devices.
I had this issue recently and the problem for me was that I had added a library from the same project which wasn't listed in 'Embedded Binaries' from the 'General' section.
NOTE: If you add it in Embedded Binaries it will also add to the Linked Libraries section, possibly adding the same one twice.
Clean and build won't work. You'll need to delete he cache in ~/Library/Caches/com.apple.dt.Xcode* directories. Delete these and rebuild.
Do this every time you upgrade the beta.
I also faced the same issue and tried all the solution given above without any luck.
then what I have done to resolve that I really don’t have much I idea about. So there is Certificated called “apple worldwide developer relations certificate authority” in System group in keychain Access and due to some profile and certificate issue I randomly mark this certificate “Always trusted” from “Use System Defaults”. So this is causing this “dyld_fatal_error” crash to me. when I revert it back to “Use System Defaults” crash got resolved.
So guys if you are tried all the possible option to resolve this crash and didn’t succeed yet, try this also. It helped me, may help you as well.
Found this about this certificate.
This problem still occurs in Xcode 7, and it can happen for a variety of reasons (it seems). In my case, the iOS app with an included framework:
ran on the simulator fine
gave the error you described on the device
The answer was to NOT use linked libraries but rather Embedded Binaries under General.
Also see here: https://stackoverflow.com/a/34052368/8047
Adding the non-system Framework to "Embedded Binaries" inside the general tab of the main project worked for me.
As stated by bitwit, this will also add your framework to "Linked Frameworks and Libraries", so watch out for those duplicates.
Tested with Xcode 7.3.
Xcode 8.
Clean and build didn't work. I deleted the cache, deleted Derived data. After that, my pods configuration was broken, so i needed to install pods again. Pods Target configuration was set to a very old Valid architectures. setting to armv7 and armv7s, was ok to compile and no problems
You'll get this if your scheme has "Guard Edges" enabled in diagnostics when running on an actual device. "Guard Edges" only works in the simulator.
I was using cocoapods and had this problem as well when I updated to deploy target iOS 8 and added use_frameworks! to my Podfile. I was able to fix it by adding the following line to my Podfile:
link_with 'TargetName1', 'TargetName2', etc.
Might work with ProjectName as well

Xcode4 Linking Problem. File was built for archive which is not the architecture being linked (arm6)

Recently, I switched to Xcode4 and when I compile my project I got following error.
ld: warning: ignoring file /Users/myname/Library/Developer/Xcode/DerivedData/appname-hezrgyqimckztgbdlslkavphdclw/Build/Products/Debug-iphoneos/libTapkuLibrary.a, file was built for archive which is not the architecture being linked (armv6)
Undefined symbols for architecture armv6:
"_OBJC_CLASS_$_TKLoadingView", referenced from:
objc-class-ref in RootViewController.o
I opened the TapkuLibrary and checked that it's Architectures set to 'Standard (armv6 armv7)'.
What can I do to fix this problem?
I figured out what caused the problem. I changed 'Build Active Architecture Only' of TapkuLibrary from Yes to No and it compiles with no problem.
I was able to solve this problem by doing the opposite of the accepted answer - I changed the 'Build Active Architecture Only' from NO to YES.
Had the same problem. But the reason was different I suppose. I was using the library.a file built for simulator and trying to run it on device.. came to know that i need different .a files for simulator and device. I hope this helps someone ;)
I met this problem when I upgraded the XCode to 4.5 and iOS to iOS6. For GMGridView, it just happened.
Not for simulator, but only for device.
I fixed this by the following steps:
1) Go to GMGridView project -> Build Settings
2) Under Setting -> Architectures, select "Standard (armv7, armv7s)"
Then clean all (including DerivedData) and rebuild.
Hope it helps!
Try to remove the armv6 architecture, and compile it only for armv7.
Something else that worked for me was making sure that all sub projects had the architecture set to be armv6 and armv7, making sure to set both the TARGET and the PROJECT of each sub project. After cleaning and rebuilding everything, it worked without a problem.
This solved the problem for me:
Some external library like three20 did extra settings for
Build Settings->Architectures->Any iOS SDK
the value is "armv6 armv7" that different from standard "armv7 armv7s"
drop down and select "Standard", it worked for me.
I managed it by clicking the "unfriendly" Project's (in my case GMGridView).
In tab "Architectures", I changed the value from something (I don't remember exactely anymore, I guess it was:) "armv7, armv6s" to "armv7, armv7".
After that it worked for me.
I managed to resolve this by just creating a adhoc configuration inside the Tapku info settings ...
XCODE 4, Project > Archive = library not found for -lTapkuLibrary - Issues - devinross/tapkulibrary - GitHub
Make sure the build variants on your projects are set to "normal".
If you are building a project which includes other projects, take a look inside the DerivedData folder for the main project. Examine the archive files with the "lipo -info yourarchive.a". Also, examine the timestamps on these archives. You may find that these libraries are not getting rebuilt or you are trying to link against an old version of the archive which is the wrong architecture.
In my case, I shutdown Xcode and deleted the DerivedData folder for my main project. This forced a full rebuild when I reopened the main project in Xcode 4. The full rebuild caused the i386 archives to be created (or the correct version to be found) & the simulator version to link correctly.
This worked for me :
Click on the offending framework's 'Project' file (xcodeproj).
Go to the "Info" tab for the framework's 'Project' (not 'Target').
Expand 'Configurations' and make sure that both 'Debug' and 'Release' have 2 configurations set--one for the framework's 'Project' and another for the framework's 'Target'. In the case of frameworks the 'Target' compiles to a Library and not an application, so it's easy to get confused.
'Debug' should have the Project set to 'Debug' and the Library set to 'Shared'
'Release' should have the Project set to 'Release' and the Library set to 'Shared'
Compile, run, and enjoy.
If you ended up mangling your entire project trying to figure this out, then you might want to double-check your Application's Project build phases (as Gon suggested). The Library should be there highlighted in red, even if it doesn't exist on your drive. If not, as long as it's set to 'Shared' you should be able to add it back again.
If you really really really mangled your project, then you may be forced to blow out your DerivedData folder, as russes suggested. Also, check the 'Organizer', since Xcode has a way of saving crap all over the place.
Oh, and you checked to make sure that 'armv6' is there right? :)
If I get the ignore file warning - I would run lipo -info on ignored file to find it's architecture as below
lipo -info libTapkuLibrary.a
That would print either of i386, armv6, armv7, armv7s, x86_64 etc. In general, that architecture has to match with your target build platform. E.g.
i386 = ios simulator or 32 bit build on mac os x
armv6 armv7 arm7s = ios device
x86_64 = 64 bit build on mac os x
Depending on the mismatch, either you have to rebuild your library for your target platform or change your target platform.
Note: For fat binaries, lipo -info will print a combination of above architectures.
I fixed this problem thanks to another thread where they show that armv6/armv7 is actually a little different than what you think it is: Upgrading to xcode 4 error No architectures to compile for
None of these answers worked for me. (Similar warning message, different static library project). For me it was having configured XCode to honor the build directories of the targets and then having targets build in a local build/ directory that caused the problem. Configuring XCOde to use "Derived data" folder fixed it.
I had this problem with the Three20 library. The thing that finally did it for me was switching the Project Format from Xcode 3.1 to Xcode 3.2 - leaving 'build active arch only' as "no".
I tried all the options above and none worked.
This is the right answer:
simply dragging a framework in your project won't link it properly (or something along these lines, in any case)
what you need to do is select the framework you want to add in Build Phases (click on your project's blue icon, then select your project's name under Targets, then the tab Build Phases), see here for more reference.
Had the same problem, and tried diverse solutions from the page to no avail.
I still had a message telling me my library was not build for arm64.
Finally how I resolved it :
opened the project.pbxproj for the library in a text editor
searched for VALID_ARCHS
there were 4 occurrences, 2 of which did not contain arm64
I manually added arm64 in the chain (VALID_ARCHS = "arm64 i386 armv7 armv7s")
rebuild the lib and it was all right
Seems sometimes the build settings displayed by XCode is incomplete, and doesn't correspond precisely to the make file.