Add UMEKit Framework to Cocoa Application - cocoa

I'm trying to link the UMEKit Framework into a cocoa application I'm working on. The application compiles fine but I cannot run the application due to the error:
dyld: Library not loaded: /Users/Joe/Library/Frameworks/UMEKit.framework/Versions/A/UMEKit
Referenced from: /Users/Joe/Documents/[MY APP PATH]/Contents/MacOS/[APP NAME]
Reason: image not found
I'm pretty sure it's a simple error brought about by me just not knowing how to properly link a framework in. I followed the apple documentation and added the framework project to my application project as a dependency but it just resulted in the same error.
I'd really appreciate some direct instructions on what exactly I need to do or what I appear to be missing here.
EDIT: This actually only happens when I compile and run as debug. For release it is fine. It would be useful to be able to use debug mode, of course, though so I don't know if this suggests anything to anyone?

Sounds like you're not copying the framework into your app. You can verify this by selecting "Show Package Contents" from the app's context menu in the Finder and look if the framework is in the app (under Contents/Frameworks).
If not, you need to add a "Copy Files" build phase to your target. Bring up the inspector for the build phase in Xcode, select "Frameworks" as the destination, then drag your framework into the build phase.

I have again the same problem.... I have to manually copy the Aquatic Framework in systems/library/framwork... then it works. Is there any other way to perform the task? And on e important thing, i am making plugins.. so is there any issue for adding frameworks in a plugin?

Related

Swift: App Installation Failed Could Not Inspect The Application Package (When Using Frameworks with XCode 6)

I'm having difficulties running a compiled app on an iPhone 6 (iOS8). It works fine in the simulator.
I get this error message:
App installation failed
Could not inspect the application package
Originally there were error messages - such as the one here but I fixed this temporarily by moving the output into the correct location. However even though all of the libraries are being codesign'ed correctly and are now found I am unable to use the app on my device.
There seems to be no further error messages and therefore no way of debugging anything. How exactly do normal iOS developers debug problems which give no error messages?
I guess the underlying problem is that my project is getting quite complex, there are a lot of moving pieces: a few cocoapods, Alamofire, ReactiveCocoa, and Moya.
I have a few general questions:
Where can I find information that documents the use of frameworks in XCode 6?
What is the difference between "Build Phases -> Link Binary With Libraries", "Build Phases -> Copy Files", "General -> Embedded Binaries" and "General -> Linked Frameworks and Libraries"?
Everything is compiling completely fine for the simulator, including the cocoapods, but I note that there are libPod.a files and wonder whether they need to be compiled into the app?
Mostly I am hoping to find some way of finding out why the application package can't be inspected. Surely whatever software that inspects this must be able to be debugged?!!
Edit:
For the record, (1) there is no file called Resources in the root folder as I get nothing back when I do this "find . -name Resources" so it cannot be that issue, (2) I have run "Product -> Clean" and then tried to build again and this does not solve the problem either, (3) the Info.plist does contain a CFBundleName which is set to "${PRODUCT_NAME}" currently (which I believe is set elsewhere.)
I managed to fix this. I am not sure exactly what the solution was, but effectively what I did was to remove all of the cocoapods, detach all of the extra projects that were being used to compile frameworks, and then completely clean the build folder (by holding Alt while going to Product > Clean.)
I then added each of the frameworks back and made sure that each of them would compile.
I checked the build output and near the bottom of each I was able to find the location in which the frameworks were being built.
I then went back to the parent app, and was able to change the framework search paths to include the folders that the frameworks were being built in.
I may have changed a couple of other paths, too, though I cannot remember completely.
I think that basically the issue was a combination of (1) a very dirty build path, (2) leftover files and bad configuration causing issues, (3) frameworks being built in the wrong location.
check your "Copy Bundle Resources",delete info.plist if it contained.
It's work for me in Xcode 6.4

OS X Framework Library not loaded: 'Image not found'

I am trying to create a basic OS X Framework, right now I just have a test framework created: TestMacFramework.framework and I'm trying to import it into a brand new OS X Application project.
I have built the .framework file and imported it into the new project, The framework appears to link okay, and I can reference the public header file I added to the framework build phases section.
However, when I try to run the container Application I get the following Error:
dyld: Library not loaded: /Library/Frameworks/TestMacFramework.framework/Versions/A/TestMacFramework
Referenced from: /Users/samharman/Library/Developer/Xcode/DerivedData/TestMacContainer-dzabuelobzfknafuhmgooqhqrgzl/Build/Products/Debug/TestMacContainer.app/Contents/MacOS/TestMacContainer
Reason: image not found
After a bit of googling I realised I needed to add a Copy Files section to my container application build phases, so I have done this and set it up like so...
However, I am still getting the runtime error. I'm obviously doing something wrong here, but the Apple developer library resource for this references Xcode 2, so isn't very helpful!
What have I missed?
UPDATE:
I can see in the build log that my TestMacFramework.framework is being copied into the .app contents/frameworks directory, but it isn't being installed to the Library/Frameworks directory on the HD
UPDATE 2:
The build links correctly if I manually copy the TestMacFramework.framework into the Library/Frameworks directory
[Xcode 11+]
The only thing to do is to add the framework to the General->Frameworks, Libraries And Embedded Content section in the General tab of your app target.
Make sure you select the 'Embed & Sign' option.
[Xcode v6 -> Xcode v10]
The only thing to do is to add the framework to the Embedded binaries section in the General tab of your app target.
So I managed to get it working, it's quite simple when you have the right instructions. What I was looking for was a 'private' framework which lives in the App bundle rather than being written to the system library folder.
Building The Framework
Add a target to create a Cocoa Framework
Within that targets 'Build Settings' configure the 'Installation Directory' to '#executable_path/../Frameworks'
Build library, and access the .framework from the archive or products directory
Including The Framework
Drag the created .framework file into the Xcode Project, be sure to tick 'Copy Files to Directory'
In the containing applications target, add a new 'Copy File Build Phase'
Set the 'Destination' to 'Frameworks'
Drag in the created .framework
It was quite simple for me, i just added my framework to my embedded binaries under app targets
The options above where not possible for me to include.
I solved it by specifying the Runpath Search Path
This is on the 'Build Settings' tab.
In the 'Linking' section.
Change 'Runpath Search Paths' into $(inherited) #executable_path/Frameworks
I ran into the same issue but the accepted solution did not work for me. Instead the solution was to modify the framework's install name.
The error in the original post is:
dyld: Library not loaded: /Library/Frameworks/TestMacFramework.framework/Versions/A/TestMacFramework
Referenced from: /Users/samharman/Library/Developer/Xcode/DerivedData/TestMacContainer-dzabuelobzfknafuhmgooqhqrgzl/Build/Products/Debug/TestMacContainer.app/Contents/MacOS/TestMacContainer
Reason: image not found
Note the first path after Library not loaded. The framework is being loaded from an absolute path. This path comes from the framework's install name (sometimes called rpath), which can be examined using:
otool -D MyFramework.framework/MyFramework
When a framework is embedded into an app this path should be relative and of this form: #rpath/MyFramework.framework/MyFramework. If your framework's install name is an absolute path it may not be loaded at runtime and an error similar to the one above will be produced.
The solution is to modify the install name:
install_name_tool -id "#rpath/MyFramework.framework/MyFramework" MyFramework.framework/MyFramework
With this change I no longer get the error
Deleting derived data saved it for me
None of these issues solved this for me. The problem in the end was pretty easy. It looks like its a pretty major Xcode bug which I have logged the problem and fix under Apple bug: 29820370. If you are struggling (as it seems like there are several pages of problems similar to this ) then it would be great if you can raise a bug on bug reporter: https://bugreport.apple.com/ and reference the bug I raised to gain visibility. I want to make Xcode back into the pleasure that it was before - and this is something I am sure Xcode should have fixed itself.
Here is the fix:
1. Open Keychain - go to Apple Worldwide Developer Cert.
2. Double Click on it
3. Change the permission level from "always trust" to use System Defaults
4. Save and close it
5. Restart Xcode, Clean and build your project and it should be gone.
Screenshot below of the correct settings:
Hope this helps!
When you drag a custom framework into a project under Xcode 10.1, it assumes that the framework is a system framework and puts the framework into "Link Binary With Libraries" section of "Build Phases" under your target.
System frameworks are already on the device so it is not copied over to the device and thus cannot execute at runtime so KABOOM (crash in __abort_with_payload, and disinforming error: "Reason: image not found"). This is because the framework code is not copied to the device...
In reality, to have Xcode both link the custom framework and ensure that it is copied along with your code to the iOS device (real or simulator) the custom framework needs to be moved to "Copy Bundle Resources". This ultimately packages the framework along with your code executable to be available on the device together.
To add a custom framework to a project and avoid the Apple crash:
Drag custom framework into your iOS project file list
Click ProjectName in Navigator -> TargetName -> "Build Phases" ->
Link Binary With Libraries disclosure triangle
Drag custom framework out and down to "Copy Bundle Resources" section below (Xcode now moves the framework reference, fixed in Xcode 10)
Run in simulator or device
The custom framework thus gets copied along with your code to your target device and is available at runtime.
[editorial: you would think Xcode would be smart enough to figure out the difference between one of it's system frameworks which need not be copied to the device and a custom framework that is, oh I don't know, in the project root directory hierarchy... 🙄]
Xcode 11 :
in Xcode 11 add framework into General->Frameworks, Libraries And Embedded Content
after adding make sure you select Embed & Sign option
There should be a 'Run Script' into 'Build Phases' with this: '/usr/local/bin/carthage copy-frameworks'
On the 'Input Files' of that 'Run Script', you should add the path to your libraries. Like this:
If you accidentally reset your keychain, this can occur due to missing Apple certificates in the keychain. I followed this to solve my problem.
I had the same issue and was able to fix by re-downloading the WWDR (Apple Worldwide Developer Relations Certification Authority).
Download from here: http://developer.apple.com/certificationauthority/AppleWWDRCA.cer
If you are using Xcode 11, ensure that you have the framework added in Frameworks, Libraries, and Embed Content under Target settings - General. Change Embed status from - 'Do not Embed' to 'Embed & Sign'
What solved it for me was changing abstract_target to target for the main target in my Podfile. I had previously set it to abstract_target and this caused the described error. Now it works like a charm
I faced this issue with Xcode 13 betas with the UniformTypeIdentifiers.framework. The app failed to run on iOS versions lower than 13.
The below approach fixed the issue :
Go to the target -> Build Phases -> Link Binary With Libraries -> Add the framework -> Add the status as "Optional"
The above worked perfectly for me! Hope this helps!
For Xcode 8, some stale products will be removed from derived data folder refer to this solution.
Apple: In macOS 10.12 and later, Xcode cleans up stale derived data, precompiled headers, and module caches. (23282174)
The Xcode build system supports stale file removal of some types of build artifacts that were produced in a previous build, but have since been removed from the project.
Base on the author's thought, I found this build log from my case.
Remove stale build products
/bin/rm -rf /Users/usename/Library/Developer/Xcode/DerivedData/myapp-esvvhwwwwngijeemhatmklwzoxnb/Build/Products/Debug-iphonesimulator/myapp.app/Frameworks/AliyunVodPlayerSDK.framework
/bin/rmdir /Users/usename/Library/Developer/Xcode/DerivedData/myapp-esvvhwwwwngijeemhatmklwzoxnb/Build/Products/Debug-iphonesimulator/myapp.app/Frameworks
After creating a new copy file phase and copy the target stale framework to Frameworks destination, the above removal log disappears after rebuilding.
Just clarify my situation and reason, hope it's helpful for someone.
For me this was the solution, after many hours of searching!!
For some reason, well into the development of a Swift 2.3 custom Framework, Xcode 8 had removed the DYLIB_INSTALL_NAME_BASE setting from the project.pbxproj file. A little walk into the Build Settings / Dynamic Library Install Name Base setting back to #rpath fixed it.
(from https://forums.developer.apple.com/thread/4687)
I found that this issue was related only to the code signing and certificates not the code itself. To verify this, create the basic single view app and try to run it without any changes to your device. If you see the same error type this shows your code is fine. Like me you will find that your certificates are invalid. Download all again and fix any expired ones. Then when you get the basic app to not report the error try your app again after exiting Xcode and perhaps restarting your mac for good measure. That finally put this nightmare to an end. Most likely this has nothing to do with your code especially if you get Build Successful message when you try to run it. FYI
Got the issue when trying Xcode 9 beta and going back to Xcode 8. A simple Clean on the target resolved the issue.
I had the same issue for a different reason.
I've created a new configuration to Debug and Release (under PROJECT -> Info tab -> Configuration).
And I had to change my pod frameworks shell script (Pods-"appName"-frameworks.sh , under Targets Support Files) to make it work.
[Xcode 9]
The only thing that worked for me:
Target > Build Phases > [CP] Embed Pods Frameworks
Uncheck "Show environment variables in build log" and "Run script only when installing"
I tried many fixes, but what worked for me was to delete a missing target listed in the build tab of the build scheme. You can get to it by opening the edit window of the current scheme.
Edit: My UI testing target was not working as well, and the solution I found was to delete it and generate it again.
open xcode -> general -> Embedded Binaries -> add QBImagepicker.framework and RSKImageCropper -> clean project
just add QBImagePicker.framework and RSKImageCropper.framework at embedded binaries worked for me
I think there is no fixed way to solve this problem since it might be caused by different reason. I also had this problem last week, I don't know when and exactly what cause this problem, only when I run it on simulator with Xcode or try to install it onto the phone, then it reports such kind of error, But when I run it with react-native run-ios with terminal, there is no problem.
I checked all the ways posted on the internet, like renew certificate, change settings in Xcode (all of ways mentions above), actually all of settings in Xcode were already set as it requested before, none of ways works for me. Until this morning when I delete the pods and reinstall, the error finally gonna after a week. If you are also using cocoapod and then error was just show up without any specific reason, maybe you can try my way.
Check my cocoapods version.
Update it if there is new version available.
Go to your project folder, delete your Podfile.lock , Pods file, project xcworkspace.
Run pod install
I experienced that problem only when running on real device (iPhone SE). On simulator project worked as expected.
I did try all fixes from this very thread and from here.
None of those worked for me.
For me problem was solved after restarting iPhone (sic!).
I did:
clean build folder,
clean derived data,
delete app from device,
reboot device
And it finally works. :)
If every other solution fails don't forget to try it out.
Xcode 11 :
Build Phases -> Embed Frameworks
This might happen with Pod Frameworks.
I was facing the same issue with AnswerBotProvidersSDK.framework and my mistake was, I set Run Script checked for Install builds only in targets build phases.
Incorrect settings:
Correct Settings:
For me for some reason xCode (12.5 up to this moment) decided that my Notification Service Extension Target should not have correct paths to frameworks. I suspect that this is happened after I've updated from xCode 12.1 to 12.5.
So I was getting the same error related to one of my internal frameworks. To fix this problem do the following:
go to Project's General Tab
Select your target (in my case it was Notification Service Extension Target)
Make sure that Framework and Libraries section contains your missing framework. I've left it Embed Without Signing in my NSE Target, but it is also was added with Embed & Sign to my primary app target
Keep your target selected and switch to Build Settings tab
There in a search bar enter LD_RUNPATH_SEARCH_PATHS (make sure that All possible settings will be displayed and not just Basic)
You will see Runpath Search Paths and it was empty for me.
Add 3 following values there:
$(inherited)
#executable_path/Frameworks
#executable_path/../../Frameworks
This is what helped me.

Error "Library not loaded" when launching app

I have created a Mac app which uses the RMSharedPreferences framework. When opening the app, it immediately crashes and I get the following error:
Dyld Error Message:
Library not loaded: #rpath/RMSharedPreferences.framework/Versions/A/RMSharedPreferences
Referenced from: /Users/USER/Desktop/MyApp.app/Contents/MacOS/MyApp
Reason: image not found
It seems that it can't find the framework. I have tried adding a copy files phase to the target which should copy the framework and when browsing the contents of the app in Finder, it seems that it is copied correctly.
Does anyone know what might cause this error?
EDIT: Setting the framework to optional does make the application launch without any errors but the application does not fully work. Any RMSharedPreferences related calls will be ignored.
Since you are bundling the framework with your app, you should set the framework's install location. You can set that in your framework target build setting "installation location". Use something like:
#executable_path
You could also use a separate folder for your frameworks, then you would use:
#executable_path/../Frameworks/
In case you can't rebuild the framework (which is not yours, but I am saying in general), you can modify a prebuilt framework installation path like this:
install_name_tool -id #executable_path/../Frameworks/<framework_name> <your_framework>
Here you can find a reference for this.
If you are going to bundle a framework inside another framework, you can use #loader_path instead of #executable_path.
#rpath is a more flexible keyword, and its use is recommended.
The better way to do this is to set the "Runpath Search Paths" build setting in Xcode.
This avoids the need for an additional build phase script to modify the framework.
For instance, in your situation, you could set "Runpath Search Paths" to
#executable_path/../Frameworks
or
#loader_path/../Frameworks
if you're trying to load the framework from within a framework.

How do I solve a "dyld: Library not loaded:" error in Xcode 4 unit tests?

I have an Xcode 4 project, a Cocoa application with Spotlight, Core Data and unit tests. The app uses a custom framework named TBPluginManager I wrote to load bundles. I originally wrote the framework in Xcode 3 but when I used it in Xcode 4 GDB kept complaining, so I recreated the framework in Xcode 4. This made GDB happy, until I tried to run the built-in unit-test and got:
[Switching to process 3840 thread 0x0]
dyld: Library not loaded: > Library/Frameworks/TBPluginManager.framework/Versions/A/TBPluginManager
Referenced from: /Users/elise/Library/Developer/Xcode/DerivedData/BookManager-cooglmktssmptpatjuetculukiqd/Build/Products/Release/BookManager.app/Contents/MacOS/BookManager
Reason: image not found
sharedlibrary apply-load-rules all
No memory available to program now: unsafe to call malloc
Now I can understand why the unit test cannot find the framework since it lives not at Library/Frameworks/TBPluginManager.framework but at /Library/Frameworks/TBPluginManager.framework. But how do I tell that to the unit-test bundle? I've tried setting the Framework, Header and Library Search path build setting, but to no avail.
BTW, I've gone back to GHUnit but I'd like to get this working as well.
FOLLOW-UP: Much as it bugs me that Grady Player got an account just to tell me that I'm an idiot, it just may be that he or she is right. My lovely, dependable framework is generating warnings and errors like they're going out of fashion and so I've turned the problem over to Apple Developer Technical Support. If anything interesting comes out of it, I'll post it here. Otherwise, I'll delete the question.
make sure that the framework installed at /Library/Frameworks/TBPluginManager.framework is valid and the same arch as you are trying to link it to. If you are in doubt recompile the framework again, put it in a custom location and set that custom location in your framework search path.

Do I have to do something to get OCunit tests to compile out of box with XCode 4?

I just installed XCode 4 today (using Apple mac app store), and I created a new Mac OS application, and tried to switch to test mode,and build the test skeleton code it generated for me. It failed here:
In mytests.h:
#import <SenTestingKit/SenTestingKit.h>
The error is:
file://..mytests.h: error: Lexical or Preprocessor Issue: 'SenTestingKit/SenTestingKit.h' file not found
Now, when I use locate from the terminal to find SenTestingKit.h, I notice it exists under the /Developer-old/Library/Frameworks folder (which is what XCode 4 installer renamed my /Developer folder to). There is no new /Developer/Library/Frameworks. And I can't seem to find SenTestingKit.framework on my disk, other than the developer-old one.
What's up? It seems SenTestingKit.framework is not shipped with XCode 4.
Update:
Furthermore, When I copy my old SenTestingKit framework from XCode 3 into /Developer/Library/Frameworks, it sort of builds, but it doesn't work the way I would expect. The dummy test is designed to just fail, but when I "run test", I just get the normal cocoa app document window opening, and no indication that my test has failed (as I intend it to do).
This is pretty bad. I can't get a Unit test to FAIL. That's not the usual situation for me, you understand.
You may find that the reason for this is because you've installed Xcode 4 into a directory such as /Xcode 4.x/ or similar. The space is causing the problem because the -I paths are "Xcode" and "4.x/Library/Frameworks".
To fix this, what you need to do is select your test target, and under its build settings go and find the Framework Search Path, and put quotes around the two arguments, so you have:
"$(SDKROOT)/Developer/Library/Frameworks" and "$(DEVELOPER_LIBRARY_DIR)/Frameworks"
Then you default tests will compile, link and fail.
You will maybe need to import the framework into your project. Otherwise, the header file won't be recognize.
If you can't see the framework you're looking for, you can adjust the framework look paths in your project's build settings.
When you're building unit tests in the same project as you main code, make sure that XCode 4 didn't automatically connect you mytests.m file into the "Compile Sources" section of your main code.
For example, if you have two targets in our project:
MyProject
MyProjectTests
Check the Build Phases for MyProject to see if XCode added mytests.m into the "Compile Sources" accordion. This will cause your builds to fail because SenTest isn't included in the main project.

Resources