To test our app across as many devices as possible we’ve written a simple loop script that calls this for both iOS and Android
npx cap run ios --list
and then loops through this for each id (filtering out simulators)
npx cap run ios --target $ID
for every targeted deployment it runs through copying web assets, updating plugins, updating native dependencies etc. Which makes the whole process take a while. Is it possible to build once and then shortcut the rest of them with just a simple push to each device?
You can try the Ionic CLI’s ionic capacitor run with it’s --no-build
option: ionic capacitor run: Run an Ionic project on a connected device
Unfortunately it doesn’t appear to make any difference, all steps are repeated for every target
mac:-app craig$ ionic capacitor run ios --no-build --target 000........802E
> capacitor run ios --target 000.......802E
[capacitor] ✔ Copying web assets from **www** to ios/App/App/public in 1.38s
[capacitor] ✔ Creating **capacitor.config.json** in ios/App/App in 1.04ms
[capacitor] [info] Found 1 Cordova plugin for **ios** :
[capacitor] cordova-plugin-device@2.0.3
[capacitor] ✔ **copy ios** in 1.44s
[capacitor] ✔ Updating iOS plugins in 10.63ms
[capacitor] [info] Found 1 Cordova plugin for **ios** :
[capacitor] cordova-plugin-device@2.0.3
[capacitor] ✔ Updating iOS native dependencies with pod install in 4.42s
[capacitor] ✔ **update ios** in 4.48s
[capacitor] ✔ Running xcodebuild in 9.89s
[capacitor] ✔ Deploying **App.app** to 000.......802E in 4.20s
whats the exactly command that you typed?
Why are you doing a ionic capacitor copy iOS
?
Steps that ionic capacitor copy will do:
- Perform an Ionic build, which compiles web assets
- Copy web assets to Capacitor native platform(s)
Steps that ionic capacitor run will do:
- Perform
ionic build
(or run the dev server from ionic serve
with the --livereload
option)
- Copy web assets into the specified native platform
- Open the IDE for your native project (Xcode for iOS, Android Studio for Android)
So as you see, the copy is part of the run
You’re right, I must’ve mixed two build processes together.
Even without the copy
command, the run
command does the build every time instead of reusing the built artefacts. I’m trying to do just the final step where it say Deploying App.app to 123456
It works for me, which CLI Version do you use? (ionic -v)
What works for you? When I run capacitor run ios --target 1234567ETC
it builds, copies and deploys. If I then run capacitor run ios --target ABCDEF
it builds again, copies again and then deploys to the right target.
Are you saying you do the same and it doesn’t repeat the build and copy steps? Because that’s the action I’m looking for.
If i run ionic capacitor run ios --no-build it respects the no-build
and doesn’t build again
Would you mind showing me the output after you do this
ionic capacitor run ios --no-build --target .......
Hi there 
It sounds like it might make more sense for your use case to use native-run library directly. It is the utility that Ionic built and maintains and use for the new npx cap run
command as well as in the Ionic CLI.
The docs are a bit sparse, but you can use the --help
command to see how to use it; but basically it takes the path of an .apk
or the .ipa
and deploys it to the device you specify.
npm i -g native-run
native-run ios --app <path_to_ipa_file> --target <device_id>