简体   繁体   English

将Cocoapods用于私有iOS框架

[英]Use Cocoapods for private iOS Framework

I'm working on an iOS framework and I would like to make it available to other developers to integrate within their "client" apps by including them in their Podfile, such as: 我正在开发一个iOS框架,并且希望通过将其他开发者包括在他们的Podfile中,使其他开发者可以将其集成到他们的“客户端”应用中:

pod 'MyFramework'

But I can't share the actual source code for it due to some licensing restrictions. 但是由于某些许可限制,我无法共享实际的源代码。 The examples I found online for developing iOS frameworks and setting up their podspec files are typically pointing to a repository on github or others and that seems to make the source code available in the developers' app after they run: 我在网上找到的用于开发iOS框架并设置其podspec文件的示例通常指向github或其他上的存储库,并且看起来在运行它们之后,这些源代码就可以在开发人员的应用程序中使用:

pod install

Do I have to share the source code from my framework with the developer? 我是否必须与开发人员共享框架中的源代码? What is the best way (on both the framework setup in cocoapods and the client app in its Podfile) to make sure I can share MyFramework.framework but not its source code? 确保我可以共享MyFramework.framework但不能共享其源代码的最佳方法(在cocoapods中的框架设置及其Podfile中的客户端应用程序上)是什么? Note that I'm using Swift 3 for this project. 请注意,我正在为此项目使用Swift 3。

Thank you 谢谢

al

在此处输入图片说明


Podfile (client): Podfile(客户端):

target 'TestSDK' do
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
  use_frameworks!
pod 'MySDK', :path => '/path/to/SDK/'
  # Pods for TestSDK
end

MySDK.podspec: MySDK.podspec:

Pod::Spec.new do |s|  
    s.name              = 'MySDK'
    s.version           = '1.0.0'
    s.summary           = 'A really cool SDK that logs stuff.'
    s.homepage          = 'http://example.com/'

    s.author            = { 'Name' => 'sdk@example.com' }
    s.license           = { :type => 'Apache-2.0', :file => 'LICENSE' }

    s.platform          = :ios
s.source = { :http => 'https://bitbucket.org/username/reponame/src/master/MySDK.zip' }
    s.ios.deployment_target = '9.3'
    s.ios.vendored_frameworks = 'MySDK.framework'
end  

Hopefully this will help others. 希望这会帮助其他人。 I ended up solving this issue by hosting the zip file that contains the framework along with my README.md and LICENSE (and later a CHANGELOG.md) and pointed the podspec's s.source to it. 我通过托管包含该框架以及我的README.md和LICENSE(以及后来的CHANGELOG.md)的zip文件来解决了这个问题,并指向了podspec的s.source。 The only issue that I have now is that on cocoapods.org, it shows that the language is in Objective-C rather than Swift, but I think that should be an easy fix. 我现在唯一的问题是在cocoapods.org上,它表明该语言是使用Objective-C而不是Swift的,但是我认为这应该很容易解决。 Otherwise, I'm now able to have the framework on trunk and use Pod MySDK in a client app. 否则,我现在可以将框架放在主干上,并在客户端应用程序中使用Pod MySDK。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM