Closed macfanatic closed 10 years ago
The contents of my AppScreenshots class being super simple:
class AppScreenshots < Motion::Screenshots::Base
screenshot "home"
end
Sorry about the problems!
Can you move your call to AppScreenshots.start!
to say a viewDidAppear
call in your first view controller? Basically the AppDelegate method gets called before anything is on screen, and so the screenshots trigger immediately (in your case), but there's nothing to capture.
See the example for where that goes
Let me know if that fixes it and I'll update the README accordingly
Ah, that makes sense - but the README should probably be updated to reflect that then. I ended up reverting the changes in the gem I had mentioned above and used GCD along with asynchronously screenshots to work when having the call to start in the delegate.
class AppScreenshots < Motion::Screenshots::Base
async_screenshot "home" do
before do
Dispatch::Queue.main.after 2 do
ready!
end
end
end
async_screenshot "learn" do
before do
screen = LearnScreen.new(letter: Letter.new("M"))
App.delegate.open screen
keyboard = screen.instance_variable_get("@grid")
keyboard.viewWithTag(1).tapped
keyboard.viewWithTag(4).tapped
keyboard.viewWithTag(5).tapped
# allow animations to complete
Dispatch::Queue.main.after 1 do
ready!
end
end
end
end
Ah great, I've updated the readme.
By the way, there's a shortcut for the Dispatch::Queue w/ ready_delay
in v0.0.7 if you want to use that:
class Screenshots
async_screenshot "profile" do
ready_delay 1
before do
ready! # will be invoked after 1s
end
end
end
I've never used the related cocoapod before, but I've added this gem to my Gemfile in my project, created a subclass & added the
AppScreenshots.start!
call to my app delegate on launch. Running the rake task succeeds and copies the contents of the folder from inside the simulator (~/Library/...) as I expect, but I have no image files at all.The only way I was able to get this to succeed was by removing the following line from inside the
Motion::Screenshots::Base#start!
method:With that gone, the images appear in the ~/Library directory inside the simulator, and the rake task actually copies them into my project directory for me as expected.
Any thoughts?