1

I have a problem integrating AFNetworking in my Swift Dynamic Library:

Here is what I have done:

  1. Create Xcode Project: ( Cocoa Touch Framework )
  2. Initialize Pod: ( pod init ) via Terminal
  3. Modify Podfile: Here is the content of the podfile, and execute (pod install)

    target 'MyFramework' do 
    use_frameworks!
    pod 'AFNetworking' => '~>2.0' 
    end
    
  4. Create sample swift file "MyLibrary" with 1 method and property.

  5. Import AFNetworking (import AFNetworking)
  6. Build, and the sample "MyFramework.framework" has been created.
  7. Create a new project file ( single application )
  8. Drag "MyFramework.framework" to the new created project
  9. Import MyLibrary: ( import MyLibrary ) in a viewcontroller class
  10. Build.

Error:

ld: framework not found AFNetworking for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

Allan Macatingrao
  • 2,071
  • 1
  • 20
  • 28
  • Have you consider using Alamofire (swift library equivalent to AFNetworking)? If you have real reasons of using AFNetworking then I think you are missing the bridging header part as described here : https://developer.apple.com/library/prerelease/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html – Zell B. May 11 '15 at 09:42
  • Bridging file is not supported in creating Swift Dynamic Framework: http://stackoverflow.com/questions/24875745/xcode-6-beta-4-using-bridging-headers-with-framework-targets-is-unsupported Using Alamofire will cause me to do lot of modification in my source file. – Allan Macatingrao May 11 '15 at 09:45

1 Answers1

0

You dragged the framework you've built manually into the app project. This way Xcode won't know that it also needs AFNetworking as an additional dependency.

You have to use CocoaPods instead to add your framework to the app. This way you can declare AFNetworking as a dependency of your framework in it's .podspec file. CocoaPods will then link AFNetworking to the app.

See

fluidsonic
  • 4,655
  • 2
  • 24
  • 34