grabury
grabury

Reputation: 5599

How to set up a private cocoapod to share our SDK privately

I am trying to share a private SDK using a spec repo and cocoapods that we can use on all our projects.

I created a dummy/test SDK (DummySDK) by creating a new Cocoatouch static library Xcode project. There is no code in the project yet. I didn't add a pod file or any other code.

I added the project to bitbucket (https://bitbucket.org/foo/dummysdk). The project file is located at https://bitbucket.org/foo/dummysdk/DummySDK.xcodeproj and the .h file is located at https://bitbucket.org/grantspilsbury/dummysdk/dummysdk/dummysdk.h

I then added a license file and pushed it to bit bucket (https://bitbucket.org/foo/dummysdk/license.txt), as well as the tag 1.0 for the version.

I then added the following spec file to bitbucket (as a ruby file) at https://bitbucket.org/foo/podspecs/PodSpec/1.0/PodSpec.podspec

Pod::Spec.new do |s|
  s.name         = 'PodSpec'
  s.version      = '1.0'
  s.summary      = 'Lightweight ad mediation for iOS'
  s.author = {
    'Grant' => '[email protected]'
  }
  s.source = {
    :git => 'https://[email protected]/foo/testsdk.git',
    :tag => '1.0'
  }
  s.source_files = 'Source/*.{h,m}'
  s.homepage     = "http://www.testsdk.com"
  s.license      = "MIT"
  s.license      = { :type => "MIT", :file => "license.txt" }
  s.requires_arc = true
end

I then ran the command > ~/Source/PodSpecs/PodSpec/1.0$ pod repo add PodSpecs https://bitbucket.org/foo/podspecs (from where the spec file is located)

I then ran >~/.cocoapods/repos/PodSpecs$ pod repo lint . (from the root folder of the spec file

I got the output message:

Linting spec repo `PodSpecs`
.
Analyzed 1 podspecs files.
All the specs passed validation.

I then removed and added the spec file again because I added the license file earlier

pod repo remove PodSpecs

and then ran > ~/Source/PodSpecs/PodSpec/1.0$ pod repo add PodSpecs https://bitbucket.org/foo/podspecs

I then tried to push the pod spec file by running:

>~/Source/PodSpecs/PodSpec/1.0$ pod repo push PodSpecs PodSpec.podspec --verbose

and I got the following message:

Validating spec
[!] The `PodSpec.podspec` specification does not validate.

/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command/repo/push.rb:91:in `rescue in block in validate_podspec_files'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command/repo/push.rb:88:in `block in validate_podspec_files'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command/repo/push.rb:85:in `each'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command/repo/push.rb:85:in `validate_podspec_files'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command/repo/push.rb:42:in `run'
/Library/Ruby/Gems/2.0.0/gems/claide-0.6.1/lib/claide/command.rb:281:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command.rb:48:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/bin/pod:33:in `<top (required)>'
/usr/bin/pod:23:in `load'
/usr/bin/pod:23:in `<main>'

I also tried >~/Source/PodSpecs/PodSpec/1.0$ pod repo push PodSpecs PodSpec.podspec --allow-warnings

and got the message:

Validating spec
[!] The `PodSpec.podspec` specification does not validate.

That's as far as I got. I also need to know how to include the sdk into other projects, I assume using the podfile?

I also tried changing the pod spec file name to DummySDK and using that in the pod spec file:

Pod::Spec.new do |s|
      s.name         = 'DummySDK'
      s.version      = '1.0'
      s.summary      = 'Lightweight ad mediation for iOS'
      s.author = {
        'Grant' => '[email protected]'
      }
      s.source = {
        :git => 'https://[email protected]/foo/testsdk.git',
        :tag => '1.0'
      }
      s.source_files = 'Source/*.{h,m}'
      s.homepage     = "http://www.testsdk.com"
      s.license      = "MIT"
      s.license      = { :type => "MIT", :file => "license.txt" }
      s.requires_arc = true
    end

But get the error:

~/.cocoapods/repos/PodSpecs$ pod spec lint

 -> DummySDK (1.0)
    - ERROR | [OSX] [xcodebuild]  2014-09-25 11:06:37.481 xcodebuild[6872:2403] error: InputFile    /Applications/Xcode 2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/SDKSettings.plist 0 1377395452 1100 33188... malformed line 7; 'InputFile' should have exactly five arguments
    - ERROR | The `source_files` pattern did not match any file.
    - ERROR | [iOS] [xcodebuild]  2014-09-25 11:06:40.900 xcodebuild[6918:3d07] error: InputFile    /Applications/Xcode 2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/SDKSettings.plist 0 1407358670 911 33188... malformed line 7; 'InputFile' should have exactly five arguments
    - ERROR | [iOS] [xcodebuild]  2014-09-25 11:06:40.902 xcodebuild[6918:3d07] error: InputFile    /Applications/Xcode 2.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS8.0.sdk/SDKSettings.plist 0 1407358670 911 33188... malformed line 7; 'InputFile' should have exactly five arguments

Analyzed 1 podspec.

EDIT

In my sdk repository there is code but nothing really meaningful.

i.e. the .h file looks like so:

//
//  DummySDK.h
//  DummySDK
//
//  Created by Grant Spilsbury on 2014/09/25.
//  Copyright (c) 2014 Grant Spilsbury. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface DummySDK : NSObject

@end

The entire file structure of the sdk repository looks like this:

/dummysdk
/dummysdk/DummySDK
/dummysdk/DummySDK/DummySDK.h
/dummysdk/DummySDK/DummySDK.m
/dummysdk/DummySDK.xcodeproj
/dummysdk/DummySDK.xcodeproj/project.xcworkspace
/dummysdk/DummySDK.xcodeproj/xcuserdata
/dummysdk/DummySDK.xcodeproj/project.pbxproj
/dummysdk/DummySDKTests

I renamed Xcode which seemed to solve one issue but I now get the following lint error:

~/.cocoapods/repos/PodSpecs$ pod spec lint .

 -> DummySDK
――― MARKDOWN TEMPLATE ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

### Report

* What did you do?

* What did you expect to happen?

* What happened instead?


### Stack

```
   CocoaPods : 0.33.1
        Ruby : ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]
    RubyGems : 2.0.14
        Host : Mac OS X 10.9.4 (13E28)
       Xcode : 6.0 (6A313)
Ruby lib dir : /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib
Repositories : Cocoapods - https://bitbucket.org/afrozaar/specs @ df68442fba9e1d7259248b1f2d46cc00835c6114
               PodSpecs - https://bitbucket.org/grantspilsbury/podspecs @ f3547e07e39e8a804c3a4238415cc86e5908d95f
               master - https://github.com/CocoaPods/Specs.git @ b99e5bad41d73c1c575dc2237ac7e7eab55b0dcc
```

### Error

```
REST::DisconnectedError - end of file reached
/Library/Ruby/Gems/2.0.0/gems/nap-0.8.0/lib/rest/request.rb:190:in `rescue in perform'
/Library/Ruby/Gems/2.0.0/gems/nap-0.8.0/lib/rest/request.rb:187:in `perform'
/Library/Ruby/Gems/2.0.0/gems/nap-0.8.0/lib/rest/request.rb:200:in `perform'
/Library/Ruby/Gems/2.0.0/gems/nap-0.8.0/lib/rest.rb:41:in `head'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-core-0.33.1/lib/cocoapods-core/http.rb:63:in `perform_head_request'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-core-0.33.1/lib/cocoapods-core/http.rb:13:in `block in get_actual_url'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-core-0.33.1/lib/cocoapods-core/http.rb:12:in `loop'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-core-0.33.1/lib/cocoapods-core/http.rb:12:in `get_actual_url'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-core-0.33.1/lib/cocoapods-core/http.rb:43:in `validate_url'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/validator.rb:232:in `validate_url'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/validator.rb:247:in `validate_homepage'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/validator.rb:199:in `perform_extensive_analysis'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/validator.rb:71:in `validate'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command/spec.rb:93:in `block in run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command/spec.rb:86:in `each'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command/spec.rb:86:in `run'
/Library/Ruby/Gems/2.0.0/gems/claide-0.6.1/lib/claide/command.rb:281:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/lib/cocoapods/command.rb:48:in `run'
/Library/Ruby/Gems/2.0.0/gems/cocoapods-0.33.1/bin/pod:33:in `<top (required)>'
/usr/bin/pod:23:in `load'
/usr/bin/pod:23:in `<main>'
```

――― TEMPLATE END ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――

[!] Oh no, an error occurred.

Search for existing github issues similar to yours:
https://github.com/CocoaPods/CocoaPods/search?q=end+of+file+reached&type=Issues

If none exists, create a ticket, with the template displayed above, on:
https://github.com/CocoaPods/CocoaPods/issues/new

Don't forget to anonymize any private data!

Upvotes: 1

Views: 2357

Answers (1)

NeoNacho
NeoNacho

Reputation: 680

So I see two problems in your final lint:

  • The error: InputFile messages are related to an issue regarding Xcode 6, see https://github.com/CocoaPods/CocoaPods/issues/2394#issuecomment-56658587 - as a workaround, you could renamed your Xcode 2.app to something else which does not contain spaces.

  • The source_files related message means that no .h or .m files actually exist in your Source directory. You said "There is no code in the project yet" early on, that will definitely cause the lint to fail.

Upvotes: 1

Related Questions