I'm trying to get a project running on an iPhone 5C, one that needs a lot of frameworks. I added all that was needed in Link Libraries.
The project works on an iPhone 5S and an iPad, but on an iPhone 5C it returns the following error:
dyld: Library not loaded: /System/Library/Frameworks/AVKit.framework/AVKit
Referenced from: /var/mobile/Applications/28EC3D4B-1011-45EA-8A6C-7D62DBC9CC09/cnContainerApp.app/cnContainerApp
Reason: image not found
Then it would seem as if AVKit.framework has not been added. Oh, but it is.
Now some of the suggestions I've read online was to:
Put it in Embedded Binaries - Tried that, but it didn't do anything. I'm also reluctant to try and touch anything on a project that works on every other device.
Clean and build - Tried it, didn't do anything.
Delete derived data - Nope.
Switch Embedded Framework with Swiftto Yes - Eh, my project was exported from Unity. No real Swift files as far as I know.
My Runpath Search Paths has #executable_path/Frameworks already.
iPhone 5C has the version of 7.0, while the Xcode project has the deployment target of 6.
If it means anything the version of the iPhone 5S it worked on was 8.4.
Any other suggestions?
Your iPhone5C iOS version is lower than iOS 8.0.The lowest iOS version to support embedded frameworks is iOS 8.If you deploy the app on a device running 7.x with the embedded frameworks, it would crash with your error log(dyld : image not found) at runtime because it is not supported.
To solve this, just upgrade your target iOS version at least to above 8.0.If you still need to keep support under 7.x for some reason, you should use static libraries instead of embedded frameworks.
here is related link
Related
Our app uses CoreNFC to scan NFC tags or you can use QR if NFC is not supported. This worked pretty well and we were able to run the app in the simulator for (ui) testing purposes.
Until Xcode12 / iOS14 GM builds. In iOS13 (or lower) we wouldn't have any issues running it on a simulator.
But in Xcode12 running it on a iOS14 simulator iPhone11 we would get the following:
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/xxx/Library/Developer/CoreSimulator/Caches/dyld/19G73/com.apple.CoreSimulator.SimRuntime.iOS-14-0.18A372
DYLD_ROOT_PATH=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot
DYLD_LIBRARY_PATH=/Users/xxx/Library/Developer/Xcode/DerivedData/xxx-awnlestrbvesqqbynrhmluzhbcsc/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libBacktraceRecording.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSi
dyld: Library not loaded: /usr/lib/libnfshared.dylib
Referenced from: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/CoreNFC.framework/CoreNFC
Reason: no suitable image found. Did find:
/usr/lib/libnfshared.dylib: mach-o, but not built for platform iOS-sim
That the simulator crashes makes sense to me, since the simulator can't scan NFC tags, but this is what I've done:
I already linked to the CoreNFC framework and made it optional, like described here: Xcode 10, Swift 4 app with CoreNFC crashes in review on iOS 12
Put #if canImport(CoreNFC) around import CoreNFC and it's underlying NFC code.
Cleaning the build folder and deleting derived data.
Created an empty Xcode12 project: https://github.com/basvankuijck/CoreNFCCrashProject, same result.
Removed all the listed simulators and re-added one
Added -weak_framework "CoreNFC" to the Other Linker Flags build setting
Obviously removing any references to the CoreNFC framework by either commenting out code sections and removing the framework link, makes the crash disappear. But that's not a suitable option.
Running it from Xcode12 on an iOS13 simulator 'device' works perfectly. So I can't seem to figure out what is causing this behavior
Apple obviously forgot to add libnfshared.dylib for whatever reason in the final version of Xcode 12 for iOS 14 simulators. A working workaround until Apple fixes this is to copy the missing lib from Xcode 12 beta 6 over (download the beta from Apple's developer download section). The missing lib can be found here and must go into the same directory for final Xcode 12
This works for me. 💯
If you want to avoid the hassle of downloading 11.25GB Xcode 12.2 beta for a single file. I have the file to share.
You may execute the following command to download and place it inside the Xcode package:
sudo curl https://storage.googleapis.com/mobile-simulator-build/libnfshared.dylib -o /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libnfshared.dylib
Hope it helps 😉
Apple obviously forgot to add libnfshared.dylib for whatever reason in the final version of Xcode 12 for iOS 14 simulators. A working workaround until Apple fixes this is to copy the missing lib from Xcode 12 beta 6 over (download the beta from Apple's developer download section). The missing lib can be found here and must go into the same directory for final Xcode 12:
Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib
Linker says that the file libnfshared (mach-o) doesn't include the binary for a simulator, which is strange because it's Apple core framework.
Create a new project with Xcode 12 and import the NFC framework. Build it and run it on a simulator. If it doesn't crash then compare the build settings specially for DYLD between those projects.
If this doesn't help, delete all the simulators and recreate new ones.
Updated:
It's bug in IOS 14 and someone has submitted a radar: openradar.appspot.com/FB8699389
A bit in later, but maybe useful for others...
scenario:
App must use NFC (where available)
Must work also on pre-NFC device (i.es. iPhone 6 with iOS12)
Build for iOS12
Some "good to use" technics:
#if canImport(CoreNFC)
import CoreNFC
...
instead of old:
#available(iOS 11.0, *) .. and similar..
Notes:
"canImport" works at compile time, so if You want to solve:
"dyld: Library not loaded: /System/Library/Frameworks/CoreNFC.framework/CoreNFC
Referenced from: /var/...
Reason: image not found" message
we have to pay attention to LINK section.
Link section:
Xcode 12.5 does not allow "optional" linking in its menus
we must go to "Other Linker flags" and add:
-weak_framework
CoreNFC
on 2 lines
(in text will be:
OTHER_LDFLAGS = -weak_framework CoreNFC -lstdc++
)
I was having same issue with my application, Although I wasn't using CoreNFC framework. this gets solved with
Xcode-12.2 beta 2. Released on September 29, 2020
I have an app working with my own framework. I made the framework build for i386 as well as arm and everything is fine. My app used to run on every simulators and is available on the store.
Now, for some reason, i can't run my app on some simulators.
The simulators that work :
iPhone 4s
iPhone 5
iPad 2
iPad Retina
The simulators that doesn't work :
iPhone 5S
iPhone 6
iPhone 6S
iPad Air
Resizable iPhone
Resizable iPad
The error is that a *.h file from my framework in not found.
I'd like to know what can prevent this file from being found, or rather what search path is not used with some simulators. There must be some project/target property that screws with those simulator types, except that i can't find any that would make a difference.
In my code i've searched for any kind of difference i would make, but they are just about iOS version regarding UI components. I also use TARGET_IPHONE_SIMULATOR but it should not make any difference between simulators.
FYI, my app version nows include Watch Kit. It's working on the Apple Watch as well as on the Apple Watch simulator attached to the iPhone 5 (external display). It may be related...
Any help much appreciated!
Edit: The full error description:
/Users/me/sources/myApp/iOS/trunk/include/someFile.h:18:10: 'dir/someOtherFile.h' file not found
Edit: Header files in all targets:
My framework and every files that include any .h of my framework are only part of the myApp, i took care not adding any reference in myApp.watchkit or myApp.watchkitextension
Edit: Solutions tried:
Xcode restart
Reboot
+Alt+Shift+K
Delete derived data
Edit: 64-bits:
I use some paths like that in the project file:
$(FRAMEWORK_SEARCH_PATHS)frameworkName_$(CURRENT_ARCH).framework/Versions/A/Headers
For example, it refers to '/searchPathFolder/frameworkName_i386.framework/...' when i build for simulators.
Solved. The issue came from my framework that for some reason wasn't build for 64 bits simulator versions.
For everything to work fine, the project needs 4 versions of the framework: x86 (32 bits simulator), x64 (64 bits simulator), armv7 (32 bits device) and arm64 (64 bits device).
Then with project properties, unnecessary frameworks are simply ignored at build time:
ignoring file myFramework_i386.framework/myFramework_i386, file was built for archive which is not the architecture being linked (arm64)
I am working on xCode 6.3.1, everything is working fine while debugging on device iPhone 5s iOS 8.3 but when I disconnect device and try to test application with simulator there are hundreds of errors about "Missing references" for many framworks (with any simulators iOS8+)
I tried to remove missing references and add again in "Build Phase" but no use.
Furthermore, I am having pods setup but missing references are from project of course. It was working fine before update to Xcode 6.3.1, here is one example error: Undefined symbols for architecture x86_64: "_ABAddressBookCopyArrayOfAllGroups". Addressbook is not some framwork which should only supported for device and not for simulator.
It is working fine with device, I uploaded Archive to app store, there was no issue either. Only with simulator.
I found solution, may be could help someone else, for me it was iPhone SDK location path as follows:
Build Settings>Framework search paths>iPhoneOS.platforms
I did not correct this path, I Just delete path and its working on simulator now.
Furthermore, Archive and debugging on device work perfect as well.
With Xcode 6.x we can use CocoaTouch Framework template to build a framework library and Xcode will create the .framework for us when we build, which is awesome. In our framework we want to support iOS 7.1 and up, so for Deployment Target (in our framework) we specified 7.1. Now when we build we see a warning: "Embedded dylibs/frameworks only run on iOS 8 or later". I've since read a number of blog posts on the subject that as far as running it on iOS 7.1 this warning can be ignored because it will run fine (still need to test to make sure). What concerns me is that I read a post on Stack Overflow which says an app may be rejected by Apple in the App Store (see: Xcode 6 and Embedded Frameworks only supported in iOS8)
Does it only apply when in Xcode the app links to it in General > Embedded Libraries?
The way we want our customers to link to our framework is:
Via CocoaPods
By referencing .framework in Build Phase > Link Binary With Libraries
I need to understand under what conditions App Store will reject an app which uses our CocoaTouch framework and supports 7.x iOS.
The app wont be rejected if you'll change the type of your framework to Static. See my answer here.
I believe that as long as the app deals with the framework correctly there shouldn't be any issues. Mixing with cocoapods could be tricky and honestly I don't know the best way to tackle it.
But from what I understand, if an app supports iOS 7.X -> 8.X and uses an embedded cocoa touch framework, as long as the compatibility checks are there to ensure the app doesn't crash in 7.X, there shouldn't be any reason for the app to be rejected.
We tried running the latest code on the following configurations:
iOS 8+ — iPhone 5s
iOS 7.1.2 — iPhone 4
iOS 6.1.3 — iPad 4
The App is working fine on all the three devices but the warning is present in the Xcode while compiling .
"embedded dylibs/frameworks only run on iOS 8 or later”
Also I tried to Archive the App in order to submit it to the app store it went on fine.
Also, found out a link where in an apple developer stated this to be a bug:
https://devforums.apple.com/message/999579#999579
I just upgraded from Xcode 6 Beta 2 to Xcode Beta 3 and am now getting the following warning when building my project:
ld: warning: relocatable dylibs (e.g. embedded frameworks) are only supported on iOS 8.0 and later (#rpath/libswift_stdlib_core.dylib)
It is a warning but seems to mean my current setup will not work on iOS 7.1, which is my deployment target. How can I track down which frameworks are embedded, and how can I fix this for iOS < 8.0?
This appears to be a bug of Beta 3. As pointed out by Apple Engineer on this post.
I have also been living with this warning when running apps on iOS 7.1 device.
You see and add them on the project page when you select the target: tab General->Embedded Binaries (and they then appear in Build Phases->Embed Frameworks).
Embedded frameworks for OSX were available in Xcode 5, but not for iOS.
WWDC session regarding new features in Xcode 6 specifically promised dynamic frameworks for iOS 8 (someone please add citation when developer center comes back online). So far, with all Xcode 6 betas, I have had no problems compiling and debugging an app with frameworks on iOS 7.
But since this wasn't promised, frameworks for iOS7 is something you cannot depend on (e.g. this may stop working in later betas; an app with embedded framework for iOS 7 may be rejected, etc.). That may explain why they added an explicit warning.
There's not much you can do if this feature turns out to be indeed unsupported, other than remove the frameworks from the target and use static libraries as we did with Xcode 5. Or go the iOS8-only route.
After using XCode 6.1.1 I am able to put the code on iOS 8+ iOS7.1.2 and iOS 6.1.3 Although the warning is still there but the app works absolutely fine on all the 3 OSs
======================
Lucky guy... My project keeps failing to compile after I referenced the PushKit framework.
The project is a new project created by Xcode with only 3 new functions for testing Push Notification.
The workaround is to put the PushKit framework as "embedded", but this is not a good solution since my working Xcode project will be generated from Unity3d. Making the changes manually will break the auto build process.
I had this error after adding a C++ framework (DeepBelief) to a project. Adding an empty .cpp file to the project fixed it.
I'm using Beta4, and found the answer on the DeepBelief github site:
XCode may be skipping the standard C++ library, and that's needed by
the DeepBelief.framework code. One workaround I've found is to include
an empty .mm or .cpp file in the project to trick XCode into treating
it as a C++
project.
Read this github post from ReactiveCocoa
The bug is still present in XCode6 GM and so XCode6 final release:
Well, I get the exact same issue in xcode6GM no matter whether I
create framework for swift OR objc :-[[[[[[[[[[[[[[[
According to Apple Extension Programming Guide:
You can make a containing app available to users running iOS 7 or earlier, but then must take precautions to safely link embedded frameworks when running in iOS 8 or later.
talking about app extensions, but if you read it, you can understand that this applies to embedded frameworks in general.
this is happening because one of your embedded binaries's deployment target is lower than your applications target. lower your embeded binaries's building target and be fine.
this was the error cause in xcode 6.1.1
i was using xcglogger with deployment target ios 8.0, and my application's deployment target 7.0. set the xcglogger's deployment target ios 7.0 and problem solved.
After using XCode 6.1.1 I am able to put the code on iOS 8+ iOS7.1.2 and iOS 6.1.3
Although the warning is still there but the app works absolutely fine on all the 3 OSs
Yes not able to submit the app for review.
Had to do by changing the modern frameworks to Static libs.