You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We will need to do CI/Cloud builds for apps in Ionic, should we support running xcodebuild/gradle easily from the CLI?
npx cap build
Reacted by Wils, Sergii Lavrin, ForeverScape, Matt Kunze, jase, dymo, Jorge Sanz Pérez, Quang Anh Le, Dante , Benoit Rospars and 73 more
Reacted by Patrick Wespi, Nathan Argetsinger, AndreasGassmann, Daniel Ehrhardt, hiepxanh, Gustavo, Nico Lueg, Josua Zurbrügg, ThisNameWasTaken, Dennis Ameling and 6 more
fastlane has very good build support for both Android and iOS - maybe this could be an alternative? (With build come profiles, certificates, output paths...)
Reacted by jase, kwilliams-curago, Denis Roldán, Wils, Patrick, Michael, Franco Gilio, Ronny Roeller, Richard Chamorro, Robson Oliveira dos Santos and 8 more
Reacted by kwilliams-curago, Denis Roldán, Julian Alimin, Clément and Nico Lueg
Major showstopper for us as we've almost never had to open/use any IDE, having a well functioning build/release setup/process via command line.
Reacted by dymo, Michael, Steven Roussey, L J Ribar, Robson Oliveira dos Santos, Gianpaolo Macario, Malte Legenhausen, Robin Genz, Jun Reiderdai, Nicolas Toublanc and 16 more
Hi, I've tried the steps above for Android, it did generate the expected .apk file however if fails when I try to install in the device.
This is the error message that I got from logcat: com.google.android.packageinstaller/com.android.packageinstaller.InstallFailed (has extras)
Hola @jcesarmobile, thank you for the feedback.
Yes, I did run from the ios/App folder.
From the ios/App:
✗ pod install
Ignoring nokogiri-1.8.4 because its extensions are not built. Try: gem pristine nokogiri --version 1.8.4
Ignoring unf_ext-0.0.7.5 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.5
Analyzing dependencies
Fetching podspec for Capacitor from ../../node_modules/@capacitor/ios
Fetching podspec for CapacitorCordova from ../../node_modules/@capacitor/ios
Fetching podspec for CordovaPlugins from ../capacitor-cordova-ios-plugins
Downloading dependencies
Using Capacitor (1.0.0-beta.7)
Using CapacitorCordova (1.0.0-beta.7)
Using CordovaPlugins (1.0.0-beta.11)
Using GCDWebServer (3.4.2)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 3 dependencies from the Podfile and 4 total pods installed.
AppDelegate.swift:2:8: error: no such module 'Capacitor'
import Capacitor
^
** ARCHIVE FAILED **
The following build commands failed:
CompileSwift normal armv7 /Users/wils/_work/projects/prototype01/ios/App/App/AppDelegate.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
CompileSwift normal arm64 /Users/wils/_work/projects/prototype01/ios/App/App/AppDelegate.swift
(3 failures)
consider using @bazelbuild to compile for ios, android and electron
it would be better to centralize everything in a single tool instead of worrying about Gradle and CocoaPods
Reacted by dymo, Luis David, Marek Lukáš, MF Codeworks, Colum Ferry, David Martín Lozano and Gabriel Sperrer
I have created a pull request #4403 to make the open of the development IDE optional. This will help using ionic capacitor from the CLI, especially when you what to use the --livereload option.
Currently, if you what to use live reload from the CLI. You can not use the ionic capacitor run <platform> --livereload command, because it will always start the corresponding IDE. So you have to write custom scripts that will update the capacitor.config.json file with the correct information needed for live reload to work. The pull request can make this use case simpler.
The pull request #4403 has just been merged. As of version 6.7.0 of the Ionic CLI, you can use the --no-open option for the ionic capacitor run and ionic capacitor build command.
What docs are you referring to?
Capacitor docs don't tell you to use Cordova anywhere.
Capacitor doesn't support building from the CLI at the moment, you have to use gradle on Android or xcodebuild on iOS (or some multi platform tool such as fastlane)
Capacitor should primary build on CLI (e.g. Android SDK Tools, without Android Studio IDE). The current behavior is not CI friendly. Not even for humans. Why? 😢 It's a pain. I read something about Capacitor is not for release builds. Oo Then what is it for? It sounds like a joke.
Reacted by Christoph, Saninn Salas Diaz, Aleksei Prokopov, Gabriel Horatiu Petchesi and Anton Gillert
Let's keep things constructive in accordance with our Code of Conduct.
Then what is it for?
Capacitor is first and foremost a cross-platform native runtime for web apps. The primary purpose is to provide a translation layer from web app to native platform. One of the philosophical differences between Capacitor and Cordova is that Capacitor doesn't try to abstract away the native platforms, it embraces them. The platforms in Capacitor projects are true native projects and considered source artifacts, not build artifacts. They're as much a part of your app as the JS you write.
You're encouraged to use Gradle for Android and xcodebuild for iOS in the command-line and CI environments because they're the official tools provided by Android and iOS. Third-party tools such as Fastlane may make this easier. Fastlane has been around much longer than Capacitor and has 20+ members on its core team alone. It's better if Capacitor focuses on its unique strengths instead of reinventing the wheel.
Could we document this better? Absolutely. Capacitor is just getting started.
Reacted by Robin Genz, Pablo Maurer, jcesarmobile, Gustavo, Jacob, jwburnside, Martin Foerster, Josua Zurbrügg, Foongit Admin, Shuang Wu and 3 more
I understand your argument, but only partly, even if you say use xcodebuild or gradle, why don't use the Cordova approach and pass the parameters for building down to the nativettools ?
Even java just passes the parameters down to the native build tools for packaging and signing apps with the jpackage tool.
Reacted by dymo, Bala Raman, Valerii Goncharenko, Sonja Leaf and gengns
For Android, it should just work as long as you have Android Studio installed and setup. For Apple, you first have to make sure you have configured your certificates and provisioning profiles accordingly, and then update the export-store-options.plist and export-debug-options.plist files as explained in the README.
When all Android and iOS dependencies are correctly setup, then a CLI build can be started by using the native ionic capacitor commands like:
@Heerschop - where does the build ios or build android output the app binary? Those commands seem to merely build your ionic application and not the binary.
Once the web assets and configuration are copied into your native project, you can build your app using the native IDE. Unfortunately, programmatically building the native project is not yet supported.
I think this is a MUST need feature now with Capacitor 3 CLI hence now we can open the app directly on our device without native tools. And the huge problem we have now is even though we'll build our app with --prod it doesn't reduce the bundle size when we use the Native tools. This is a huge problem right now for us for testing. i.e. first impression is very important here from our clients. i.e. giving high performance and small bundle size app to the client for testing using --prod.
I have asked about it here also but no reply yet? #4754
Reacted by Leonardo Medeiros, Diran Ogunlana, Marek Lukáš and Subhasish Das
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.
Activity
jcesarmobile commentedon Mar 13, 2018
Is the CI something we control? we can configure the CI to build the native project
mlynch commentedon Mar 13, 2018
Yea, but just CI's in general, we could make it easier to build the app from the command line
janpio commentedon Mar 15, 2018
fastlane has very good build support for both Android and iOS - maybe this could be an alternative? (With build come profiles, certificates, output paths...)
zarko-tg commentedon Nov 21, 2018
Major showstopper for us as we've almost never had to open/use any IDE, having a well functioning build/release setup/process via command line.
ptitjes commentedon Nov 21, 2018
@zarko-tg You can do
(cd android/ && ./gradlew assembleRelease)for Android.See for instance:
You can do something like
xcodebuild -scheme App buildfor iOS.But I can't tell exactly as I didn't pay Apple's dime yet.
wilsolutions commentedon Dec 6, 2018
Hi, I've tried the steps above for Android, it did generate the expected .apk file however if fails when I try to install in the device.
This is the error message that I got from logcat:
com.google.android.packageinstaller/com.android.packageinstaller.InstallFailed (has extras)xcodebuild -workspace App.xcworkspace -scheme App clean archive -configuration debug -sdk iphoneos -archivePath App.xcarchiveIt fails with:
AppDelegate.swift:2:8: error: no such module 'Capacitor'Any thoughts about it?
tkx
jcesarmobile commentedon Dec 6, 2018
Did you run it from
ios/App/folder?I just copy/pasted your command in one random Capacitor project and worked fine
You can also try to run
pod installfromios/App/first, but shouldn't be necessary asnpx cap update iosalready run itwilsolutions commentedon Dec 6, 2018
Hola @jcesarmobile, thank you for the feedback.
Yes, I did run from the
ios/Appfolder.From the
ios/App:✗ pod installIgnoring nokogiri-1.8.4 because its extensions are not built. Try: gem pristine nokogiri --version 1.8.4
Ignoring unf_ext-0.0.7.5 because its extensions are not built. Try: gem pristine unf_ext --version 0.0.7.5
Analyzing dependencies
Fetching podspec for
Capacitorfrom../../node_modules/@capacitor/iosFetching podspec for
CapacitorCordovafrom../../node_modules/@capacitor/iosFetching podspec for
CordovaPluginsfrom../capacitor-cordova-ios-pluginsDownloading dependencies
Using Capacitor (1.0.0-beta.7)
Using CapacitorCordova (1.0.0-beta.7)
Using CordovaPlugins (1.0.0-beta.11)
Using GCDWebServer (3.4.2)
Generating Pods project
Integrating client project
Sending stats
Pod installation complete! There are 3 dependencies from the Podfile and 4 total pods installed.
✗ xcodebuild -workspace App.xcworkspace -scheme App clean archive -configuration debug -sdk iphoneos -archivePath App.xcarchiveAppDelegate.swift:2:8: error: no such module 'Capacitor'
import Capacitor
^
** ARCHIVE FAILED **
The following build commands failed:
CompileSwift normal armv7 /Users/wils/_work/projects/prototype01/ios/App/App/AppDelegate.swift
CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
CompileSwift normal arm64 /Users/wils/_work/projects/prototype01/ios/App/App/AppDelegate.swift
(3 failures)
tkx
wilsolutions commentedon Dec 6, 2018
It works!
I have just created a new project and it works!
So, looks likes some discrepancy in my previous project, after reading jcesarmobile message I decided to create a new project and voilà!
tkx
Rodrigo54 commentedon Mar 28, 2019
consider using @bazelbuild to compile for ios, android and electron
it would be better to centralize everything in a single tool instead of worrying about Gradle and CocoaPods
Coly010 commentedon Mar 20, 2020
Heerschop commentedon Apr 26, 2020
I have created a pull request #4403 to make the open of the development IDE optional. This will help using
ionic capacitorfrom the CLI, especially when you what to use the--livereloadoption.Currently, if you what to use live reload from the CLI. You can not use the
ionic capacitor run <platform> --livereloadcommand, because it will always start the corresponding IDE. So you have to write custom scripts that will update thecapacitor.config.jsonfile with the correct information needed for live reload to work. The pull request can make this use case simpler.Heerschop commentedon Apr 30, 2020
The pull request #4403 has just been merged. As of version 6.7.0 of the Ionic CLI, you can use the
--no-openoption for theionic capacitor runandionic capacitor buildcommand.9 remaining items
jcesarmobile commentedon Aug 17, 2020
What docs are you referring to?
Capacitor docs don't tell you to use Cordova anywhere.
Capacitor doesn't support building from the CLI at the moment, you have to use gradle on Android or xcodebuild on iOS (or some multi platform tool such as fastlane)
infacto commentedon Aug 26, 2020
Capacitor should primary build on CLI (e.g. Android SDK Tools, without Android Studio IDE). The current behavior is not CI friendly. Not even for humans. Why? 😢 It's a pain. I read something about Capacitor is not for release builds. Oo Then what is it for? It sounds like a joke.
imhoffd commentedon Aug 26, 2020
Let's keep things constructive in accordance with our Code of Conduct.
Capacitor is first and foremost a cross-platform native runtime for web apps. The primary purpose is to provide a translation layer from web app to native platform. One of the philosophical differences between Capacitor and Cordova is that Capacitor doesn't try to abstract away the native platforms, it embraces them. The platforms in Capacitor projects are true native projects and considered source artifacts, not build artifacts. They're as much a part of your app as the JS you write.
You're encouraged to use Gradle for Android and
xcodebuildfor iOS in the command-line and CI environments because they're the official tools provided by Android and iOS. Third-party tools such as Fastlane may make this easier. Fastlane has been around much longer than Capacitor and has 20+ members on its core team alone. It's better if Capacitor focuses on its unique strengths instead of reinventing the wheel.Could we document this better? Absolutely. Capacitor is just getting started.
Siedlerchr commentedon Sep 8, 2020
I understand your argument, but only partly, even if you say use xcodebuild or gradle, why don't use the Cordova approach and pass the parameters for building down to the nativettools ?
Even java just passes the parameters down to the native build tools for packaging and signing apps with the jpackage tool.
Heerschop commentedon Nov 20, 2020
This Ionic Capacitor example project can be used for building with Capacitor from the CLI. The project uses ionic hooks and script-launcher for enabling this.
For Android, it should just work as long as you have Android Studio installed and setup. For Apple, you first have to make sure you have configured your certificates and provisioning profiles accordingly, and then update the
export-store-options.plistandexport-debug-options.plistfiles as explained in the README.When all Android and iOS dependencies are correctly setup, then a CLI build can be started by using the native ionic capacitor commands like:
Or you can use the menu by executing
npm startto select and start the desired action interactively.npm start ? Select action › - Use arrow-keys. Return to submit. ❯ serve - Builds and serves your app, rebuilding on file changes. build deployHope this will help people to get started using ionic capacitors in a CI / CD environment.
tmk1991 commentedon Jul 1, 2021
@Heerschop - where does the
build iosorbuild androidoutput the app binary? Those commands seem to merely build your ionic application and not the binary.Once the web assets and configuration are copied into your native project, you can build your app using the native IDE. Unfortunately, programmatically building the native project is not yet supported.https://ionicframework.com/docs/cli/commands/capacitor-build
@ptitjes answer above is the correct CLI way to build a native binary.
Sampath-Lokuge commentedon Aug 19, 2021
I think this is a MUST need feature now with Capacitor 3 CLI hence now we can open the app directly on our device without native tools. And the huge problem we have now is even though we'll build our app with
--prodit doesn't reduce the bundle size when we use the Native tools. This is a huge problem right now for us for testing. i.e. first impression is very important here from our clients. i.e. giving high performance and small bundle size app to the client for testing using--prod.I have asked about it here also but no reply yet? #4754
jcesarmobile commentedon Nov 1, 2022
Capacitor 4.4.0 included build command, closing
https://capacitorjs.com/docs/cli/commands/build
ionitron-bot commentedon Dec 1, 2022
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out.