Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here's the approach that I've used in the past to share resources across Android and iOS: </p> <ul> <li><a href="http://www.tricedesigns.com/2012/02/16/linked-source-files-across-phonegap-projects-on-osx/" rel="nofollow noreferrer">http://www.tricedesigns.com/2012/02/16/linked-source-files-across-phonegap-projects-on-osx/</a></li> </ul> <p>You can use this exact technique to have a shared codebase, but also have platform-specific files. Just add a folder to the www directory (not the shared directory), and put your platform specific CSS files inside of it. <em>Note: in this approach, a subfolder of www is symlinked, not the parent of www.</em></p> <p>For having separate CSS files between device form factors it's a little bit more tricky...</p> <p>One option is to conditionally append &lt;style&gt; elements during application initialization using JavaScript. You can inspect the user agent and the window dimensions, and manually add a &lt;style&gt; element for the appropriate platform and form factor. However, user agent sniffing is generally discouraged b/c it can be easily broken, or fail if a new device category is introduced.</p> <p>Another option is to include everything and use CSS media queries.</p> <p>If you are using a universal binary (targets both phone and tablet form factors), then you have to include the phone and tablet CSS both in the app. You can use CSS media queries so that CSS styles are only applied to specific device form factors. So, wrap your tablet styles in a media query, and they will only be applied to the tablet form factor. </p> <p>You can read more about CSS media queries here: </p> <ul> <li><a href="https://developer.mozilla.org/en-US/docs/CSS/Media_queries" rel="nofollow noreferrer">https://developer.mozilla.org/en-US/docs/CSS/Media_queries</a></li> </ul> <p>You can access predefined CSS media queries for common device form factors here:</p> <ul> <li><a href="https://stackoverflow.com/questions/6370690/media-queries-how-to-target-desktop-tablet-and-mobile">Media Queries: How to target desktop, tablet and mobile?</a></li> <li><a href="http://css-tricks.com/snippets/css/media-queries-for-standard-devices/" rel="nofollow noreferrer">http://css-tricks.com/snippets/css/media-queries-for-standard-devices/</a></li> </ul> <p>If you are not using a universal binary, you would need separate project environments for each device category. In each separate project, you could symlink to the shared codebase, with a static path to the CSS file.</p> <p>If you want to conditionally insert specific CSS files to specific project configurations, then you either need separate projects for each, or you need to write a script to do it for you.</p> <p>Hopefully that helps...</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COThanks for your answer Andrew. We already handle css load depending of the device type (using javascript). But my question is more about excluding **tablet images** to be included into the install for iphone, for example. Our phone version of the app is already quite heavy on IOS (~9Mo). So I don't want that once the tablet part would be added to the project that the size grow up to ~30Mo where 20Mo are not used.
      singulars
    2. COI use the same approach than you to share resources across Android and iOS (I think that, I follow your tutorial for that). But this approach only resolve the problem of separated or shared resources across OS's (Android & IOS) but not for devices type under same OS. I think that for Android, I can extend this approach since Google Play allow to upload 2 different builds for the same app (one target phones, the other that target tablets). But using this approach on IOS (2 IOS projects with symlinks) will force me to have 2 app to manage in the App Store. I would link to avoid that.
      singulars
    3. COWith the universal binary approach for iOS, you unfortunately don't have much choice. If you want it to be inside the app archive for both form factors, then the assets have to be in there. The only alternative I can think of is that you could pull the UI elements from a server and save locally when needed (HTML5 cache or write to local file system). This would reduce IPA file size, but would require downloading assets on first use.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload