How to use local-only project via CocoaPods

2020-04-08 13:13发布

I am struggling to find a way to package an Xcode framework we created as a Pod that would only be used internally (not public, not on github).

How do I modify the .podspec to build the SDK from the local Xcode project on my development machine?

3条回答
家丑人穷心不美
2楼-- · 2020-04-08 13:18

Short answer: you don't use the .podspec for this. Longer: the .podfile is mainly for specifying:

  • external dependencies
  • what to snarf out of the project, relative to the project folder

IIRC, other than some informational metadata, the .podspec does not address how you get to that project folder, as this is handled separately.

As mentioned in the comments, you can use the Podfile to use a local project, with the :path => directive pointing to a local project folder. For example, you have the project in /Users/me/proj -- and the .podspec lives at the top-level -- your Podfile would have an entry like:

pod 'MyPodName', :path => '/Users/me/proj'

Warning: when you run pod {update, install}, this will pull whatever is checked out locally in that project at the time.

查看更多
我命由我不由天
3楼-- · 2020-04-08 13:30

You just need a private Git repository, add as a source to Podfile Then deciding if the framework is going to be closed source or open source, then podspec file will be different. all the pod repo ... will help you Doc

查看更多
狗以群分
4楼-- · 2020-04-08 13:32

Sometimes during development it is useful to check CocoaPod's[About] changes locally.

Example with Git enter image description here

Textual

//Podfile
//-remote    
    pod 'PodName'
//-local     
    pod 'PodName', :path => 'local_path_to.podspec'

//.podspec
//-remote    
    s.source = { :git => "https://url_to.git", :tag => "git_tag" }
//-local     
    s.source = { :git => 'file:///path_to_git_folder', :tag => "git_tag" }

Do not forgive to commit your changes beforehand. git_tag can be the same as a branch name

Several useful commands

Podfile

pod update

.podspec

pod spec lint "path_to.podspec" --quick
pod spec lint "path_to.podspec" --verbose --allow-warnings
查看更多
登录 后发表回答