Works on Simulator, fails on device: error: WatchKit App doesn't contain any WatchKit Extensions - objective-c

I am seeing the following error when trying to run a project on a real device, in the simulator it runs fine.
error: WatchKit App doesn't contain any WatchKit Extensions. Verify that the value of NSExtensionPointIdentifier in your WatchKit Extension's Info.plist is set to com.apple.watchkit
Things which may or may not be relevant
I am using cocoa pods in both the watch and main app target
The project is mostly objective-c but has a few swift files
Xcode 8.1 (8B62)
Device Software Versions: iOS 10.1.1 & WatchOS 3.1
Deployment Info > Deployment Target: iOS 10.0 watchOS 3.0
Things I’ve tried
I have checked several times that all the correct files belong to the watch target. I may have missed something here, but I assume it wouldn’t run on the simulator if this was the case
Bundle identifiers
main app’s identifier: < app id >
watch app’s bundle identifier: < app id >.watchkit
watch app’s WKCompanionAppBundleIdentifier: < app id >
watch extension’s bundle identifier: < app id >.watchkit.extension
watch extension’s NSExtension>NSExtensionAttributes>WKAppBundleIdentifier: < app id >.watchkit
NSExtension>NSExtensionPointIdentifier: com.apple.watchkit
WKWatchKitApp is set to YES in both the Watch Extension and the Watch App
I have removed and re-added the .appex from Build Phases>Embed App Extensions
Ensuring Mach-O Type is set to executable in all targets
Re-installing pods as described in this answer
Clearing derived data
Clearing build folder
Restarting Xcode
I tried an archive and this failed with the same error
In lieu of an answer, advice on debugging / troubleshooting this would be appreciated too.

I've seen this intermittently, but usually rebuilding a second time fixed it. I've never got to the bottom of why.
I've always assumed it's a bug in Xcode.
Sorry can't be more help, but you're not alone in seeing this.

I encountered this error, with 3 other errors.
Turned out the problem is that Valid Architectures is set incorrectly. Under Build Settings, make sure Valid Architectures includes i386 and armv7k.
Once that is fixed, the watch extension will be build, and all errors gone.

Related

Xcode 12 Problems: "Build input file cannot be found "- Building for release on a react native app

When I try to do an archive build for "any iOS device", I receive this error:
Build input file cannot be found: '/Users/.../Library/Developer/Xcode/DerivedData/[app]-czrkuohjfzuzxxfobfoyptxhyoyo/Build/Intermediates.noindex/ArchiveIntermediates/[app]/InstallationBuildProductsLocation/Applications/[Product Name].app/[Product Name]'
I received this same error when building for an iOS simulator, but this post fixed it - Problems after upgrading to Xcode 12:ld: building for iOS Simulator, but linking in dylib built for iOS, architecture arm64.
I am also receiving a warning concerning the architectures that may or may not be relatable to the error:
None of the architectures in ARCHS (arm64) are valid. Consider setting ARCHS to $(ARCHS_STANDARD) or updating it to include at least one value from VALID_ARCHS (arm64, armv7s, armv7) which is not in EXCLUDED_ARCHS (arm64).
Build for "Any iOS Device" (for example, "Archive" because you want to upload to AppStore):
Delete arm64 from "Excluded Architectures"
Delete x86_64 from VALID_ARCHS
Add arm64 to VALID_ARCHS
All this changes on both "Build Settings", project and target. And if you want to build for simulator do the inverse path:
Add arm64 to "Excluded Architectures"
Delete arm64 from VALID_ARCHS
Add x86_64 to VALID_ARCHS
That works for me.
So I had the exact same issue. After updating to Xcode 12 I had originally set both my project and target 's 'Excluded Architecture' to arm64 in order to run on Simulator. But, as you mention, that blocks anything from working on Release / Real device. All I had to do was switch to 'Any iOS Simulator SDK = arm64' instead of all of them, see screen shot below:
link to screenshot
This error started happening for me with a SwiftUI app. I didn't need the file for my project, but the settings were set to generate a file anyways. What worked for me was to go into Project Navigator --> App Target --> Build Settings --> Packaging and delete the value (file name) for the Info.plist File key.
This problem wasted a lot of my time after upgrading to xcode 12, using React Native 0.63. Excluding architectures did not work for me.
Symptoms: "build input file could not be found..." when running on device in debug AND release. Simulator worked fine.
To Fix: Editor > Validate Settings... > Perform Changes
Now my app builds fine on device.
I know this question has been answered but this piece of information may help someone: This kind of error may also be produced if you have no node_modules folder e.g. you have deleted it and forgot to re-create it

Invalid Bundle Structure for WatchKit

I'm trying to submit a WatchKit app to the App Store but get this error.
Another cause for this is including a WatchKit or any other TargetApplication.app inside your application bundle.
Do not include any in your project settings > target > Build Phases > Copy Bundle Resources.
A bug in Xcode (6.2..) added it there when I tried to add it to Target > General > Embedded Binaries. Nothing changed in that section and no errors were shown so I ignored the bad feeling it gave me.
After hours dealing with other certificate issues (and hosing all of our TestFlight testers, due to revoking distribution certs, which was apparently/probably required), upgrading to Xcode 6.3.1 I finally remembered this bad feeling and found the app watchkit application lurking in the Copy Bundle Resources section and removed it.
In addition to the Invalid Bundle Structure error above the specific errors exhibited for me were:
ERROR ITMS-90378: "CFBundleIdentifier Collision. There is more than one bundle with the CFBundleIdentifier value 'com.company.App.watchkitapp' under the iOS application 'App.app'
ERROR ITMS-90451: "CFBundleIdentifier Collision. The Info.plist CFBundleIdentifier value 'com.company.App.watckitapp' of 'App.app/App Watchkit App.app' is in conflict with the Info.plist CFBundleIdentifier value of 'App.app/Plugins/App Watchkit Extension.appex/App WatchKit App.app'
All were gone and submission worked fine after removing.
Also, validation passed fine even with both instances of the watckit app.
You cannot submit WatchKit apps yet even though Xcode 6.2 and iOS 8.2 are officially out. See the following answer for more info.

Confirmation: does "Cocoa-Touch framework" only support for iOS8 or later? [duplicate]

When using an embedded framework (dyld) in Xcode 6.0.1 with deployment target less that iOS 8 I get:
Build is successful
Runtime library loading error
Error:
dyld: Library not loaded: #rpath/ObjectiveLyricsTouch2.framework/ObjectiveLyricsTouch2
Referenced from: /private/var/mobile/Containers/Bundle/Application/DC65ACA9-98E5-46CD-95F8-829D3416F6C0/musiXmatch.app/musiXmatch
Reason: image not found
(lldb)
For some time I was thinking that this is my problem as well, but for normal apps (non-iOS-8-extension) you just need to change one build setting in your casual Xcode 6 iOS Universal Framework target (set Mach-O Type to Static Library):
There should be no problem with iTunes Connect and iOS 7 after that :)
So,
after digging around I came out with the solution
Supposed to have yours MyEmbeddedFramework.framework to add to the app, do this
Remove MyEmbeddedFramework.framework in the tab General > Embedded Binaries
Remove the Build Phases > Copy Phase "Frameworks" if you have MyEmbeddedFramework.framework there.
Clean Build Folder
Move the MyEmbeddedFramework.framework in the void Embedded Frameworks section.
You will see now that a new Build Phase > Embedded Frameworks is created by XCode6 (not you, it is done automatically)
Now if you have 5, it should run without erros.
So to recap, to make it works you should see MyEmbeddedFramework.framework in
A) General > Embedded Binaries
B) Build Phase > Embedded Frameworks
It worked fine on iPhone5/iOS8 not on iPhone4S/iOS7 where I get:
dyld: Library not loaded: #rpath/ObjectiveLyricsTouch2.framework/ObjectiveLyricsTouch2
Referenced from: /var/mobile/Applications/739D9C44-3B91-4D4F-805B-83BE66C9CBCA/musiXmatch.app/musiXmatch
Reason: no suitable image found. Did find:
/private/var/mobile/Applications/739D9C44-3B91-4D4F-805B-83BE66C9CBCA/musiXmatch.app/Frameworks/ObjectiveLyricsTouch2.framework/ObjectiveLyricsTouch2: incompatible cpu-subtype: 0x0000000B in /private/var/mobile/Applications/739D9C44-3B91-4D4F-805B-83BE66C9CBCA/musiXmatch.app/Frameworks/ObjectiveLyricsTouch2.framework/ObjectiveLyricsTouch2
The problem was in the EmbeddedFramework. I had to
1) Set Architecture to default
2) Set Valid Architectures to: armv7, armv7s and armv64 (as Apple suggests armv64 is needed to have Embedded Frameworks working).
Then I was able to run the app with an embedded framework on
iPhone5S/iPhone5C iOS8
iPhone5S/iPhone5C iOS7
iPod 5th gen / iOS7
iPhone4S / iOS7
iPhone4 / iOS7
Anyways when submitting to iTunesConnect I get some errors for the Minimum Required Version:
The MinimumOSVersion of framework "..." is invalid. The minimum value is iOS 8.0;
Invalid Architecture: Apps that include and app extension and a framework must support arm64;
As of right now there is no way to use an embedded framework to share code between an app and widget and have it run on iOS 8 as well as iOS 7 & previous.
Here's some more reading on that http://atomicbird.com/blog/ios-app-extension-tips
Frameworks vs. iOS 7
If you are sharing code between an app and an extension, one nice way to do so is to create your own embedded framework to hold the code. On iOS 8 it'll load dynamically for both cases, so you're set.
If you still support iOS 7 (or earlier), it's not so clear cut. Embedded frameworks don't work there. The App Extension Programming Guide breezily notes that you can use dlopen to deal with this. With that approach you write code to load the framework dynamically at run time rather than rely on iOS loading it for you, if you've verified that the code is running on a version of iOS that supports doing so.
But how do you use that code on iOS 7? You don't. If your shared code is in an embedded framework, there's no way to execute it on iOS 7. It's just unavailable.
The dlopen approach might be handy if you only need the shared code on iOS 8. If you need it on iOS 7, you'll need to include it in the app target. And once you do that, you have no need of the framework. You could still use a framework for the app extension, but doing so is not actually useful. You'd be doing the work of creating the framework but not getting any benefit from it. Just include the shared code in both targets.
And from Apple's extension guide https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensibilityPG.pdf
If you link to an embedded framework from your containing app, you can still deploy it to versions of iOS older than 8.0, even though embedded frameworks are not available in those versions.
Fixed the error in xcode 6.1.1
using vim or vi open the project.pbxproj file.
At the end of the file (search for 8.1) , there would be Begin XCBuildConfiguration section
Look for your framework.
In out case even though the deployment target was set to 7.1 via Xcode -> general in target settings, the entry in the file had 8.1 for both debug & release
Here's the old file section looks like:
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "#rpath";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = ENFramework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) #executable_path/Frameworks #loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
New section looks like :
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "#rpath";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = ENFramework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) #executable_path/Frameworks #loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Now we don't get error just a warning (but works on iOS 7.1 device) :
ld: warning: embedded dylibs/frameworks only run on iOS 8 or later
This looks like an xcode bug which incorrectly sets different ios targets and then causes error.
Going deeper on Apple Documentation I found out about dlopen command, which is used to make the linking of the libraries on some conditions, depending on system versions and libraries supported.
dlopen example of use:
Is the function 'dlopen()' private API?
So let's look at the solution provided by Apple Docs:
Deploying a Containing App to Older Versions of iOS
If you link to an embedded framework from your containing app, you can
still deploy it to versions of iOS older than 8.0, even though
embedded frameworks are not available in those versions.
The mechanism that lets you do this is the dlopen command, which you use to conditionally link and load a framework bundle. You employ this command as an alternative to the build-time linking you can specify in the Xcode General or Build Phases target editor. The main idea is to link embedded frameworks into your containing app only when running in iOS 8.0 or newer.
You must use Objective-C, not Swift, in your code statements that conditionally load a framework bundle. The rest of your app can be written in either language, and the embedded framework itself can likewise be written in either language.
After calling dlopen, access the embedded framework classes using the following type of statement:
MyLoadedClass *loadedClass = [[NSClassFromString (#"MyClass") alloc] init];
IMPORTANT
If your containing app target links to an embedded framework, it must
include the arm64 architecture or it will be rejected by the App
Store.
To set up an app extension Xcode project to take advantage of conditional linking
For each of your contained app extensions, set the deployment target
to be iOS 8.0 or later, as usual. Do this in the “Deployment info”
section of the General tab in the Xcode target editor.
For your containing app, set the deployment target to be the oldest
version of iOS that you want to support.
In your containing app, conditionalize calls to the dlopen command
within a runtime check for the iOS version by using the
systemVersion method. Call the dlopen command only if your
containing app is running in iOS 8.0 or later. Be sure to use
Objective-C, not Swift, when making this call.
Certain iOS APIs use embedded frameworks via the dlopen command. You must conditionalize your use of these APIs just as you do when calling dlopen directly. These APIs are from the CFBundleRef opaque type:
CFBundleGetFunctionPointerForName
CFBundleGetFunctionPointersforNames
And from the NSBundle class:
load
loadAndReturnError:
classNamed:
In a containing app you are deploying to versions of iOS older than
8.0, call these APIs only within a runtime check that ensures you are running in iOS 8.0 or newer, and call these APIs using Objective-C.
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
Just for the record... I had this issue when changing a project from iOS8 to iOS7 deployment type.
The app used cocoapods and no custom embedded frameworks.
I had to change the main project two targets
Application
Application-Test
Changing Mach-O Type to static (from above answer).
Then on the cocoapods project. Under each sub pod project changing the Mach-O type to static, leaving the main pod Project Mach-O setting to blank.
I set the Mach-O Type to EXECUTABLE and it worked for me. Setting it to Static, Dynamic or Bundle created other errors when I ran it.
Target > "Your App" > Build Settings > Linking > Mach-O Type > Executable
I solve this problem following way :
Use same deployment target in both target "Embedded Framework" and "main App" target.
So, temporary, i said no to dynamic library, while many devices on iOS 7. How i solved my problem. I was need lib for transferring model between app and extension. So, i put my model to JSON string into shared container. And it works like a charm.
When you use dynamic library on ios you must code signed the library. In the Xcode 6, you should select the "Code Sign On Copy". And with the Xcode5, you should sign the library by your self with run script. like :
LOCATION="${BUILT_PRODUCTS_DIR}"/"${FRAMEWORKS_FOLDER_PATH}"
IDENTITY="iPhone Developer: xxxxx"
codesign --verbose --force --sign "$IDENTITY" "$LOCATION/BeeFramework.framework/BeeFramework"
Remove the use frameworks! from your PodFile if you want the Framework to work in iOS 7.0. i.e. run pod deintegrate command, modify your PodFile and then rerun the pod install command
Also after this, I had to add all the .h file's of the Framework in the Bridging file, that fixed the issue. Also remove the import TestLibrary from the swift files
I had a bug when updating to xcode 7.3. And I had solution for me.
- Change targets in pods project -> 7.0
- Hope it useful!
I was running into an issue where i needed to include some libraries as embedded frameworks otherwise i received the above error and when I did just that, I received errors when submitting to the app store.
My solution was to use Pods and make sure you uncomment the "use_frameworks!" line.
iOS Dynamic framework pre iOS v8
Dynamic framework aka Embedded framework is supported from iOS v8, but you can try to change Mach-O type[About] to Dynamic Library (which is set by default for supported target)
Dynamic linking error[About]
dyld: Library not loaded: #rpath/<some_path>
It is an dynamic linker error which links binary in load or runtime
[Vocabulary]

Xcode 6 and Embedded Frameworks only supported in iOS8

When using an embedded framework (dyld) in Xcode 6.0.1 with deployment target less that iOS 8 I get:
Build is successful
Runtime library loading error
Error:
dyld: Library not loaded: #rpath/ObjectiveLyricsTouch2.framework/ObjectiveLyricsTouch2
Referenced from: /private/var/mobile/Containers/Bundle/Application/DC65ACA9-98E5-46CD-95F8-829D3416F6C0/musiXmatch.app/musiXmatch
Reason: image not found
(lldb)
For some time I was thinking that this is my problem as well, but for normal apps (non-iOS-8-extension) you just need to change one build setting in your casual Xcode 6 iOS Universal Framework target (set Mach-O Type to Static Library):
There should be no problem with iTunes Connect and iOS 7 after that :)
So,
after digging around I came out with the solution
Supposed to have yours MyEmbeddedFramework.framework to add to the app, do this
Remove MyEmbeddedFramework.framework in the tab General > Embedded Binaries
Remove the Build Phases > Copy Phase "Frameworks" if you have MyEmbeddedFramework.framework there.
Clean Build Folder
Move the MyEmbeddedFramework.framework in the void Embedded Frameworks section.
You will see now that a new Build Phase > Embedded Frameworks is created by XCode6 (not you, it is done automatically)
Now if you have 5, it should run without erros.
So to recap, to make it works you should see MyEmbeddedFramework.framework in
A) General > Embedded Binaries
B) Build Phase > Embedded Frameworks
It worked fine on iPhone5/iOS8 not on iPhone4S/iOS7 where I get:
dyld: Library not loaded: #rpath/ObjectiveLyricsTouch2.framework/ObjectiveLyricsTouch2
Referenced from: /var/mobile/Applications/739D9C44-3B91-4D4F-805B-83BE66C9CBCA/musiXmatch.app/musiXmatch
Reason: no suitable image found. Did find:
/private/var/mobile/Applications/739D9C44-3B91-4D4F-805B-83BE66C9CBCA/musiXmatch.app/Frameworks/ObjectiveLyricsTouch2.framework/ObjectiveLyricsTouch2: incompatible cpu-subtype: 0x0000000B in /private/var/mobile/Applications/739D9C44-3B91-4D4F-805B-83BE66C9CBCA/musiXmatch.app/Frameworks/ObjectiveLyricsTouch2.framework/ObjectiveLyricsTouch2
The problem was in the EmbeddedFramework. I had to
1) Set Architecture to default
2) Set Valid Architectures to: armv7, armv7s and armv64 (as Apple suggests armv64 is needed to have Embedded Frameworks working).
Then I was able to run the app with an embedded framework on
iPhone5S/iPhone5C iOS8
iPhone5S/iPhone5C iOS7
iPod 5th gen / iOS7
iPhone4S / iOS7
iPhone4 / iOS7
Anyways when submitting to iTunesConnect I get some errors for the Minimum Required Version:
The MinimumOSVersion of framework "..." is invalid. The minimum value is iOS 8.0;
Invalid Architecture: Apps that include and app extension and a framework must support arm64;
As of right now there is no way to use an embedded framework to share code between an app and widget and have it run on iOS 8 as well as iOS 7 & previous.
Here's some more reading on that http://atomicbird.com/blog/ios-app-extension-tips
Frameworks vs. iOS 7
If you are sharing code between an app and an extension, one nice way to do so is to create your own embedded framework to hold the code. On iOS 8 it'll load dynamically for both cases, so you're set.
If you still support iOS 7 (or earlier), it's not so clear cut. Embedded frameworks don't work there. The App Extension Programming Guide breezily notes that you can use dlopen to deal with this. With that approach you write code to load the framework dynamically at run time rather than rely on iOS loading it for you, if you've verified that the code is running on a version of iOS that supports doing so.
But how do you use that code on iOS 7? You don't. If your shared code is in an embedded framework, there's no way to execute it on iOS 7. It's just unavailable.
The dlopen approach might be handy if you only need the shared code on iOS 8. If you need it on iOS 7, you'll need to include it in the app target. And once you do that, you have no need of the framework. You could still use a framework for the app extension, but doing so is not actually useful. You'd be doing the work of creating the framework but not getting any benefit from it. Just include the shared code in both targets.
And from Apple's extension guide https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/ExtensibilityPG.pdf
If you link to an embedded framework from your containing app, you can still deploy it to versions of iOS older than 8.0, even though embedded frameworks are not available in those versions.
Fixed the error in xcode 6.1.1
using vim or vi open the project.pbxproj file.
At the end of the file (search for 8.1) , there would be Begin XCBuildConfiguration section
Look for your framework.
In out case even though the deployment target was set to 7.1 via Xcode -> general in target settings, the entry in the file had 8.1 for both debug & release
Here's the old file section looks like:
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "#rpath";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = ENFramework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) #executable_path/Frameworks #loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
New section looks like :
CURRENT_PROJECT_VERSION = 1;
DEFINES_MODULE = YES;
DYLIB_COMPATIBILITY_VERSION = 1;
DYLIB_CURRENT_VERSION = 1;
DYLIB_INSTALL_NAME_BASE = "#rpath";
GCC_PREPROCESSOR_DEFINITIONS = (
"DEBUG=1",
"$(inherited)",
);
INFOPLIST_FILE = ENFramework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 7.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) #executable_path/Frameworks #loader_path/Frameworks";
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
Now we don't get error just a warning (but works on iOS 7.1 device) :
ld: warning: embedded dylibs/frameworks only run on iOS 8 or later
This looks like an xcode bug which incorrectly sets different ios targets and then causes error.
Going deeper on Apple Documentation I found out about dlopen command, which is used to make the linking of the libraries on some conditions, depending on system versions and libraries supported.
dlopen example of use:
Is the function 'dlopen()' private API?
So let's look at the solution provided by Apple Docs:
Deploying a Containing App to Older Versions of iOS
If you link to an embedded framework from your containing app, you can
still deploy it to versions of iOS older than 8.0, even though
embedded frameworks are not available in those versions.
The mechanism that lets you do this is the dlopen command, which you use to conditionally link and load a framework bundle. You employ this command as an alternative to the build-time linking you can specify in the Xcode General or Build Phases target editor. The main idea is to link embedded frameworks into your containing app only when running in iOS 8.0 or newer.
You must use Objective-C, not Swift, in your code statements that conditionally load a framework bundle. The rest of your app can be written in either language, and the embedded framework itself can likewise be written in either language.
After calling dlopen, access the embedded framework classes using the following type of statement:
MyLoadedClass *loadedClass = [[NSClassFromString (#"MyClass") alloc] init];
IMPORTANT
If your containing app target links to an embedded framework, it must
include the arm64 architecture or it will be rejected by the App
Store.
To set up an app extension Xcode project to take advantage of conditional linking
For each of your contained app extensions, set the deployment target
to be iOS 8.0 or later, as usual. Do this in the “Deployment info”
section of the General tab in the Xcode target editor.
For your containing app, set the deployment target to be the oldest
version of iOS that you want to support.
In your containing app, conditionalize calls to the dlopen command
within a runtime check for the iOS version by using the
systemVersion method. Call the dlopen command only if your
containing app is running in iOS 8.0 or later. Be sure to use
Objective-C, not Swift, when making this call.
Certain iOS APIs use embedded frameworks via the dlopen command. You must conditionalize your use of these APIs just as you do when calling dlopen directly. These APIs are from the CFBundleRef opaque type:
CFBundleGetFunctionPointerForName
CFBundleGetFunctionPointersforNames
And from the NSBundle class:
load
loadAndReturnError:
classNamed:
In a containing app you are deploying to versions of iOS older than
8.0, call these APIs only within a runtime check that ensures you are running in iOS 8.0 or newer, and call these APIs using Objective-C.
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
Just for the record... I had this issue when changing a project from iOS8 to iOS7 deployment type.
The app used cocoapods and no custom embedded frameworks.
I had to change the main project two targets
Application
Application-Test
Changing Mach-O Type to static (from above answer).
Then on the cocoapods project. Under each sub pod project changing the Mach-O type to static, leaving the main pod Project Mach-O setting to blank.
I set the Mach-O Type to EXECUTABLE and it worked for me. Setting it to Static, Dynamic or Bundle created other errors when I ran it.
Target > "Your App" > Build Settings > Linking > Mach-O Type > Executable
I solve this problem following way :
Use same deployment target in both target "Embedded Framework" and "main App" target.
So, temporary, i said no to dynamic library, while many devices on iOS 7. How i solved my problem. I was need lib for transferring model between app and extension. So, i put my model to JSON string into shared container. And it works like a charm.
When you use dynamic library on ios you must code signed the library. In the Xcode 6, you should select the "Code Sign On Copy". And with the Xcode5, you should sign the library by your self with run script. like :
LOCATION="${BUILT_PRODUCTS_DIR}"/"${FRAMEWORKS_FOLDER_PATH}"
IDENTITY="iPhone Developer: xxxxx"
codesign --verbose --force --sign "$IDENTITY" "$LOCATION/BeeFramework.framework/BeeFramework"
Remove the use frameworks! from your PodFile if you want the Framework to work in iOS 7.0. i.e. run pod deintegrate command, modify your PodFile and then rerun the pod install command
Also after this, I had to add all the .h file's of the Framework in the Bridging file, that fixed the issue. Also remove the import TestLibrary from the swift files
I had a bug when updating to xcode 7.3. And I had solution for me.
- Change targets in pods project -> 7.0
- Hope it useful!
I was running into an issue where i needed to include some libraries as embedded frameworks otherwise i received the above error and when I did just that, I received errors when submitting to the app store.
My solution was to use Pods and make sure you uncomment the "use_frameworks!" line.
iOS Dynamic framework pre iOS v8
Dynamic framework aka Embedded framework is supported from iOS v8, but you can try to change Mach-O type[About] to Dynamic Library (which is set by default for supported target)
Dynamic linking error[About]
dyld: Library not loaded: #rpath/<some_path>
It is an dynamic linker error which links binary in load or runtime
[Vocabulary]

Library not loaded

I added Social.framework in my application in the same way i use to add the other frame works. I have downloaded xcode 4.5 and iOS 6 . but my application crashes with follwing error only on device. It works fine on simulator.
dyld: Library not loaded: /System/Library/Frameworks/Social.framework/Social
Referenced from: /var/mobile/Applications/FC88291D-2052-45D6-A7BB-65CE340F07BF/Uploading Image.app/Uploading Image
Reason: image not found
I was getting this exact error. My app currently has a deployment target of 5.1. I wanted to add Facebook sharing. I found this old post, Conditionally including a library for different iOS SDK versions?. All I did was set "Social.framework" to 'optional' and it did the trick, then my app would run on ios 5.1 and ios 6.0. Of course you need to do checks at runtime for what OS the device is running otherwise you could run into a crash if you try to access social.framework in ios 5.1 or earlier. Hope that helps!
In Xcode go to targets, Go to build phase and search for Social frame work you will find that under "Link Binary with Libraries" section. There select social frame work and see there is an option on right hand side required/optional in that just change required to optional. Now you are able to run on all ios devices without any crashes.