Skip to content

Commit d115cb0

Browse files
committed
Update iOS troubleshooting and launch screen guidance
1 parent 723281e commit d115cb0

File tree

1 file changed

+40
-131
lines changed

1 file changed

+40
-131
lines changed

docs/developer-guide/Working-With-iOS.asciidoc

Lines changed: 40 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -2,167 +2,76 @@
22

33
=== Troubleshooting iOS Debug Build installs
44

5-
In 9 cases out of 10 if you have a problem installing an app make sure your device is a 64 bit device. If not you will need to add the build hint `ios.debug.archs=armv7`. Notice that a 32 bit app will still work on a 64 bit device it will just display a performance warning.
6-
7-
If you have access to a Mac you can connect a cable and open xcode where you can use the device explorer console to look at messages which sometimes give a clue about what went wrong. If not here is a laundry list of a few things that might fail:
5+
If you have access to a Mac you can connect a cable and open Xcode where you can use the device explorer console to look at messages which sometimes give a clue about what went wrong. If not, here is a laundry list of a few things that might fail:
86

97
- Make sure you built the debug version and not the appstore version. The appstore version won't install on the device and can only be distributed via Apple's store or testflight
108

11-
- Verify that you are sending a 32 bit build in the build hints using the build hint `ios.debug.archs=armv7`. It's only necessary if you have an older 32 bit device, see https://www.codenameone.com/blog/moving-to-64bit-by-default.html[this]. Notice that this only applies for debug builds, release builds include both 32 and 64 bit versions
12-
13-
TIP: Devices prior to iPad Air & iPhone 5s were 32 bit devices so iPhone 5s won't need that flag but iPhone 5 or iPhone 5c will need it
14-
159
- Check the the UDID is correct - if you got the UDID from an app then it's probably wrong as apps don't have access to the device UDID anymore. The way to get the UDID is either thru iOS Settings app or itunes
1610

1711
- Make sure the device isn't locked for installing 3rd party apps. I've had this when trying to install on my kids tablet which I configured to be child safe. This is configured in the settings as parental controls
1812

1913
- Check that you "own" the package name. E.g. if you previously installed an app with the same package name but a different certificate a new install will fail (this is true for Android too). So if you installed the kitchen sink from the store then built one of your own and installed it there will be a collision. +
2014
Notice that this might be problematic if you use overly generic package names as someone else might have used them which is why you must always use your own domain
2115

22-
- Make sure the device has a modern enough version of iOS for the dependencies. I think the current minimum for hello world is 6.0.1 but some apps might require a newer version e.g. Intercom requires OS 8 or newer
16+
- Make sure the device has a modern enough version of iOS for the dependencies. As of 2024, Codename One builds target iOS 12.0 or newer by default. You can raise the requirement with the `ios.deployment_target` build hint if a library needs a newer version.
2317

2418
- Verify that you are using Safari when installing on the device (if you tried via cable that's not a problem), some developers had issues with firefox not launching the install process
2519

2620
- Check that the build hint `ios.includePush` is set in a way that matches your iOS provisioning. So it must be false if you don't have push within the provisioning profile
2721

28-
[[section-ios-screenshots]]
29-
=== The iOS Screenshot/Splash Screen Process
30-
31-
NOTE: As of version 5.0 (September 2018), screenshot generation is no longer enabled by default. Instead, the launch storyboard is used. Therefore much of the following section is no longer relevant.
32-
33-
iOS apps seem to start almost instantly in comparison to Android apps. +
34-
There is a trick to that, iOS applications have a file traditionally called `Default.png` that includes a `320x480` pixel
35-
image of the first screen of the application. This creates an "illusion" of the application instantly coming to life and
36-
filling up with data, this is rather clever but is a source trouble as the platform grows footnote:[Apple provided
37-
another trick with XIB files starting with iOS 8 but that doesn't apply to games or Codename One. It has its own set of problems].
38-
39-
TIP: You can disable the screenshot process entirely with the `ios.fastBuild=true` build hint. This will only apply for debug builds so you don't need to worry about accidentally forgetting it in production.
40-
41-
The screenshot process was a pretty clever workaround but as Apple introduced the retina display `640x960` it required
42-
a higher resolution `[email protected]` file, then it added the iPad, iPad Retina and iPhone 5 footnote:[slightly larger screen and different aspect ratio] iPhone 6 & 6+ all of which required images of their own.
43-
44-
To make matters worse iPad apps (and iPhone 6+ apps) can be launched in landscape mode so that's two more resolutions for the horizontal orientation iPad. Overall as of this writing (or until Apple adds more resolutions) we need 16 screenshots for a typical iOS app:
45-
46-
.iOS Device Screenshot Resolutions
47-
|===
48-
|Resolution |File Name |Devices
22+
[[section-ios-launch-screen]]
23+
=== Launch Screen Storyboard Best Practices
4924

50-
|320x480
51-
|`Default.png`
52-
|iPhone 3gs
25+
Launch screen storyboards are the default approach for Codename One iOS builds. Apple requires a storyboard-based launch experience for modern devices, so the legacy screenshot generator was removed in favour of a single, adaptive layout. You can still opt back into the old behaviour by setting the `ios.generateSplashScreens=true` build hint, but we recommend adopting a storyboard unless you have a very specific use case that can't be expressed with Auto Layout.
5326

54-
|640x960
55-
56-
|iPhone 4x
27+
==== Key Files
5728

58-
|640x1136
59-
60-
|iPhone 5x
29+
The build server provides a minimal launch storyboard automatically. Customise it by adding any of the following files under your project's `native/ios` directory:
6130

62-
|1024x768
63-
|`Default-Portrait.png`
64-
|Non-retina ipads in portrait mode
31+
. `Launch.Foreground.png` - Shown in the centre of the screen instead of your app icon.
32+
. `Launch.Background.png` - Drawn behind the content to provide a colour or illustration.
33+
. `LaunchScreen.storyboard` - A custom storyboard created in Xcode that replaces the default layout entirely.
6534

66-
|768x1024
67-
|`Default-Landscape.png`
68-
|Non-retina ipads in landscape mode
69-
70-
|2048x1536
71-
72-
|Retina ipads in portrait mode
73-
74-
|1536x2048
75-
76-
|Retina ipads in landscape mode
77-
78-
|750x1334
79-
80-
|iPhone 6
81-
82-
|1242x2208
83-
84-
|iPhone 6 Plus Portrait
85-
86-
|2208x1242
87-
88-
|iPhone 6 Plus Landscape
35+
IMPORTANT: Make sure to add the `ios.multitasking=true` build hint, or your launch storyboard will not be used.
8936

90-
|2048×2732
91-
92-
|iPad Pro Portrait
37+
==== Designing a Flexible Layout
9338

94-
|2732x2048
95-
96-
|iPad Pro Landscape
39+
Keep the launch storyboard simple and static. The layout is rendered before your app code runs, so avoid views that depend on live data or animation. Follow these guidelines when editing `LaunchScreen.storyboard` in Xcode:
9740

98-
|1668×2224
99-
100-
|10.5" iPad Pro Portrait
41+
* Use Auto Layout constraints and safe-area guides so the design scales to every device, including split view on iPad.
42+
* Prefer system colours or vector/PDF assets for logos so the result stays crisp on high-density screens and supports Dark Mode.
43+
* Reserve text for short taglines or status messages that do not need localisation at launch. Dynamic localisation is not available.
44+
* Avoid referencing application delegate outlets or custom classes. Only design-time UIKit elements are supported.
10145

102-
|2224x1668
103-
104-
|10.5" iPad Pro Landscape
46+
==== Asset Reference
10547

106-
|1125×2436
107-
108-
|iPhone X Portrait
48+
The default storyboard expects PNG assets with the following characteristics. All sizes are specified in points (pt); supply @2x and @3x variants for Retina displays when possible.
10949

110-
|2436x1125
111-
112-
|iPhone X Landscape
50+
.Launch Screen Asset Reference
51+
|===
52+
|Asset | Purpose | Suggested 1x dimensions | Notes
53+
54+
|`Launch.Foreground.png`
55+
|Brand mark centred on screen
56+
|152×152
57+
|Provide optional `[email protected]` (304×304) and `[email protected]` (456×456) for sharper output. Use transparency to let the background show through.
58+
59+
|`Launch.Background.png`
60+
|Full-screen backdrop
61+
|1024×1024
62+
|Supply complementary `[email protected]` (2048×2048) and `[email protected]` (3072×3072) if you rely on artwork instead of a flat colour. Keep file sizes small (<2 MB) to avoid slowing startup.
63+
64+
|`LaunchScreen.storyboard`
65+
|Complete custom layout
66+
|N/A
67+
|Target iOS 12.0 and later, enable Auto Layout, and include constraints for every view. Avoid timers or code connections.
11368
|===
11469

115-
TIP: You can predefine any of these files within the `native/ios` directory in your project. If the build server sees a file matching that exact name it will not generate a screenshot for that resolution
116-
117-
Native iOS developers can run their applications 16 times with blank data to grab these screenshots every time they change something in the first view of their application!
118-
119-
With Codename One this will not be feasible since the fonts and behavior might not match the device. Thus Codename One runs the application 16 times in the build servers, grabs the right sized screenshots in the simulator and then builds the app!
120-
121-
This means the process of the iPhone splash screen is almost seamless to the developer, however like every abstraction this too leaks.
122-
123-
The biggest problem developers have with this approach is for apps that use a web browser or native maps in the first screen of their app. This won't work well as those are native widgets. They will look different during the screenshot process.
124-
125-
Another problem is with applications that require a connection immediately on startup, this can fail for the build process.
126-
127-
A solution to both problems is to create a special case for the first launch of the app where no data exists. This will setup the screenshot process correctly and let you proceed with the app as usual.
128-
129-
==== Size
130-
131-
One of the first things we ran into when building one of our demos was a case where an app that wasn't very big
132-
in terms of functionality took up 30mb!
133-
134-
After inspecting the app we discovered that the iPad retina PNG files were close to 5mb in size... +
135-
Since we had 2 of them (landscape and portrait) this was the main problem.
136-
137-
The iPad retina is a 2048x1536 device and with the leather theme the PNG images are almost impossible to compress because of the richness of details within that theme. This produced the huge screenshots that ballooned the application.
138-
139-
==== Mutable first screen
140-
141-
A very common use case is to have an application that pops up a login dialog on first run. This doesn't work well since the server takes a picture of the login screen and the login screen will appear briefly for future loads and will never appear again.
142-
143-
==== Unsupported component
144-
145-
One of the biggest obstacles is with heavyweight components, e.g. if you use a browser or maps on the first
146-
screen of the app you will see a partially loaded/distorted https://www.codenameone.com/javadoc/com/codename1/maps/MapComponent.html[MapComponent] and the native webkit browser
147-
obviously can't be rendered properly by our servers.
148-
149-
The workaround for such issues is to have a splash screen that doesn't include any of the above. Its OK to show it for a very brief amount of time since the screenshot process is pretty fast.
150-
151-
=== Launch Screen Storyboards
152-
153-
With the shift to Xcode 9, which is the default version on the Codename One build servers as of https://www.codenameone.com/blog/xcode-9-on-by-default.html[February 2018], it is now possible to use a launch-screen storyboard as the splash screen instead of launch images. This will potentially solve the issue of the proliferation of screenshots, as you can supply a single storyboard which will work on all devices. Launch screen storyboards are enabled by default (as of version 5.0/September 2018). You can disable them by adding the `ios.generateSplashScreens=true` build hint.
154-
155-
==== Launch Storyboard vs Launch Images
156-
157-
The key benefit of using a launch storyboard right now is that it allows your app to be used in split-screen mode. Storyboards, however, work a little bit differently than launch images. They don't show a screenshot of the first page of your app. The default Codename One launch storyboard simply shows your app's icon in the middle of the screen. You can customize the launch screen by providing one or more of the following files in your project's native/ios directory
158-
159-
. `Launch.Foreground.png` - Will be shown instead of your app's icon in the center of the screen.
160-
. `Launch.Background.png` - Will fill the background of the screen.
161-
. `LaunchScreen.storyboard` - A custom storyboard developed in Xcode, that will be used instead of the default storyboard.
70+
==== Testing Changes
16271

163-
IMPORTANT: Make sure to add the `ios.multitasking=true` build hint, or your launch storyboard will not be used.
72+
NOTE: Changes to the launch screen will not take effect until the device has been restarted. I.e. If you install your app on a device, then you make changes to the launch screen and update the app, the launch screen won't change until the device is restarted.
16473

165-
NOTE: Changes to the launch screen will not take effect until the device has been restarted. I.e. If you install your app on a device, then you make changes to the launch screen and update the app, the launch screen won't change until the device is restarted.
74+
When iterating locally with a Mac, open the generated Xcode project and run it on device or Simulator to verify that the layout adapts correctly. On Windows or Linux, submit a TestFlight or Ad Hoc build and validate on hardware before shipping.
16675

16776
=== Local Notifications on iOS and Android
16877

0 commit comments

Comments
 (0)