Dependencies
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.
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 :)
@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:
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, 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:
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, 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.