Search code examples
xcode7cocoapodspspdfkit

3rd party Framework Library not loaded: 'Image not found'


I am upgrading a framework to latest version. Earlier integration (>2 years old) had framework directly copied in the project; now getting cocoapod (0.39.0) to get framework integrated with project using xcode (7.2.1) and objective-c project.

Upon run, it generates following error:

dyld: Library not loaded: @rpath/name.framework/name
Referenced from:

/Users/xyz_xyz/Library/Developer/CoreSimulator/Devices/xxxxxxx/data/Containers/Bundle/Application/xxxxxxx/appname.app/appname
Reason: image not found

"Pod" xcode-project has correct reference and framework is present in corresponding folder

Found that nameFramework isn't linked (added) in any of the build phases. I am new to using cocoapods and not sure what changes would be necessary in Xcode build settings to make transition from directly-embedded framework to cocoapods based integration.

  • how to get past "dyld: Library not loaded" error?
  • What phase should I use to reference name.Framework during build as it's not getting generated?
  • How to copy bundle resources from Pod to project? Dragging-n-drop Pods/name/Resources/name.bundle prompts "copy item if needed" dialog. <- I don't think I need to do this when using cocoapods.

[update] Integration using cocoapods works fine when a sample or new project is used. It's something in the current project settings that's causing the issue.

Podfile:

platform :ios, '8.0'

# use_framework for swift based pod integration. requires cocoapod 0.39.0
#use_frameworks!

pod 'GTMOAuth2'
pod 'Typhoon'

pod 'Alamofire'

# Issue with name
pod 'name', podspec:'https://customers.pspdfkit.com/cocoapods/.../latest.podspec'

target :ABC do
        pod '...', '~>1'
end

target :XYZ do
        pod '...', :path => 'submodules/...'
end

[Update] - Upgraded to CocoaPods 1.0.1 & modified the Podfile to uncomment use_frameworks!, and make other changes that are required for 0.39.0 to 1.0.1 migration. Here is the updated Podfile.

platform :ios, '8.0'

# use_framework is required for dynamic links (swift) based pod integration.
use_frameworks!

target 'XYZ' do
    pod 'GTMOAuth2'

    pod 'Alamofire'

    pod 'name', podspec:'https://customers.name.com/cocoapods/.../latest.podspec'

    target :XYZ-A do
            pod 'XYZ-iOS-SDK', :path => 'submodules/xyz-ios-sdk'
    end
end

Fixed errors such as following by adding $(inherited) flag (where applicable)

  • [!] The XYZ-v2 [Release] target overrides the OTHER_LDFLAGS build setting defined in ...

Progress after above changes, Pods/Target Supported Files/XYZ-v2/ has Pods-XYZ-v2-frameworks.sh and resources.sh; earlier frameworks.sh was missing. Following is partial content of the framworks.sh, and it does contain copy instructions.

if [[ "$CONFIGURATION" == "Debug" ]]; then
  install_framework "$BUILT_PRODUCTS_DIR/GTMOAuth2/GTMOAuth2.framework"
  install_framework "$BUILT_PRODUCTS_DIR/GTMSessionFetcher/GTMSessionFetcher.framework"
  install_framework "$BUILT_PRODUCTS_DIR/GoogleAPIClient/GoogleAPIClient.framework"
  install_framework "$BUILT_PRODUCTS_DIR/Mantle/Mantle.framework"
  install_framework "${PODS_ROOT}/PSPDFKit/PSPDFKit.framework"
  install_framework "$BUILT_PRODUCTS_DIR/SSKeychain/SSKeychain.framework"
fi

// and for "Release" & "Distribution" as well..

Now I am trying to resolve compile errors upon build, which are related to static vs dynamic library includes.

  • /path../Pods/SSKeychain/Sources/SSKeychain.h:65:1: Duplicate interface definition for class ‘SSKeychain'

[Updated] Posted a new question: CocoaPods 1.0.1 Redefinition of 'XYZ', Redefinition of enumerator 'ABC', Duplicate interface definition for 'MNO'

Related:


Solution

  • Try using use_frameworks! (it's currently commented out). PSPDFKit is a dynamic framework, so you need to enable this option.

    Also try it with the newest Xcode and CocoaPods >= 1.0.0. Older versions might not work correctly.

    You can find more information about PSPDFKit integration via CocoaPods here: https://pspdfkit.com/guides/ios/current/getting-started/using-cocoapods

    If all of this doesn't help you can reach the PSPDFKit developers directly at https://pspdfkit.com/support/request