amirrajan / rubymotion-applied

RubyMotion documentation provided by the community. Submit a pull request to the docs for a free one year indie subscription.
Apache License 2.0
49 stars 10 forks source link

Wrong iOS UIScreen.mainScreen.bounds when missing Assets.xcasset #121

Open calicoday opened 5 years ago

calicoday commented 5 years ago

Wonder if this might help someone else (sorry if it’s already noted somewhere and I missed it). Not a rubymotion thing but dev for current iOS in general, I believe. Stumbled on the answer by accident, researching a totally unrelated swift problem.

This came up for me when I was merging and rearranging a couple of projects and suddenly my views weren’t displaying the right size, though I couldn’t see anywhere I was setting them wrong. Turns out, if your app doesn’t get built with an Assets.xcasset, it may well run mostly fine but the screen size doesn’t get set correctly from the start. So I’d get bounds size width=320.0 height=480.0, instead of width=375.0 height=667.0 on an iPhone 6s or width=375.0 height=812.0 on an iPhone X.

motion create will generate an Assets.xcasset directory in the resources directory. You can move it elsewhere (for whatever project management reasons of your own), so long as you add the new location to the Rakefile. For example, if you move Assets.xcasset into a subdir of resources or a sidedir, the Rakefile needs:

`app.resources_dirs << [‘resources/subdir’]`

or app.resources_dirs << ['sidedir’]

Obvi, missing Assets.xcasset will result in icon problems too but I wasn’t looking at icons. No major error messages but a quiet:

2019-01-11 09:25:53.058 mvassets[30199:8095732] +[CATransaction synchronize] called within transaction

(where ‘mvassets’ is the name of the app).

I investigated this under macos 10.13.6, rubymotion 5.14, and sims for iPhone 6s - 12.0 and iPhone X - 12.0.

amirrajan commented 5 years ago

@astechishin, any thoughts on this ^

amirrajan commented 5 years ago

might be related to this: https://github.com/amirrajan/rubymotion-templates/pull/10

astechishin commented 5 years ago

I wonder if we should generate a warning on the compile if this is missing? Adding a cli command to generate if missing is probably a good idea too (and could be mentioned in warning). What was issue under macOs? Funny window sizes?