iOS 8 Dynamic Framework: Library Not Loaded - ios

I've been working on an iOS 8 app that includes a Share Extension. Both app and extension targets use a new iOS 8-style dynamic framework. In an effort yesterday to get the damned thing into the TestFlight Beta App Review (see here and here), I made a number of changes to my build configuration. The store eventually accepted the app for review, but today as I'm trying to run on my device I'm getting the following error:
dyld: Library not loaded:
/Users/aaron/Library/Developer/Xcode/DerivedData/VideoGrabber-gpyzpfvbijsnuyglzzvynckkuwee/Build/Products/Debug-iphoneos/MyAppKitiOS.framework/MyAppKitiOS
Referenced from: /private/var/mobile/Containers/Bundle/Application/4C6CFF22-0595-4222-A515-D0D5A1696DBF/MyApp.app/MyApp
Reason: image not found
Looking elsewhere for help, I've come across a number of proposed solutions:
Add the framework to the App Target's Embedded Binaries section of the General tab. Done.
Enter "#executable_path/Frameworks" into the Runpath Search Paths section of Build Settings on the App Target. Done.
Ensure there's an entry in the "Copy Files" build phase. Step one actually does this for you, so... Done.
Having followed the advice in this otherwise-excellent piece and looking at the solutions offered in the Dev Forums with the exact same issue, I'm totally flummoxed. Anything else I can try?

I got it working by comparing something known-good (Apple's Lister app) with my own Build Settings. By comparing the install paths for the framework, and then the search paths for my app target, I was able to get it working. In summary:
In the Framework Target's Dynamic Library Install Name Base, use "#rpath"
In the Framework Target's Dynamic Library Install Name, use "$(DYLIB_INSTALL_NAME_BASE:standardizepath)/$(EXECUTABLE_PATH)" -- this automatically resolves to the name of your framework.
In the Application Target's Runpath Search Paths, use "#executable_path/Frameworks".
Ensure "Always Search User Paths" is set to No. Framework Search Paths could be blank too.
If it's after lunchtime, pour yourself three fingers of scotch. You've earned it.
Since it's morning still, I'll console myself with gentle weeping.

Related

iMessage app, "disallowed nested bundles" error trying to archive/upload with binary framework

I have an iMessage app (not an app with an iMessage extension) in which I have successfully added a binary framework (the project runs just fine on device and simulator)
However, I cannot successfully upload the project to App Store Connect - upload from the archive build returns the following errors:
The relevant text of the error is:
The bundle ... contains disallowed nested bundles. Refer to https://developer.apple.com/go/id=framework-imessage
That link (if you follow the instructions for using an newer Xcode version) leads you back to the link below I used to add the framework to begin with... to run you will need Xcode 11 as I am using an XCFramework.
I added the framework to the iMessage app as instructed by Apple here:
https://developer.apple.com/library/archive/technotes/tn2435/_index.html
(see Embedding a Framework in an iMessage App section)
What do I need to change to the settings for the project or extension in order for the archive/upload process to succeed, while actually including the framework I need? I have searched on StackOverflow, and found a variety of posts related to cocoapods, or around various build settings of "Always Embed Swift Standard Libraries" that do not help.
I have reduced the problem down to a simple sample app you can see here, which builds and runs just fine but cannot be archived and uploaded:
https://www.dropbox.com/sh/jpa4oe7zlnb21wl/AACXkLbxIbayZUtJr3VDwO07a?dl=0
That directory contains a zip file of the project, and an image showing the error encountered.
You have .xcframework in your project. May be you haven't enable Build Libraries for Distribution in Build setting when you have build .xcframework. You can refer this link for this.
Edit:
Error message is Invalid Bundle. So check bundle name of message extension and frameworks which are in the .xcframework.
I've made a few changes regarding the stub app, it seems to work and validate ok.
Remove the Embed Framework from the extension target.
Add the Embed Framework in the app target, set the Destination to 'Frameworks'

How to debug "Invalid Bundle" error which happens only after submitting to app store

I have a lot of frameworks in my app. App works fine in adhoc/enterprise release. Only if I submit to the app store for testflight testing I get this error email from apple:
Dear developer,
We have discovered one or more issues with your recent delivery for "My app's name here". To process your delivery, the following
issues must be corrected:
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
Once these issues have been corrected, you can then redeliver the corrected binary.
Regards,
The App Store team
there is no specific information here. How can I debug it?
Got an answer from Apple Developer Technical Support which says it is a bug on Apple's side. this is the suggested workaround below which did not work for me:
To diagnose this issue, you should export the IPA you are sending to
the App Store from Xcode. Since IPAs are zip files, you can
decompress it by right clicking and saying Open With > Archive
Utility. You should find your main executable inside the unzipped
folder structure and run otool at the command line to see the library
list: otool -L
The list of paths you get should match what you find inside of your
IPA. All of your libraries should start with #rpath. A simple
comparison of everything in this list with the unzipped IPA folders
should reveal what is missing.
Once you know what is missing, go to your Xcode build phases setup.
There should be a build phase for either Copy Files or Embed
Frameworks that includes the missing library — you should just add the
library to the list. If you don’t see either of these build phases,
you can recreate it by adding a new Copy Files build phase, setting
the Destination to Frameworks, and adding the library to the list,
ensuring that Code Sign On Copy is checked.
If you don’t find anything missing in your main binary, make sure to
do the same search on any other binaries you may have, like for a
watchOS app or an iOS app extension.
If you find that all of the frameworks are in this build phase, please
take a look at the Embedded Binaries section of your app target’s
General page, and let me know if you see multiple levels of ../ next
to the binary that you found is missing.
Please let me know if it works for you!
I have encountered the same issue when uploading an app with watch support to the app store.
I was able to solve it with the hint from the first answer, using otool -L to analyze the binary from the ipa or xcarchive.
However, the problem was not with my frameworks (at #rpath) but with a swift lib. I noticed that libswiftWatchKit.dylib was missing in the frameworks folder.
The solution that worked for me was as simple as to set EMBEDDED_CONTENT_CONTAINS_SWIFT=YES in the build settings of the watch app (or the watch app extension, but not both). After that, all necessary swift libraries were correctly copied to the watch app path in the archive and upload to app store was working correctly.
Apparently, the watch app works and upload passes if you provide the necessary swift libraries only in the main app's folder.
After adding the custom Swift framework to my project I got this email after uploading the app to iTunes connect.
I got this email from iTunes store,
Invalid Bundle - One or more dynamic libraries that are referenced by your app are not present in the dylib search path.
The fix is simple for this issue,
Step 1: Make sure your Custom framework is added to Embedded Binaries in General tab of your target.
Step 2: Under build settings,
Set Always Embed Swift Standard Libraries = Yes for your main project target.
And Set Always Embed Swift Standard Libraries = No for your custom framework target.
This solved my problem and I was able to upload binary to iTunes connect.
Ref
Tried all the above solutions and did not work for me.
I was experiencing this issue in Xcode 10.1 recently and all my frameworks were referenced correctly (did otool -L and everything lined up).
Seems there were some changes in the apple validation process, may be a bug, may not be on Apple's end, but all my prior builds uploaded and validated fine -- and I did not add any new frameworks since.
Upon uploading the binary to iTunesConnect, I'd see the following error:
Invalid Bundle - One or more dynamic libraries that are referenced by
your app are not present in the dylib search path.
Invalid Bundle - The app uses Swift, but one of the binaries could not
link to it because it wasn't found. Check that the app bundles
correctly embed Swift standard libraries using the "Always Embed Swift
Standard Libraries" build setting, and that each binary which uses
Swift has correct search paths to the embedded Swift standard
libraries using the "Runpath Search Paths" build setting.
MY SOLUTION:
After days of debugging, what worked for me was to disable 'Include bitcode for iOS content' upon uploading the archive from Xcode organizer. Seems that this option modifies the binary which caused the validator to fail.
Or you can disable bitcode in your Build Settings
My Problem:
I had the same error with embedded frameworks.
The App project has Custom Framework project
Inside the Custom Framework project is another Custom Framework project
The app built to the simulator and to devices with no problem but failed the Apple test, returning "Invalid Bundle".
I inspected the package just like Taha had been told to by Tech Support and everything was present and correct!
My Solution:
I restructured the project so that the two custom frameworks sit side by side and one is no longer embedded within the other.
This looks to be an Apple validation problem since everything works fine on devices and the simulator but the work around was straight forward.
In my case, in the build settings, this was fixed when I added the following to the build settings for the library:
DYLIB_INSTALL_NAME_BASE = #rpath
The clue was a linker warning: 'YourLibrary has an install name beginning with “/”, but it is not from the specified SDK'
Had same issue. This happened to me because one of my Framework target was added to main target in "Link Binary With Libraries" but was not added to "Target Dependencies" and "Embedded Binaries"
I also received a similar mail from Apple:
Dear Developer,
We identified one or more issues with a recent delivery for your app,
"********. Please correct the following issues, then
upload again.
ITMS-90562: Invalid Bundle - One or more dynamic libraries that are
referenced by your app are not present in the dylib search path.
Best regards,
The App Store Team
I used my own framework for my watch app. I solved this issue by changing the framework option to "Embed Without Signing" in the Extension Target. The default option was "Do Not Embed".
I had the same problem, it was due to one framework not being present in the Frameworks subfolder in the app bundle.
I fixed it by adding a Copy Fields build phase, and adding the missing .framework file there.
This error message is also addressed in Apple Technical Note TN2435
Embedding Frameworks In An App: https://developer.apple.com/library/archive/technotes/tn2435/_index.html
You can find the error message under the heading "Missing Framework Bundle" with troubleshooting steps.
We had the same problem, and even after going through all the steps (see "Missing Framework Bundle"), the only thing that worked was disabling Bitcode.
So I struggled on this for two days. What it turned out to be was I had UITests checked in Archive for the Build for the Scheme I was archiving.
After unchecking it from Archive, re-archiving it, validating it (although validating it before always passed), and "Upload to AppStore" I did not get the e-mail from Apple informing me of Invalid Swift Support. Instead I got the e-mail that it'd been processed and is good to go!
In my case, I've had to add a framework from Notification App Extension to the main target (embed & sign in the main target, do not embed in the extension) - even though there was no mention about it in otool -L output.
Funny thing that Iterable official doc says that the framework should be embedded & signed in the extension - which would lead to another upload problem because of nested bundles.

WatchOS 2 App fails to launch on device with dyld_fatal_error for my Framework Library not loaded: Image not found

I've just followed the apple transition guide to upgrade my ObjectiveC app to WatchOS 2
https://developer.apple.com/library/watchos/documentation/General/Conceptual/AppleWatch2TransitionGuide/ConfiguretheXcodeProject.html
With the section "Sharing Code Between an iOS App and a watchOS App" describing how to duplicate an existing iOS framework into a WatchOS framework target for use by WatchOS as follows.
"If you already have a watchOS 1 app that shares a framework with your iOS app, duplicate your iOS framework target and modify it to support watchOS 2.
To duplicate and configure your framework target for watchOS 2
Open the project editor pane of Xcode. (The pane is normally closed.)
Control-click the target to display a context menu with a Duplicate command.
Change the name of the target so that you can identify it easily later.
In Build settings, change the following values:
Change the Supported Platforms setting to watchOS.
Change the Base SDK setting to the latest watchOS.
Change the Product Name setting so that it matches the name of your iOS framework. You want both frameworks to be built with the same name.
Add the framework to your WatchKit extension’s list of linked frameworks."
I've followed these steps to clone my framework which with the iOS framework was called MyFramework, and now the new WatchOS framework is called MyFrameworkWatch. But as described above the Product Name is set to MyFramework instead of MyFrameworkWatch. I presume this naming shift is so that I can include from my framework using
#import <MyFramework/SharedUtils.h>
instead of presumably having to change it to
#import <MyFrameworkWatch/SharedUtils.h>
I wouldn't mind the latter but I'll admit its nicer keeping the framework name the same.
After a bit more work beyond the initial automatic transition I managed to get my app working perfectly well on the simulator, but now switching to device i just can't get it to launch.
Launching my app on the device causes it to spin for a few seconds and then just crash. Launching the glance just causes it to spin indefinitely. Trying to run it from Xcode and running the app causes the app to eventually launch and spin, the spinning can last indefinitely sometimes, but eventually it gets through and i get the actual error reported as follows
dyld_fatal_error - dyld: Library not loaded: #rpath/MyFramework.framework/MyFramework referenced from WatchKit Extension Reason: image not found
So this is my Watch App Extension trying to link to the Watch framework, and doing so looking for the MyFramework name, not the MyFrameworkWatch name. I wonder if this name clashing has caused it to get confused?
When I try to find the frameworks referenced under the Products folder in Xcode I can see two frameworks
MyFramework
MyFramework
they're both reference the same path
/Users/jim/Library/Developer/Xcode/DerivedData/MyApp-byegspjumgwlfpahhwjgzpmfkcdx/Build/Products/Debug-iphoneos/MyFramework.framework
though you can see the target membership is separating the two frameworks, the top MyFramework is associated with the main app, today widget and framework tests project. The lower MyFramework is just associated with my Watch extension. It doesn't feel right that these are referencing the exact same path surely?
Finally when googling for this issue I've found reference of CocoaPods having similar problems though according to their site here
https://github.com/CocoaPods/CocoaPods/issues/4180
It's been fixed since September in version 0.39.0, which is the version that pod --version reports. So I presume I have their fix. I'm tempted to remove the cocoa pods from my framework to see if it helps.
Has anyone else followed the transition guide suggestions for creating a duplicate framework and then managed to get the app and framework actually installing on their watch ok?
Is there any way to analyse the build that is done to try and see if i can see problems with the built files so i don't have to wait for the watch to fail to launch the app to debug it.
Any help is really appreciated as always! Cheers!
Edit: I think I've managed to remove cocoa pods from the offending MyFrameworkWatch target by commenting out the target section in my pod file and running pod update/pod install... it didn't seem to clean up the target very well so i had to manually remove the cocoa pod steps in the post build step. Maybe i've not removed it properly, i find it a little confusing to know what is going on under the hood with cocoa pods. Regardless the same error occurred, so either i didn't remove it properly or it has no effect on this particular problem
Ok, this was caused by the apple documentation for transitioning being wrong, or me interpreting it wrong. It says
Add the framework to your WatchKit extension’s list of linked frameworks.
Where as actually the correct fix was to add the framework to the embedded binaries section (which automatically adds an entry to the linked frameworks anyways) and correctly places the framework within the watch extension under a Frameworks directory. Which the app then loads fine! So much frustration, I lost hours to this across a few days!!

Adding Framework and App Extension targets to IOS App project, am I doing it correctly?

I'm studying IOS/Swift development and I'd like to build an IOS app that in the future will have its own Today Extension. I've read that it is better to put the common logic (for example the logic that accesses Internet resources, performs some job on the result etc) between the App and its extension into a Custom Framework.. Since I think I'll need to change both Framework and App code during the development of the App, I'd like to avoid building the framework in a separate project, than use Show In Finder function to locate the framework bundle and then drag-and-dropping it within the App project.. So I'd like to know if this is the correct way to set up a Workspace with an App, the framework it uses and the Today Extension of the App:
Create a new Project with an IOS App target
Select the project in the Project Navigator and then Editor->Add Target... and specify a Cocoa Touch Framework
Editor->Add Target... and specify Today Extension
Add the framework in Linked Frameworks and Libraries
In this way I've seen that changes to the Framework sources do not need a Framework target recompilation, maybe because the project knows about the need to recompile framework sources even if I only build & run the IOS App target that uses that framework? Am I doing it right? I've seen that the Today Extension created in such way does not lists the framework in the Build Phases -> Target Dependencies while the IOS App does, but both of them correctly use the updated code of the Framework when I update it.
Then, I've noticed the following warning when I compile the project, but I don't know if it is related to the way I've setup the project:
ld: warning: linking against dylib not safe for use in application extensions: /Users/gianni/Library/Developer/Xcode/DerivedData/TestFrameworkApp-dshihhfiuepeqzddbnpgnfwilhem/Build/Products/Debug-iphonesimulator/TestFramework.framework/TestFramework
BTW is it normal that the entries within the Products folder are always red? Is it due to the fact that I build only for IOS Simulator since I don't have a Paid developer account that allows me to build for an IOS Device? Does this prevent me to build a framework that can be exported for some other Project since I can't find the Framework bundle with a right clicking on the framework product and selecting Show In Finder (and so I can't drag-and-drop it to another project)?
I hope I've been clear enough and that you'll point me in the right direction to understand what is the suggested way of starting my new project :)
It sounds to me like you're headed down the exact path I would take.
Regarding the warning you're seeing... I believe that checking the "Allow app extension API only" for your shared framework will supress that and cause build failures when you attempt to use a API that is not allowed in extensions.

dyld: Library not loaded: #rpath/libswiftCore.dylib

I am trying to run a Swift app on my iPhone 4s. It works fine on the simulator, and my friend can successfully run it on his iPhone 4s. I have iOS 8 and the official release of Xcode 6.
I have tried
Restarting Xcode, iPhone, computer
Cleaning & rebuilding
Revoking and creating new certificate/provision profile
Runpath Search Paths is $(inherited) #executable_path/Frameworks
Embedded Content Contains Swift Code is 'Yes'
Code Signing Identity is developer
Below is the error in entirety
dyld: Library not loaded: #rpath/libswiftCore.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/AppName
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/AppName.app/Frameworks/libswiftCore.dylib: mmap() error 1 at
address=0x008A1000, size=0x001A4000 segment=__TEXT in Segment::map() mapping
/private/var/mobile/Containers/Bundle/Application/LONGSERIALNUMBER/APPLICATION_NAME/Frameworks/libswiftCore.dylib
For me none of the previous solutions worked. We discovered that there is an "Always Embed Swift Standard Libraries" flag in the Build Settings that needs to be set to YES. It was NO by default!
Build Settings > Always Embed Swift Standard Libraries
After setting this, clean the project before building again.
For keen readers some explanation
The most important part is:
set the Embedded Content Contains Swift Code (EMBEDDED_CONTENT_CONTAINS_SWIFT) build setting to YES in your app as shown in Figure 2. This build setting, which specifies whether a target's product has embedded content with Swift code, tells Xcode to embed Swift standard libraries in your app when set to YES.
The flag was formerly called Embedded Content Contains Swift Code
Surprisingly enough, all i did was "Clean" my project (shift+cmd+K) and it worked. Did seem to be related to the certificate though.
I started getting this error when I removed:
#executable_path/Frameworks
from Runpath Search Paths in my build settings. Replacing it fixed everything up again (thank goodness for source control!)
I don't know how it got there, but it appears to be needed for a binary to find its embedded Swift runtime.
For the device, you also need to add the dynamic framework to the Embedded binaries section in the General tab of the project.
In Xcode 8 the option for Embedded Content Contains Swift Code option is no longer available.
It has been renamed to "Always Embed Swift Standard Libraries = YES"
Xcode 13 here (13.1 with react-native).
Created a clean react-native project and saw /usr/lib/swift as an entry in Runpath Search Paths.
After adding that, my project finally ran without crashing!
Nothing helped from what was suggested before.
I think it's a bug when certificates are generated directly from Xcode. To resolve (at least in Xcode 6.1 / 6A1052d):
go to the Apple Developer website where certificates are managed: https://developer.apple.com/account/ios/certificate/certificateList.action
select your certificate(s) (which should show "Managed by Xcode" under "Status") and "Revoke" it
follow instructions here to manually generate a new certificate: https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW32
go to Xcode > Preferences > Accounts > [your Apple ID] > double-click your team name > hit refresh button to update certificates and provisioning profiles
I was having this issue with running my Swift tests (but not my app). It turns out that the test needed to have more than #executable_path/Frameworks in it's Runpath Search Paths build setting for the test target. Setting the Runpath Search Paths to the following worked a charm for me:
$(inherited)
#executable_path/Frameworks
#loader_path/Frameworks
OK, sharing here another cause of this error. It took me a few hours to sort this out.
In my case the trust policy of my certificate in Keychain Access was Always Trust, changing it back to defaults solved the problem.
In order to open the certificate settings window double click the certificate in the Keychain Access list of certificates.
This issue occurs again in Xcode 10.2. You must download and install the following package from Apple. It provides Swift 5 Runtime Support for Command Line Tools.
https://support.apple.com/kb/DL1998?locale=en_US
You have to set the Runpath Search Paths to #executable_path/Frameworks as showed in the following screenshot of Build Settings:
If you have any embedded frameworks made in Swift, than you can set to YES the Build Options Embedded Content Contains Swift Code.
I think Apple has already summarized it under Swift app crashes when trying to reference Swift library libswiftCore.dylib
Cited from Technical Q&A QA1886:
Swift app crashes when trying to reference Swift library
libswiftCore.dylib.
Q: What can I do about the libswiftCore.dylib loading error in my
device's console that happens when I try to run my Swift language app?
A: To correct this problem, you will need to sign your app using code
signing certificates with the Subject Organizational Unit (OU) set to
your Team ID. All Enterprise and standard iOS developer certificates
that are created after iOS 8 was released have the new Team ID field
in the proper place to allow Swift language apps to run.
Usually this error appears in the device's console log with a message
similar to one of the following:
[....] [deny-mmap] mapped file has no team identifier and is not a platform binary:
/private/var/mobile/Containers/Bundle/Application/5D8FB2F7-1083-4564-94B2-0CB7DC75C9D1/YourAppNameHere.app/Frameworks/libswiftCore.dylib
Dyld Error Message:
Library not loaded: #rpath/libswiftCore.dylib
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x0000000120021088
Triggered by Thread: 0
Referenced from: /private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/TestApp
Reason: no suitable image found. Did find:
/private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/Frameworks/libswiftCore.dylib: mmap() error 1 at address=0x1001D8000, size=0x00194000 segment=__TEXT in Segment::map() mapping /private/var/mobile/Containers/Bundle/Application/C3DCD586-2A40-4C7C-AA2B-64EDAE8339E2/TestApp.app/Frameworks/libswiftCore.dylib
Dyld Version: 353.5
The new certificates are needed when building an archive and packaging
your app. Even if you have one of the new certificates, just resigning
an existing swift app archive won’t work. If it was built with a
pre-iOS 8 certificate, you will need to build another archive.
Important: Please use caution if you need to revoke and setup up a new
Enterprise Distribution certificate. If you are an in-house Enterprise
developer you will need to be careful that you do not revoke a
distribution certificate that was used to sign an app any one of your
Enterprise employees is still using as any apps that were signed with
that enterprise distribution certificate will stop working
immediately. The above only applies to Enterprise Distribution
certificates. Development certs are safe to revoke for
enterprise/standard iOS developers.
As the AirSign guys state the problem roots from the missing OU attribute in the subject field of the In-House certificate.
Subject: UID=269J2W3P2L, CN=iPhone Distribution: Company Name, OU=269J2W3P2L, O=Company Name, C=FR
I have an enterprise development certificate, creating a new one solved the issue.
Let's project P is importing custom library L, then you must add L into
P -> Build Phases -> Embed Frameworks -> +. That works for me.
This error message can also be caused when upgrading Xcode (and subsequently to a new version of Swift) and your project uses a framework built/compiled with an older/previous version of Swift.
In this case rebuilding the framework and re-adding it will fix the problem.
The most easy and easy to ignored way : clean and rebuild.
This solved the issue after tried the answers above and did not worked.
I was having the same problem after moving to a new mac, and after hours, trying all the suggested answers in the questions, none of this worked for me.
The solution for me was installing this missing certificate.
http://developer.apple.com/certificationauthority/AppleWWDRCA.cer
Found the answer here.
https://stackoverflow.com/a/14495100/976628
Change Copy Pods Resources for the target from:
"${SRCROOT}/Pods/Target Support Files/Pods-Wishlist/Pods-Wishlist-resources.sh"
to:
"${SRCROOT}/Pods/Target Support Files/Pods-Wishlist/Pods-Wishlist-frameworks.sh"
I solved by deleting the derived data and this time it worked correctly. Tried with Xcode 7.3.1GM
After having tried out everything, I finally found out, that the build seems not always include every detail again and again. Maybe for speeding up the process...
In order to ensure WHOLE packaging before running on a device, make a Clean first: Shift-Cmd-K.
Then build with: Cmd-B.
After that run it on your device.
Easy.
Kind regards to all you nice guys in that place!
We had a unity project that creates an xcode project that includes libraries that use swift.
We tried each and every reasonable suggestion on this thread.
Nothing worked. Code runs fine on new devices, and crashes on iOS<=12
It seems that swift is so smart, that even if you set it to "ALWAYS_EMBED_SWIFT_LIBRAIES"="YES" it does not include the swift libraries.
What actually solved the problem for us is to include a dummy swift file in the project.
The file must contain calls to dispatch, foundation libraries.
Apparently this hints mighty-xcode to force include the libraries, but this time for real.
Here is the dummy file we added that made it work:
import Dispatch
import Foundation
class ForceSwiftInclusion {
init() {
// Force dispatch library.
DispatchQueue.main.async {
print("something")
}
// Force foundation library.
let uuid = UUID().uuidString
print("\(uuid)")
}
}
For unity, also add project.AddBuildProperty(target, "SWIFT_VERSION", "Swift 5"); to your post processing for creating the xcode project.
In my case, it was just the name of my target :
I renamed it like this : MyApp.something and the same issue appeared.
But I saw in the build Settings window, my product module name has been changed like this MyApp-something.
So, I removed the dot in my target name (MyAppSomething) and the issue was gone.
For me, having tried everything with no success, what worked was to remove #executable_path/Frameworks from the Packaging section (don't know how it came to be in there in the first place)
What worked for me in Xcode 11 was going to General -> Frameworks, Libraries, and Embedded Content and changing the "Embed" option for the framework in question to "Embed & Sign"
None of the solutions worked for me. Restarting the phone fixed it. Strange but it worked.
none of these solutions seemed to work but when I changed the permission of the world Wide Developer cert to Use System defaults then it worked. I have included the steps and screenshots in the link below
I would encourage you to log the ticket in apple bug report as mentioned here as Apple really should solve this massive error:
https://stackoverflow.com/a/41401354/559760
I had the same issue for Xcode 13+ when I create a release build. Had to waste my time on troubleshooting this issue. Finally I was able to fix the issue with following step.
I added a new entry for Release in Runpath Search Paths in Build Settings -> Linking.
/usr/lib/swift
After adding that, I could run my app without crashing!
Xcode 7.2, iOS 9.2 on one device, 9.0 on other. Both had the error. No idea what changed that caused it, but the solutions above for the WWDR were correct for me. Install that cert and problem solved.
https://forums.developer.apple.com/message/43547
https://forums.developer.apple.com/message/84846
There are lot's of answers there but might be my answer will help some one.
I am having same issue, My app works fine on Simulator but on Device got crashed as I Lunches app and gives error as above. I have tried all answers and solutions . In My Case , My Project I am having multiple targets .I have created duplicate target B from target A. Target B works fine while target A got crashed. I am using different Image assets for each target. After searching and doing google I have found something which might help to someone.
App stop crashing when I change name of Launch images assets for both apps . e.g Target A Launch Image asset name LaunchImage A . Target B Lunch Image asset name LaunchImage B and assigned properly in General Tab of each target . My Apps works fine.
For me building a MacOS command line Swift app that depended on 3rd party Swift libs (e.g. SQLite) none of the above solutions seemed to work. What did work was directly adding the following path to my Runpath Search Paths in the Build Settings:
/Applications/Xcode.app/Contents//Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx/
Doing that did give a warning at runtime saying that Xcode had found 2 versions of libswiftCore - which makes sense. Except that not including that line resulted in Xcode not finding any versions of libswiftCore.
Anyway, that'll do for me even if it doesn't seem right - my app is just a utility that I'm not intending to distribute and at least it runs now!
I have multiple version of Xcode installed at the same time. The framework was built with a newer version of Xcode. The app that I tried to compile was with an older version of Xcode. When I cleaned and compiled both the framework and the app with the same version of Xcode then things worked.

Resources