3

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 ?

Shane D
  • 834
  • 9
  • 23
  • Is the framework in the `Frameworks` folder of the app bundle? – trojanfoe Dec 21 '15 at 11:05
  • @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 Dec 21 '15 at 11:28
  • Sometimes it is enough just to rebuld whole workspace. Click Product -> Clean, and then rebuild your project. – Alexander Perechnev Dec 21 '15 at 11:34
  • @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 Dec 21 '15 at 11:36
  • did anyone ever figure this out? – JAManfredi Mar 04 '16 at 22:31
  • @JAManfredi Was not able to figure out. Resorted back to using static libraries. Solution that I found was, if you are using any other frameworks into your framework, and then using your framework in an application, requirement is, you also need to link those 3rd party/other frameworks into your application as well. Refer this link's solution : [dyld-library-not-loaded-for-a-framework-within-a-framework](http://stackoverflow.com/questions/28740268/dyld-library-not-loaded-for-a-framework-within-a-framework) At present, there does not seem any solid solution to these. – Shane D Mar 05 '16 at 07:28

1 Answers1

1

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".

arjuna
  • 11
  • 1