Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a project that includes Pods and will be released on CocoaPods

Tags:

ios

cocoapods

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
like image 628
MatterGoal Avatar asked Oct 31 '22 07:10

MatterGoal


1 Answers

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'
like image 179
rckoenes Avatar answered Nov 15 '22 07:11

rckoenes