Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating CocoaPod Library without including source code

I've a framework project on IOS and I would like to change it to a cocoapod project , however as much as I read from making cocoapod documentation its commonly used for the project which source codes are open. However our SDK is commercial and our customers are paying money for that, so I would like to include my existing framework into cocoapod library(private or public) but I dont want my source codes to be seen. Is something like that possible?

I' ve seen the google analytics made something like that ( https://developers.google.com/analytics/devguides/collection/ios/v3/)

Does anybody know how can I do something like that?

[EDIT]

According to answers, I've modified our podspec file as in the below url: https://github.com/Kandy-IO/test-cp/blob/1.6.7/CPaaSSDK.podspec

However when I try to push it to cocoapods , it gave the below error

Validating podspec
 -> CPaaSSDK (1.6.7)
    - ERROR | [iOS] public_header_files: The pattern includes header files that are not listed in source_files (/private/var/folders/kl/zfs4qq_d119cvqq26x9rt3zc0000gp/T/CocoaPods-Lint-20190513-14320-1opt8kx-CPaaSSDK/Pods/CPaaSSDK/CPaaSSDK.framework/Headers/CPaaSSDK-Swift.h, /private/var/folders/kl/zfs4qq_d119cvqq26x9rt3zc0000gp/T/CocoaPods-Lint-20190513-14320-1opt8kx-CPaaSSDK/Pods/CPaaSSDK/CPaaSSDK.framework/Headers/CPaaSSDK.h).
    - ERROR | [iOS] xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - NOTE  | [CPaaSSDK/CPUtilities, CPaaSSDK/RestManager, CPaaSSDK/CPWebRTC, and more...] xcodebuild:  note: Using new build system
    - NOTE  | [CPaaSSDK/CPUtilities, CPaaSSDK/RestManager, CPaaSSDK/CPWebRTC, and more...] xcodebuild:  note: Planning build
    - NOTE  | [CPaaSSDK/CPUtilities, CPaaSSDK/RestManager, CPaaSSDK/CPWebRTC, and more...] xcodebuild:  note: Constructing build description
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftCoreGraphics'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftFoundation'
    - NOTE  | xcodebuild:  ld: warning: 
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftMetal'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftDarwin'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftUIKit'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftCoreFoundation'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftObjectiveC'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftDispatch'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftCoreMedia'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftQuartzCore'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftCore'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftCoreImage'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked library 'swiftCoreAudio'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked framework 'CPAddressBookService'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked framework 'CPWebRTC'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked framework 'CPAuthenticationService'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked framework 'NotificationEngine'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked framework 'CPMessagingService'
    - NOTE  | xcodebuild:  ld: warning: Could not find auto-linked framework 'CPUtilities'
    - NOTE  | xcodebuild:  RestManager.CPRestDownloadRequest.completion(_: __C.NSObject?, error: Swift.Error?) -> () in CPaaSSDK(CPRestDownloadRequest.o)
    - NOTE  | xcodebuild:  function signature specialization <Arg[1] = Exploded> of CPAddressBookService.CPAddressBookService.(logResult in _FFF4592E3450CC7F075A904CF3818DC2)(error: __C.CPError?, functionName: Swift.String) -> () in CPaaSSDK(CPAddressBookService.o)
    - NOTE  | [iOS] xcodebuild:  clang: error: 
    - NOTE  | [iOS] xcodebuild:  ld: warning: Could not find auto-linked library 'swiftsimd'
    - NOTE  | [iOS] xcodebuild:  ld: warning: Could not find auto-linked library 'swiftAVFoundation'
    - NOTE  | [iOS] xcodebuild:  ld: warning: Could not find auto-linked framework 'RestManager'
    - NOTE  | [iOS] xcodebuild:  ld: warning: Could not find auto-linked framework 'CPPresenceService'
    - NOTE  | [iOS] xcodebuild:  ld: warning: Could not find auto-linked framework 'CPCallService'
    - NOTE  | [iOS] xcodebuild:  ld: warning: Could not find auto-linked framework 'CPPushService'
    - ERROR | [CPaaSSDK/CPUtilities, CPaaSSDK/RestManager, CPaaSSDK/CPWebRTC, and more...] file patterns: The `vendored_frameworks` pattern did not match any file.
    - WARN  | [CPaaSSDK/CPUtilities, CPaaSSDK/RestManager, CPaaSSDK/CPWebRTC, and more...] file patterns: The `public_header_files` pattern did not match any file.

[!] The spec did not pass validation, due to 3 errors and 1 warning.

Thanks

like image 313
tolgatanriverdi Avatar asked Feb 22 '16 10:02

tolgatanriverdi


1 Answers

CocoaPods's podspec allows shipping closed source pods.

You can use the following podspec settings:

  • vendored_frameworks to point to .framework bundles in the repo;
  • vendored_libraries to point to static library files (.a) plus source_files to point to the header files so client apps now how to use the library.

You can even combine both, for what it's worth.

When properly set up, your prepared library files will be shipped instead of source files that have to be built by devs.

To differentiate the platforms, you can write:

spec.ios.vendored_frameworks = "..."
spec.osx.vendored_frameworks = "..."

Similarly, vendored_libraries is available for the platform parameters as well.

Static lib

As @Sven Herzberg mentioned, the Flurry SDK uses static library plus headers like this:

s.subspec 'FlurrySDK' do |ss|
  ss.source_files = [
    'Flurry/Flurry.h',
    'Flurry/FlurrySessionBuilder.h',
    'Flurry/FlurryConsent.h',
    'Flurry/FlurryEmpty.m'
  ]

  ss.platform   = :ios, '8.0'
  ss.frameworks = 'Foundation', 'SystemConfiguration', 'UIKit', 'Security'
  ss.vendored_libraries = "Flurry/libFlurry_9.2.1.a"
end

Framework bundle

On the other hand, the Google Ads SDK v7.35 uses frameworks and additionally a static library without headers (of which I'm not sure how you'd use that):

"source": {
  "http": "https://dl.google.com/dl/cpdc/bda58e433afe6cb0/Google-Mobile-Ads-SDK-7.35.0.tar.gz"
},
"vendored_frameworks": [
  "Frameworks/frameworks/GoogleMobileAds.framework"
],
"vendored_libraries": [
  "Libraries/libGoogleMobileAds.a"
],

Heads up: the source parameter points to the downloadable package that contains both the framework and the static library, not to headers like source_files does. I overlooked this when first scanning the specification.

like image 105
ctietze Avatar answered Oct 20 '22 00:10

ctietze