CocoaSeeds icon indicating copy to clipboard operation
CocoaSeeds copied to clipboard

Dependencies

Open hffmnn opened this issue 10 years ago • 6 comments

Hi there,

do you have any ideas, how to handle dependencies? Given I want to add github "thoughtbot/Argo", "2.1", :files => "Argo/*/*.swift" it does not compile, because it has imports like import Runes and the compiler says No such module: Runes.

hffmnn avatar Oct 09 '15 18:10 hffmnn

Hi, @hffmnn. Sadly there's no clear way to avoid import statement in CocoaSeeds. Currently I'm trying to add post-file-processing to remove all import statements.

If you have an idea, please let me know :)

devxoul avatar Oct 12 '15 08:10 devxoul

@hffmnn, I've succeeded installing latest version of Runes and Argo. Here's my Seedfile:

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

They seem to have deleted all import statements from their source files. :smiley:

devxoul avatar Oct 20 '15 06:10 devxoul

I have the following code run after seed install to strip out imports: https://github.com/argon/mas/blob/master/script/bootstrap#L13-L27

I've been using it in a few projects with lots of imports so it might be useful for you.

argon avatar Nov 05 '15 20:11 argon

@argon, looks good! I'm having a problem on deleting import statements because CocoaSeeds should not delete system frameworks such as CoreBluetooth or something else. I'll keep this in my mind :smile:

devxoul avatar Nov 06 '15 05:11 devxoul

The code I posted does exactly what you describe, it first builds a list of directories in Seeds/ (each corresponding to a seeded import.

    # Build a list of the seeded modules
    MODULES=( )
    for i in  */; do 
      MODULES+=(${i%%/})
    done

Next it creates a search pattern of the found modules:

    # Construct a pattern for module imports to remove
    local pattern
    pattern="/import ($(join "|" "${MODULES[@]}"))/d"

Giving, for example: pattern="/import (Argo|Runes|Commandant)/d"

It then finds all swift files and deletes lines matching that regular expression:

    find . -name "*.swift" -type f -exec sed -Eie "${pattern}" {} \;

I find it works well and behaves exactly as it should, only deleting Seeded import statements.

argon avatar Nov 06 '15 07:11 argon

@argon, Oh yeah. But, what I exactly wanted to do is 'Remove all import statements except system frameworks.'. It looks similar, but it is as different as blacklisting and whitelisting.

devxoul avatar Nov 06 '15 08:11 devxoul