ios - Using 3rd party framework (Alamofire) in my sub-project (CocoaTouch framework) -
i using xcode 8 + swift 3.
i created fresh ios project named "myapp".
then, create cocoa touch framework project, named "mysubproject". (the idea have myapp project accessing mysubproject code.)
i added mysubproject myapp project, linked mysubproject framework.
in xcode project navigator looks this:
myapp > mysubproject.xcodeproj
everything works fine. code in myapp
can access code in mysubproject
.
now, need add alamofire mysubproject
. followed instruction in alamofire offical website manually add alamofire mysubproject
, project structure looks this:
myapp > mysubproject.xcodeproj > alamofire.xcodeproj
so, mysubproject
has dependency on alamofire framework. looke under mysubproject
target--> general :
after that, can access alamofire in mysubproject
code, no compile error. myapp built successfully. however, when run app in emulator, got run-time error:
dyld: library not loaded: @rpath/libswiftswiftononesupport.dylib referenced from: /users/myname/library/developer/xcode/deriveddata/myapp-hezjlyvzxnavccenabxdepgftbrg/build/products/debug-iphonesimulator
/alamofire.framework/alamofire reason: image not found
why? & how solve that?
if want use alamofire, there's better way install it. can use cocoapods intall 3rd party frameworks. so, must follow these steps:
1.- please install cocoapods gems sudo gem install cocoapods
2.- go folder terminal , type pod init
, type vim podfile
3.- can see file can add 3rd party frameworks must add alamofire target , write vim :wq
. example type this:
# uncomment next line define global platform project # platform :ios, '9.0' target 'yourtarget' use_frameworks! pod 'alamofire', '~>4.0'
4.- must type pod install
terminal , that's it. open xcworkspace
generated cocoapods , type cmd + b
xcode. after can import alamofire classes.
Comments
Post a Comment