3

Is it required for a cocoapod framework to be open source? I have created a cocoapod swift framework on git.

And when I create an ios application and config the pod information in my Podfile.

It works fine.Now I want to protect my source code, expect other guys can use my framework, but can not see my framework source code.

Is that possible?

Kara
  • 5,650
  • 15
  • 48
  • 55
fcbflying
  • 623
  • 1
  • 6
  • 19

2 Answers2

5

Yes, it is possible. You can create a framework, compile it and distribute as a cocoapod. Use the vendored_framework or vendored_frameworks key in your podspec. An example podspec is the Google-Mobile-Ads-SDK pod that is distributed exactly that way.

{
  "name": "Google-Mobile-Ads-SDK",
  "version": "7.6.0",
  "summary": "Monetize your mobile applications with Google ads",
  "description": "The Google Mobile Ads SDK is the latest generation in Google mobile advertising featuring refined ad formats and streamlined APIs for access to mobile ad networks and advertising solutions.",
  "homepage": "https://developers.google.com/admob/",
  "license": {
    "type": "Copyright",
    "text": "Copyright 2011 Google Inc. All Rights Reserved."
  },
  "authors": "Google Inc.",
  "platforms": {
    "ios": "6.0"
  },
  "source": {
    "http": "https://dl.google.com/googleadmobadssdk/googlemobileadssdkios-7.6.0.zip"
  },
  "preserve_paths": "GoogleMobileAdsSdkiOS-7.6.0",
  "vendored_frameworks": "GoogleMobileAdsSdkiOS-7.6.0/GoogleMobileAds.framework",
  "weak_frameworks": "AdSupport",
  "frameworks": [
    "AudioToolbox",
    "AVFoundation",
    "CoreGraphics",
    "CoreMedia",
    "CoreTelephony",
    "EventKit",
    "EventKitUI",
    "MessageUI",
    "StoreKit",
    "SystemConfiguration"
  ],
  "requires_arc": true
}
Adam
  • 24,901
  • 8
  • 59
  • 74
  • you mean I need to add the 'vendored_frameworks' line in my podspec? How about the value of it, I can not understand well what is this property used for. – fcbflying Jan 06 '16 at 02:24
  • "vendored_frameworks" is used to integrate third custom framework, why will it protect my source non-open. – fcbflying Jan 06 '16 at 02:39
  • Do not include source code in your pod, only the compiled framework. – Adam Jan 06 '16 at 05:49
  • only add the 'vendored_frameworks' property will work? What should be its value? My .framework path?And where the path is relative to? – fcbflying Jan 06 '16 at 06:26
  • Take a look at the example. The compiled framework is uploaded to some server, there is no source code at all. – Adam Jan 06 '16 at 06:33
  • I tried to upload my .framework to the git as part of my source. – fcbflying Jan 06 '16 at 07:38
  • I tried to upload my .framework to the git as part of my source. And when I add my framework pod in my another project podfile. and then run 'pod update' will download my framework and I see only .framework folder contains Frameworks sub sub folder (inlcude some .dylib files) and Headers sub folder (include test.h file and test-Swfit.h file), I can import my framework, but can not use method or instantiate my public swift class in the framework – fcbflying Jan 06 '16 at 07:45
  • Any tutorial links for me? – fcbflying Jan 06 '16 at 09:01
  • It seems like there is something wrong with your framework itself. For tutorials check [Ray Wenderlich](http://www.raywenderlich.com). – Adam Jan 06 '16 at 09:26
  • That is not relevant. If you have issues with creating a framework, please ask another question. – Adam Jan 06 '16 at 09:36
  • see [create a swift framework](http://stackoverflow.com/questions/34630048/custom-swift-framework-create-with-other-dependencies) – fcbflying Jan 06 '16 at 09:50
1

CocoaPods closed source

CocoaPods[About] supports open source and closed source(binary) distribution

To create closed source you should

  1. Create a fat binary[Vocabulary] - to allow working with it on simulator and real device
  2. Zip and publish(e.g. zip attachment for GitHub)

The key point is to use parameters in your podspec:

  • source - http link to a .zip file with a fat binary
  • vendored_frameworks - path to your framework in the .zip file pointed by the source

Take a look at guidelines here, here

yoAlex5
  • 13,571
  • 5
  • 105
  • 98