I'm in this situation... I'm starting a new SDK that I want to release through CocoaPods, the SDK itself needs some Pods (AFNetworking) I wonder which is the best way to setup the project, given that I need to try the SDK in an example project while writing it.
My first attempt started with the pod lib create command. I followed all the instruction and I ended up with a complete workspace, wonderful! now how can I include AFNetworking? I have to add it as dependency in the mySDK.podspec file using: s.dependency 'AFNetworking', '~> 3.0' so that users of my SDK can also have it included into the library, great. But how can I have it included in my current project to use it during development?
I see that under the "Example" folder created by cocoapods I have a Podfile but it contains only the example and test target... I've tried to include the SDK target here but it doesn't seem to work that way.
source 'https://github.com/CocoaPods/Specs.git' use_frameworks! target 'MYSDK_Example', :exclusive => true do pod 'MYSDK', :path => '../' end target 'MYSDK_Tests', :exclusive => true do pod 'MYSDK', :path => '../' pod 'Specta' pod 'Expecta' end I've tried to include the next configuration and launch again pod install...
target 'MYSDK', :exclusive => true do pod 'AFNetworking', '~> 3.0' end I get a generic terrible error and anyway it doesn't sound really good as solution.
This is the structure created by the lib create command, where I'm supposed to add a new Podfile to include the library that I need to develop the library?
MyLib ├── _Pods.xcproject ├── Example │ ├── MyLib │ ├── MyLib.xcodeproj │ ├── MyLib.xcworkspace │ ├── Podfile <----- the Podfile previously described │ ├── Podfile.lock │ ├── Pods │ └── Tests ├── MyLib.podspec ├── Pod │ ├── Assets │ └── Classes │ └── TheFilesForMyLib.[swift/m] <---- My Lib code 2 Answers
Answers 1
How I did it was to have a Podfile for my library as well. In this Podfile I have all the dependency.
Here my libraries Podfile:
source 'https://github.com/CocoaPods/Specs.git' platform :ios, '7.0' workspace 'SAFoundation.xcworkspace' xcodeproj 'SAFoundation.xcodeproj' pod 'AFNetworking' Answers 2
I made a project using pods, and my Podfile looked like this.
# Uncomment this line to define a global platform for your project # platform :ios, '8.0' # Uncomment this line if you're using Swift use_frameworks! target 'golden-boy-iOS' do end target 'golden-boy-iOSTests' do end target 'golden-boy-iOSUITests' do end pod 'AFNetworking', '~> 2.6' pod 'SVProgressHUD' pod 'FBSDKCoreKit' pod 'FBSDKLoginKit' pod 'FBSDKShareKit' pod 'Fabric' pod 'Crashlytics' pod 'REFrostedViewController', '~> 2.4' pod 'IBActionSheet' pod 'ICViewPager' pod 'TwitterKit' pod 'SDWebImage', '~>3.7' after edit your Podfile you have to run pod install in your terminal. Also after install pods you have to open your project through myProjec.xcworkspace instead of myProject.xcodeproject.
For more info check out this doc. guides.cocoapods.org
hope it works.
0 comments:
Post a Comment