draveness / DKNightVersion

Manage Colors, Integrate Night/Multiple Themes. (Unmaintained)
MIT License
3.55k stars 516 forks source link

NoMethodError when executing rake command #3

Closed portwatcher closed 9 years ago

portwatcher commented 9 years ago

I want to customize my own theme for night mode. However, when I finish editing the property.json and run rake, it raise an error.

The error log goes like this:

......
[Generate] Generating Classes/UIKit/UITableViewCell/UITableViewCell+BackgroundColor.m
[Link] Find pbxproj file path
[Link] pbxproj is at '.././Pods.xcodeproj'
[Link] Linking to xcodeproj
rake aborted!
NoMethodError: undefined method `source_build_phase' for nil:NilClass
/path/to/Pods/DKNightVersion/generator/lib/generator/project.rb:59:in `clear_target'
/path/to/Pods/DKNightVersion/generator/lib/generator/project.rb:14:in `add_files_to_project'
/path/to/Pods/DKNightVersion/Rakefile:25:in `block in <top (required)>'
~/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `eval'
~/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => default
(See full trace by running task with --trace)

I'm not in good command of ruby, sorry.

draveness commented 9 years ago

This ruby script is based on xcodeproj which is a cocoapods components. I think you should run

bundle install // in DKNightVersion folder

or

[sudo] gem install xcodeproj

This will download requirements in Gemfile.

source "https://rubygems.org"

gem 'colorize'
gem 'rake'
gem 'xcodeproj'

After this, run rake.

portwatcher commented 9 years ago

I already successfully run bundle install before I go into this issue.

I check the edited json file again, I just change the hex string of the colors, nothing more.

draveness commented 9 years ago

Add this line of code puts target to add_files_to_project method

...
uikit_group = project.main_group.find_subpath(group_path, true)
uikit_group.clear
-> puts target
clear_target(target)
...

What does this print, do you use this repo with cocoapods? This error means that the script doesn't find a target in your pods project. If you use this repo with cocoapods, it will find the target inside Pods xcodeproj which names Pods-XXX-DKNightVersion.

portwatcher commented 9 years ago
......
[Generate] Generating Classes/UIKit/UITableViewCell/UITableViewCell+BackgroundColor.m
[Link] Find pbxproj file path
[Link] pbxproj is at '.././Pods.xcodeproj'
[Link] Linking to xcodeproj

rake aborted!
NoMethodError: undefined method `source_build_phase' for nil:NilClass

It seems it prints a line of blank.

Yes I'm using CocoaPods. and the Pods-DKNightVersion target exsists.

image

I build and run my app, and the customized night mode works in spite of the rake error.

Anyway, I can customize the night mode!

When will this repo march to 1.0.0 by the way? This is really an amazing repo.

draveness commented 9 years ago

我只是不想直接跳到 1.0.0, 我最近想加上使用代码设置默认颜色................. 不过有很多问题的...

我其实还是很想知道到底为什么没有找到正确的 target, 这个还是很关键的.

因为如果你不用 rake, 这个仓库是有默认的实现代码和配色的, 如果你不需要为新的类添加更多种类的属性, 其实不需要管这个 rake 命令...

portwatcher commented 9 years ago

嗯,不过确实帮我省了很多时间!

我们做的是一个手机浏览器,暂时只实现了插 CSS 来做到 Web app 的夜间模式,现在想实现全局的夜间模式。你这个真的太屌了,感谢!

当然,作为 90 后创业团队,我们会在应用的 设置 => 关于 里附上所有用到的开源项目的 License

( ・ ω・ ́)

draveness commented 9 years ago

( ・ ω・ ́)