Skip to content

Commit 2e55720

Browse files
committed
Inertia on iOS
And other useful hints
1 parent f2aeb55 commit 2e55720

File tree

1 file changed

+66
-7
lines changed

1 file changed

+66
-7
lines changed

resources/views/docs/mobile/1/getting-started/development.md

Lines changed: 66 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@ title: Development
33
order: 300
44
---
55

6-
## Building
7-
8-
Building your NativePHP apps can be done completely in the browser with the workflows you're already familiar with.
6+
Developing your NativePHP apps can be done in the browser, using workflows with which you're already familiar.
97

108
This allows you to iterate rapidly on parts like the UI and major functionality, even using your favorite tools for
119
testing etc.
1210

13-
But when you want to test _native_ features, then you must run it on a real/emulated device.
11+
But when you want to test _native_ features, then you must run your app on a real/emulated device.
1412

1513
Whether you run your native app on an emulated or real device, it will always require compilation after changes have
1614
been made.
1715

16+
<aside class="relative z-0 mt-5 overflow-hidden rounded-2xl bg-pink-50 px-5 ring-1 ring-black/5 dark:bg-pink-600/10">
17+
18+
#### Platforms
19+
1820
We've worked incredibly hard to ensure that your apps will operate almost identically across both platforms - aside
1921
from obvious platform differences. For the most part, you should be able to build without thinking about which platform
2022
your app is running on, but if you do need to, you can check by using one of the following helper methods:
@@ -26,6 +28,38 @@ System::isIos() // -> `true` on iOS
2628
System::isAndroid() // -> `true` on Android
2729
```
2830

31+
</aside>
32+
33+
## Build your frontend
34+
35+
If you're using Vite or similar tooling to build any part of your UI (e.g. for React/Vue, Tailwind etc), you'll need
36+
to run your asset build command _before_ compiling your app.
37+
38+
### Inertia on iOS
39+
40+
Due to the way your apps are configured to work on iOS, we need to patch the Axios package to make Inertia work.
41+
42+
We've tried to make this as straightforward as possible. Simply run:
43+
44+
```shell
45+
php artisan native:patch-inertia
46+
```
47+
48+
This will backup your current `vite.config.js` and replace it with one that 'fixes' Axios.
49+
50+
You will just need to copy over any specific config (plugins etc) from your old Vite config to this new one.
51+
52+
Once that's done, you'll need to adjust your Vite build command for when you're creating iOS builds. _Only_ for iOS
53+
builds. (If you try to run these builds on Android they probably won't work.)
54+
55+
Add the `--mode=ios` to your build command. Run it before compiling your app for iOS. Here's an example using `npm`:
56+
57+
```shell
58+
npm run build -- --mode=ios
59+
```
60+
61+
## Compile your app
62+
2963
To compile and run your app, simply run:
3064

3165
```shell
@@ -37,9 +71,12 @@ learn any new editors or platform-specific tools.
3771

3872
<aside class="relative z-0 mt-5 overflow-hidden rounded-2xl bg-pink-50 px-5 ring-1 ring-black/5 dark:bg-pink-600/10">
3973

40-
#### Rule of Thumb
74+
#### Rule of thumb
4175

4276
During development, keep `NATIVEPHP_APP_VERSION=DEBUG` to always refresh the Laravel application inside the native app.
77+
Your app will boot a little slower, but you will find that everything looks as you expect.
78+
79+
It's better than scratching your head for an hour trying to figure out why your changes aren't showing!
4380

4481
</aside>
4582

@@ -56,17 +93,25 @@ php artisan native:open
5693

5794
## Hot Reloading (Experimental)
5895

96+
We've tried to make compiling your apps as fast as possible, but when coming from the 'make a change; hit refresh'-world
97+
of PHP development that we all love, compiling apps can feel like a slow and time-consuming process.
98+
99+
So we've released an early version of hot reloading, which aims to make your development experience feel just like home.
100+
59101
You can enable hot reloading by adding the `--watch` flag when running the `native:run` command:
60102

61103
```shell
62104
php artisan native:run --watch
63105
```
64106

65-
This is useful during development for quickly testing changes without rebuilding the entire app.
107+
This is useful during development for quickly testing changes without re-compiling your entire app. When you make
108+
changes to any files in your Laravel app, the web view will be reloaded and your changes should show almost immediately.
66109

67110
### Caveats
68111

69-
This feature is currently best suited for **Blade** and **Livewire** applications. It does not work so well if you're
112+
For now, hot reloading only works in emulators, not on real devices.
113+
114+
Also, it's currently best suited for **Blade** and **Livewire** applications. It doesn't work so well if you're
70115
also trying to hot reload compiled frontends using something like Vite's hot reloading.
71116

72117
## Releasing
@@ -111,3 +156,17 @@ submit it to the stores for approval and distribution.
111156

112157
- [Google Play Store submission guidelines](https://support.google.com/googleplay/android-developer/answer/9859152?hl=en-GB#zippy=%2Cmaximum-size-limit)
113158
- [Apple App Store submission guidelines](https://developer.apple.com/ios/submit/)
159+
160+
<aside class="relative z-0 mt-5 overflow-hidden rounded-2xl bg-pink-50 px-5 ring-1 ring-black/5 dark:bg-pink-600/10">
161+
162+
#### Skip the prompts
163+
164+
If you are tired of prompts, you can run most commands - like `native:run` - with the arguments and options that will
165+
allow you to skip through the various prompts. Use the `--help` flag on a command to find out what values you can
166+
pass directly to it:
167+
168+
```shell
169+
php artisan native:run --help
170+
```
171+
172+
</aside>

0 commit comments

Comments
 (0)