SDK image not found when running OSX UI Tests with Cocoapods - macos

I am trying to add my first automated UI tests to my application and am running into quite a bit of difficultly.
The app will build in its current state and the main application itself runs just fine. However, when I try to run my tests I get the following error:
2016-08-02 19:39:33.340 XCTRunner[17590:966857] Running tests...
2016-08-02 19:39:33.407 XCTRunner[17590:966857] The bundle “MYAPPUITests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-08-02 19:39:33.407 XCTRunner[17590:966857] (dlopen_preflight(/Users/username/Library/Developer/Xcode/DerivedData/MYAPP-bdpxtxtxmsobtreqnojvykobjlts/Build/Products/Debug/MYAPPUITests-Runner.app/Contents/PlugIns/MYAPPUITests.xctest/Contents/MacOS/MYAPPUITests): Library not loaded: #rpath/HockeySDK.framework/Versions/A/HockeySDK
Referenced from: /Users/username/Library/Developer/Xcode/DerivedData/MYAPP-bdpxtxtxmsobtreqnojvykobjlts/Build/Products/Debug/MYAPPUITests-Runner.app/Contents/PlugIns/MYAPPUITests.xctest/Contents/MacOS/MYAPPUITests
Reason: image not found)
I've seen that there are a few related questions on SO but none of them see to help me out.
Originally, I was implementing my tests in Swift on top of an Objective C application and thought that might be the problem. However, I discovered after making an Objective-C based test target that I am running into exactly the same issue in Objective C.
Thanks for any help.
EDIT
Some additional information: I have tried this using both Cocoapods 0.39.0 as well as the latest non-beta 1.x release. Both resulted in the same error.
My podfile is listed below (for 0.39.0)
platform :osx, '10.9'
link_with 'MYAPP', 'MYAPP MAS', 'MYAPPUITests'
pod 'AFNetworking', '~> 2.5.0'
pod 'ISO8601DateFormatter'
pod 'CDEvents', :git => 'https://github.com/rastersize/CDEvents'
pod 'MASShortcut', '1.3.1'
pod 'libPusher', '1.6'
pod 'NPReachability', :git => 'https://github.com/Abizern/NPReachability.git', :commit => 'e57753d'
pod 'CocoaLumberjack'
pod 'SocketRocket', :git => 'https://github.com/marianoabdala/SocketRocket.git'
pod 'HockeySDK-Mac'
pod 'INAppStoreWindow', '~> 1.4'

I was able to fix this after spending 2-3 days on this by adding an obscure step to my Build Phases.
I created a Copy Files build step after the Link Binary With Libraries step and before the Embed Pods Frameworks step.
I copied the offending framework ("HockeySDK") into the Products Directory. This solved the issue!
Ultimately this may be related to my app being a StatusBar App, not a regular app, as the solution which finally worked for me was related to a CommandLine application running into the same bug.
Link to Github bug page with the solution that worked for me

Related

Library not loaded: #rpath/hermes.framework/hermes

I have enabled Hermes in my react-native(v0.64) Application. Everytime I run app I get following stack trace.
dyld: dyld cache load error: shared cache file open() failed
dyld: Library not loaded: #rpath/hermes.framework/hermes
Referenced from: /Users/sharktank/Library/Developer/CoreSimulator/Devices/A32F4931-51A8-4D22-AEFB-625F834CE221/data/Containers/Bundle/Application/71773888-08D5-4B82-9545-07F6B1538864/COSPM-DEV.app/COSPM-DEV
Reason: image not found
dyld: launch, loading dependent libraries
DYLD_SHARED_CACHE_DIR=/Users/sharktank/Library/Developer/CoreSimulator/Caches/dyld/20E232/com.apple.CoreSimulator.SimRuntime.iOS-14-4.18D46
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/sharktank/Library/Developer/Xcode/DerivedData/COSPM-atbujvbobdbyehckyoqrdgmqiubm/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/CoreSim
(lldb)
I have enabled hermes in Podfile and after pod install pod is available in Pods folder.
Project is in monorepo architecture along side another projects. Another app enabled with Hermes in same mono-repo package is working fine without crash.
Podfile:
require_relative '../../../node_modules/react-native/scripts/react_native_pods'
require_relative '../../../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '10.0'
source 'https://github.com/CocoaPods/Specs.git'
target 'COSPM' do
config = use_native_modules!
use_react_native!(
:path => config[:reactNativePath],
# to enable hermes on iOS, change `false` to `true` and then install pods
:hermes_enabled => true
)
pod 'RNVectorIcons', :path => '../../../node_modules/react-native-vector-icons'
# Firebase
pod 'Firebase'
pod 'Firebase/Core'
pod 'Firebase/Messaging'
pod 'CodePush', :path => '../../../node_modules/react-native-code-push'
target 'COSPMTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable the next line.
use_flipper!()
post_install do |installer|
react_native_post_install(installer)
end
end
I am using Xcode 12.4.
Solutions I tried which did not work:
Clean Pods and npm packages, clean previous build and rebuild
Clear watchman and metro bundler cache and rebuild
I was facing the same problem on react native 0.70
Select App Target then follow the steps
goto Build Phases
Inside Link Binary With Libraries section
Click on Add Items and search for hermes.xcframework and add it
Rebuild application
This resolved my issue in RN 0.70. In Xcode, Targets -> Build Phases -> Link Binary With Libraries
The other answers suggest disabling Hermes or manually adding it as a linked library, but this should not be necessary.
The latest version should install the Hermes framework automatically.
The problem seems to be related to using the incorrect version of CocoaPods and the pods repo.
To bring everything up to date, do the following:
Make sure your Gemfile is up to date for your version of React Native. You can use the Upgrade Helper to see if it needs changed.
Upgrade Ruby to the version listed in your project's Gemfile. (Instructions)
Upgrade CocoaPods to the latest version: bundle install
Update the CocoaPods repo: bundle exec pod repo update
Delete Podfile.lock
Reinstall pods cd ./ios && bundle exec pod install
If you're still getting errors, double check that the correct versions are actually being used (are in your PATH).
I also made a blog post about this error if you would like more details: https://traviswimer.com/blog/cocoapods-could-not-find-compatible-versions-for-pod-hermes-engine/
Update (Jan 17, 2023)
I updated this answer to use the Bundler tool to manage Ruby and Cocoapods versions. The bundle command is now the recommended way to use Cocoapods in React Native projects. It runs commands based on the versions listed in your project's Gemfile (which is updated with each version of React Native). If for some reason you are unable to use bundle, you can manually upgrade Cocoapods using: gem install cocoapods
Then run the other commands without bundle exec. (e.g. pod repo update and pod install
Try following:
Change hermes_enabled value from true to false in Podfile
Reinstall npm/yarn dependencies by (yarn install)
Reinstall pods (cd ios && pods install)
Run app (react-native run-ios)
I tried this a couple of times changing hermes_enabled from true to false and back, and once it starts working.
The right answer depends on your react-native version
This error means that your react-native project is set to use hermes a lightweight Javascript engine created by facebook specially for react-native. It is supposed to make the app faster and lighter.
If you want to use hermes, open your Podfile (ios/Podfile), look for hermes_enabled and set its value to true. The line should look like the following
:hermes_enabled => true
Besides that, you might needs to follow few more steps from the official page.
If your Podfile does not have any hermes_enabled property, please make sure your react-native project is using at least 0.60.
For react-native > 0.60 and < 0.70
follow these steps from the official page.
For react-native >= 0.70
Hermes is the default engine for this version and beyond. Maybe you just need to reinstall your node packages, clean your Podfile.lock and reinstall your pods by running pod install from inside your ios folder.

Trying to Rebuild a Legacy IOS App, Getting Error in Facebook-IOS-SDK Cocoapod

I've been asked to rebuild an existing IOS app that uses Facebook-IOS-SDK. The app is at least 5 years old so I expected things to be deprecated. I have some limited experience with XCode and IOS but I'm far from an expert. I've never used cocapods until today. I installed cocoapods and ran pod init. Facebook-IOS-SDK ver 3.24.4 loaded with no errors (other pods too, including Bolt, with no errors).
I've read the migration notes on the FB dev page regarding the versions and it's implied that I should be able to use 3.24. When I do a clean build I get the error:
(FBRequest *)requestForUpdateOpenGraphObject(id<FBOpenGraphObject>)object
{
return [FBRequest requestForUpdateOpenGraphObjectWithId:object[#"id"] graphObject:object];
}
Expected method to read dictionary element not found on object of type 'id<FBOpenGraphObject>'
This error is in FBRequest.m, the cocoapod code, not in my clients code. This code is marked read only. If this is the correct pod version, and I can't change it then is there some other dependency in the (large) project that needs to be updated?
Podfile:
# Uncomment this line to define a global platform for your project
platform :ios, "9.0"
target "tbd" do
pod 'IQKeyboardManager'
pod 'UICKeyChainStore'
pod 'CocoaLumberjack', '~> 2.0.0-beta'
pod 'SDURLCache'
pod 'HockeySDK'
pod 'Facebook-iOS-SDK', '~> 3.23'
pod 'GoogleAnalytics-iOS-SDK'
pod 'UIActionSheet-Blocks', '~> 1.0'
end
target "tbdTests" do
end
The only, nasty, solution I found is to change the code inside FBRequest.m manually.
Change line 370 from:
return [FBRequest requestForUpdateOpenGraphObjectWithId:object[#"id"] graphObject:object];
to
return [FBRequest requestForUpdateOpenGraphObjectWithId:object.objectID graphObject:object];
this should make you project runs again.
Again, this is not a nice solution, but it works :)
Emilio
if you don't have the need to use Facebook-IOS-SDK ver 3.24.4 you can simply use the latest version 4.36.0.
have a look at your Podfile and see if there is any reference to Facebook-IOS-SDK, if there is something like:
pod 'Facebook-IOS-SDK', '~> 3.0'
you can replace it with:
pod 'Facebook-IOS-SDK', '~> 4.0'
otherwise post your Podfile and we can have a look.
Cheers

IBDesignables, no suitable image found, required code signature missing

I recently made some changes to Assets.xcassets and this caused absolute chaos for XCode. I ended up with multiple errors of this kind: Failed to render and update auto layout status for *MyViewController* (6jf-cd-DYU) dlopen (AFramework.framework, 1): no suitable image found. Did find: Aframework.framwork: required code signature missing for 'Aframework.framework' in both .storyboard and .xib files.
Aframework is a placeholder for multiple Pod frameworks I have as dependencies. These worked fine before I modified xcassets.
I tried everything I could find related to this but I've gotten nowhere: Cleaned Derived Data, ran clean/build, removed all XCode cache folders, reinstalled XCode entirely, Refresh all views etc. It compiles and runs fine, everything works in the app (and no images or resources are missing), but all my Storyboards are blank (all white), which makes it pretty hard to work.
I also tried pod deintegrate, removed the xcworkspace-file and reinstalling pods (since the error points to a Pod framework). I also revoked and re-issued all my certificates through XCode since it points to code signing as a problem.
EDIT: I Completely reinstalled OSX and cloned the repo from Git from a working configuration. No change. This must be something other than the xcassets-theory, because even if I check out commits from weeks ago (where I know for sure this wasn't a problem) I still get the error. Maybe something was updated by Apple between now and the last time it worked. I've given up and moved on for now. I'll just click through the views in the explorer on the left side instead of inside the storyboard. Hopefully someone somewhere figures this out at some point.
This issue looks like Cocoapods bug and caused by CODE_SIGNING_ALLOWED and CODE_SIGNING_REQUIRED keys in settings of Pods.
Adding this code in the end of pod file will fix an issue (don't forget do then pod install):
# Workaround for Cocoapods v.1.5 issue #7606
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end
It turns out this was related to cocoapods. 1.5 has issues with XCode 9.3 it seems. I downgraded to cocoapods 1.4 and the issue went away. Please see this thread on GitHub.
Edit: This issue has been fixed. The latest version of CocoaPods no longer suffers from this problem, so all you have to do is update.
Just adding a complete version of Igor's answer
Please don't downgrade cocoapods. Instead modify pod files as bellow.
#Replace 9.0 with your project ios version
platform :ios, '9.0'
target 'YourProject' do
frameworks
use_frameworks!
pod 'Alamofire', '~> 4.7'
pod 'AlamofireObjectMapper', '~> 5.0'
pod 'SDWebImage', '~> 4.0'
end
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
config.build_settings.delete('CODE_SIGNING_ALLOWED')
config.build_settings.delete('CODE_SIGNING_REQUIRED')
end
end

Migrating to CocoaPods 1.0.1

I am trying to migrate our existing CocoaPod configuration from 0.39.0 to 1.0.1.
Our existing Podfile looks like:
platform :ios, '9.0'
use_frameworks!
target 'Tools' do
pod 'zipzap', '~> 8.0.4'
pod 'Argo', '~> 2.2.0'
pod 'Curry', :git => 'https://github.com/thoughtbot/Curry.git', :commit => 'eeb459fac309833288e61e134a4e8fad649e99b0'
end
target 'ToolsTests' do
end
This compiled and the tests ran just fine previously. After following the migration guide. I restructured the Podfile like so:
platform :ios, '9.0'
target 'Tools' do
use_frameworks!
pod 'zipzap', '~> 8.0.4'
pod 'Argo', '~> 2.2.0'
pod 'Curry', :git => 'https://github.com/thoughtbot/Curry.git', :commit => 'eeb459fac309833288e61e134a4e8fad649e99b0'
target 'ToolsTests' do
inherit! :search_paths
end
end
This compiles and links just fine. Unfortunately when the tests run they crash with:
2016-06-07 12:04:06.265 xctest[56474:789900] The bundle “ToolsTests” couldn’t be loaded because it is damaged or missing necessary resources. Try reinstalling the bundle.
2016-06-07 12:04:06.299 xctest[56474:789900] (dlopen_preflight($HOME/Library/Developer/Xcode/DerivedData/Tools-dbmncsubtoarlhhcrpchrswefprz/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/ToolsTests.xctest/ToolsTests): Library not loaded: #rpath/Argo.framework/Argo
Referenced from: $HOME/Library/Developer/Xcode/DerivedData/Tools-dbmncsubtoarlhhcrpchrswefprz/Build/Intermediates/CodeCoverage/Products/Debug-iphonesimulator/ToolsTests.xctest/ToolsTests
Reason: image not found)
Program ended with exit code: 82
In the migration guide it says:
A large fraction of the bug reports we receive is due to ambiguity in the Podfile. It gave a lot of freedom to create all kinds of CocoaPods setups that would work by luck of implementation details, or work but are significantly more complex than they needed to be.
Is this one of those cases that used to "work by luck of implementation details"? If not what is the correct Podfile syntax?
I should note if I duplicate the pod defs in the ToolsTests everything works just fine. Though this feels wrong.
Similar question: Cocoapods testing linker error
Seems to be a common problem people are facing when upgrading. Your new Podfile looks right to me.
If you haven't already, I would try:
cleaning the build folder (in Xcode -> Option+Shift+Command+K)
clearing the derived data folder (rm -rf ~/Library/Developer/Xcode/DerivedData)
clearing your CocoaPods cache (rm -rf ~/Library/Caches/CocoaPods)
and run pod install again
EDIT:
The question I mentioned above has an answer now: https://stackoverflow.com/a/37705768/3067051

GCDWebServer fails to comile when CocoaLumberjak is included in project

When using cocoapods, with those 2 libs:
pod "GCDWebServer", "3.3.2"
pod 'CocoaLumberjack', '2.2.0'
Project fails to compile, as GCDW does not link to LumberJack (even optionally).
Adding Lumberjack to "Linked Grameworks and Libraries" as optional, for GCDWS pod fixes the issue, but it is only a workaround, as each
pod install resets the state, making it pain in the a$$ to work with, and impossible to have it build by CI env.
Any ideas of how to solve that?
BTW - GCDWebServer guys, why you have dissabled issues on GitHUb!?
This was fixed by https://github.com/swisspol/GCDWebServer/pull/256. Use this in your podspec:
pod 'GCDWebServer/CocoaLumberjack'

Resources