Project

cocoaseeds

0.12
Repository is archived
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
Git Submodule Alternative for Cocoa. iOS 7 projects are not available to use Swift librariesfrom CocoaPods or Carthage. CocoaSeeds just downloads thesource code and add to your Xcode project. No staticlibraries, no dynamic frameworks at all. It can be usedwith CocoaPods and Carthage.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

~> 3.1
>= 0.28
 Project Readme

CocoaSeeds

Gem Build Status

Git Submodule Alternative for Cocoa. Inspired by CocoaPods.

Why?

  • iOS 7 projects do not support the use of Swift libraries from CocoaPods or Carthage.

    ld: warning: embedded dylibs/frameworks only run on iOS 8 or later

  • CocoaSeeds just downloads the source code and add it to your Xcode project. No static libraries, no dynamic frameworks.

  • Git Submodule sucks.

  • It can be used with CocoaPods and Carthage.

Installation

You can get CocoaSeeds from RubyGems.

$ [sudo] gem install cocoaseeds

How to Use CocoaSeeds

1. Write a Seedfile

A Seedfile is a ruby script that manifests the dependencies of your project. You can manage third party libraries by simply specifying them in the Seedfile. Currently, CocoaSeeds supports only GitHub and BitBucket repositories. However, we are planning to support other version control systems.

Let's make an empty file named Seedfile in the directory where your Xcode project file is located. Here is a sample Seedfile:

Seedfile

github "Alamofire/Alamofire", "1.2.1", :files => "Source/*.{swift,h}"
github "devxoul/JLToast", "1.2.5", :files => "JLToast/*.{swift,h}"
github "devxoul/SwipeBack", "1.0.4"
github "SnapKit/SnapKit", :commit => "62e7645", :files => "Source/*.{swift,h}"

git "https://gitlab.com/MyCompany/CompanyLibrary.git", "1.1.0"
local "PrivateLibrary", "../libs/PrivateLibrary", :files => "Source/*.{swift,h}"

target :MyAppTest do
  github "Quick/Quick", "v0.3.1", :files => "Quick/**.{swift,h}"
  github "Quick/Nimble", "v0.4.2", :files => "Nimble/**.{swift,h}"
end

Can you guess what each line does? It has basic information about the third party libraries.

Each line in a Seedfile consists of three parts: source, tag, and files. Let's look at the second line of the previous sample.

github "devxoul/JLToast", "1.2.5", :files => "JLToast/*.{swift,h}"
~~~~~~~~~~~~~~~~~~~~~~~~  ~~~~~~~  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       (Source)          (Version)             (Files)
Parts Example Required Default
Source github "devxoul/SwipeBack" Required -
Version Tag: "1.0.4"
Branch: "swift-2.0"
Commit: :commit => "SHA1"
Required -
Files :files => "JLToast/*.{swift,h}" Optional */**.{h,m,mm,swift}

Tip: You can pass an array to :files for multiple file patterns:

:files => ["/path1/*.swift", "/path2/*.swift"]

Want to use branch names instead of tags? See the Branch support section.

Specifying targets

Third party libraries can be included as a specific target by creating a target block. For example, if you want to add some testing libraries such as Quick and Nimble into test target, you can specify them like this:

target :MyAppTest do
  github "Quick/Quick", "v0.3.1", :files => "Quick/**.{swift,h}"
  github "Quick/Nimble", "v0.4.2", :files => "Nimble/**.{swift,h}"
end

Specifying Xcode project file path

If the .xcodeproj file is located in other location, you can specify the path in Seedfile.

xcodeproj "path/to/Project.xcodeproj"

target :MyApp do
    github "devxoul/JLToast", "1.2.5", :files => "JLToast/*.{swift,h}"
end

2. Install dependencies

After you are done with your Seedfile, it's time to load those libraries into your project. This is pretty simple. Just open the terminal, cd to your project directory and execute seed install command.

$ seed install

Then, all the source files will be automatically downloaded and added to a group named 'Seeds'.

Seeds-in-Xcode

3. Enjoy

Build your project and enjoy coding!

Tips and Tricks

Using branches

You can specify a branch name instead of the tag. What you need to do is just replacing the tag with the branch name.

github 'devxoul/SwiftyImage', 'swift-2.0', :files => 'SwiftyImage/SwiftyImage.swift'

Excluding files

Use exclude_files to exclude files from files pattern.

github 'devxoul/Carte', '0.2.2', :files => 'Carte/*', :exclude_files => "Carte/Carte.h"

Using resources

If the resource files are sprecified in files, they will be added to Copy Bundle Resource build phase instead of Compile Source build phase.

github 'author/Repository', 'x.y.z', :files => ['Source/*', 'Images/*']

Resolving filename conflicts

Since CocoaSeeds tries to include source files directly rather than linking dynamic frameworks, it is important to make sure that all sources have different names. CocoaSeeds provides a way to do this:

Seedfile

swift_seedname_prefix!  # add this line

github "thoughtbot/Argo", "v1.0.3", :files => "Argo/*/*.swift"
github "thoughtbot/Runes", "v2.0.0", :files => "Source/*.swift"

Then all of source files installed via CocoasSeeds will have names with the seed names as prefix.

Before (filename) After (seedname_filename)
Seeds/Alamofire/Alamofire.swift Seeds/Alamofire/Alamofire_Alamofire.swift
Seeds/Argo/Operators/Operators.swift Seeds/Argo/Operators/Argo_Operators.swift
Seeds/Runes/Operators.swift Seeds/Runes/Runes_Operators.swift

FAQ

  • Are you using this in real-world projects? (Does Apple allow apps to use CocoaSeeds?)

    • Of course I am. I'm developing a social media service that has about 2 million users. The app is on AppStore without any complaints from Apple.
  • Can I ignore Seeds folder in VCS (version control system)?

    • Yes, you can ignore the Seeds folder (by adding it to .gitignore if you use Git).

License

CocoaSeeds is under MIT license. See the LICENSE file for more info.