3
votes

I am using Xcode 7.2 and swift 2. Deployment target is ios 9.0

The question is similar to many previous questions being asked, but my issue is not common or did not find any reference to any of them.

I have created a cocoa touch framework for iOS which has mixed code ( both swift and objC) and has some libraries included from Cocoapods. ( FMDB, ObjectMapper, HockeySDK )

I have another target in the same project which has a sample application where I include my framework. Now, when I try to run it on my device it throws me this runtime error just after installation,

dyld: Library not loaded: @rpath/FMDB.framework/FMDB Referenced from: /private/var/mobile/Containers/Bundle/Application/0A768355-B7F9-4B1C-AE0D-D2ED57A7E1D6/SwiftExample.app/Frameworks/MyFramework.framework/MyFramework Reason: image not found.

I have tried all these actions:

  • Restarting Xcode, iPhone, computer
  • Clean & Build, project
  • Runpath Search Paths is '$(inherited) @executable_path/Frameworks'
  • Embedded Content Contains Swift Code is 'Yes'

My PodFile has the following desc :

source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!

platform :ios, '9.0'

xcodeproj 'MyFramework'

target :'MyFramework' do
    pod 'HockeySDK', '~> 3.8.4'
    pod 'FMDB'
    pod 'OpenSSL-iOS', '~> 1.0'
    pod 'GoogleAnalytics'
    pod 'ObjectMapper', '~> 1.0'
end

Is there something I am missing or doing wrong ?

1
Is the framework in the Frameworks folder of the app bundle? - trojanfoe
@trojanfoe Yes. The framework is present in the Frameworks folder. But the Frameworks folder of the .framework does not have the libraries installed through pods. - Shane D
Sometimes it is enough just to rebuld whole workspace. Click Product -> Clean, and then rebuild your project. - Alexander Perechnev
@AlexanderPerechnev That is the first thing that I fall back too when something does not work in Xcode. But it does not work - Shane D
did anyone ever figure this out? - JAManfredi

1 Answers

1
votes

I had the same problem this morning. I solved it by (1) compiling the FMDB framework in statically-linked, not dynamically-linked, mode; and (2) adding the link to "libsqlite3.dylib" library in the frameworks section of my application program.

To do (1), in XCode, open the FMDB framework project, and in the Project editor, under the framework's Build Settings tab, in the Linking subsection, change the Mach-O Type to Static Library, and re-build the framework.

To do (2), again in XCode, open your application project, and in the Project editor, under the application's General tab, in the "Linked Frameworks and Libraries" subsection, add "libsqlite3.dylib".