-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat(app): add capacitor support, fixes #4388 #4475
Feat(app): add capacitor support, fixes #4388 #4475
Conversation
…feat(app)--add-capacitor-support
Hi Noah, Excellent work! Few things:
|
|
Cant' you use "src-capacitor" as root, calling capacitor commands using appPaths.capacitor as cwd @nklayman ? |
About the execution of locally installed capacitor, can't you use something like what Electron is doing: https://github.com/quasarframework/quasar/blob/dev/app/lib/electron/index.js#L161 ? |
@lucasfernog using |
I added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On MacOS
yarn cap add ios
=>
[error] cocoapods is not installed. For information: https://guides.cocoapods.org/using/getting-started.html#installation
Cocoapods requires ruby. Installed with:
brew install ruby
Ruby brings these deps:
==> Installing dependencies for ruby: libyaml, openssl and readline
CocoaPods installed with:
sudo gem install cocoapods
CocoaPods brings these deps:
thread_safe, tzinfo, concurrent-ruby, i18n, activesupport, nap, fuzzy_match, cocoapods-core, claide, cocoapods-deintegrate, cocoapods-downloader, cocoapods-plugins, cocoapods-search, cocoapods-stats, netrc, cocoapods-trunk, cocoapods-try, molinillo, atomos, CFPropertyList, colored2, nanaimo, xcodeproj, escape, fourflusher, gh_inspector, ruby-macho
After installing all deps and rerunning the cmd, this is the error:
[error] Capacitor could not find the web assets directory "/[redacted]/capacitor-quasar/dist/capacitor".
So I then run:
quasar build -m capacitor --target ios
Which does create the assets, but still throws an error:
[error] ios" platform has not been created. Use "npx cap add ios" to add the platform project.
So then I run yarn cap add ios
and this works now.
It spends a bit of time (in my case still running the update loop after more than 15 minutes...) to update iOS native dependencies. Unfortunately this is all I see:
Updating iOS native dependencies with "pod install" (may take several minutes)
So there is ZERO information about what is being installed on my system, whether the cmd has hung etc. This is a little worrisome from a security standpoint, because I had to install cocoapods with sudo. Maybe it will tell me what it did at the end of its loop (if it ends)...
Will report back when it finally finishes. Note - I have not yet had the opportunity to run quasar dev -m capacitor --target ios
I stopped waiting and cancelled. Now, regardless of whether I try dev
or build
it hangs at Updating iOS native dependencies.
So I cd into ios/App
and run $ pod install
It is downloading a really MASSIVE spec (ca 750MB) from here:
https://github.com/CocoaPods/Specs.git
CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. It has over 63 thousand libraries and is used in over 3 million apps. CocoaPods can help you scale your projects elegantly.
See this about saving time and storage:
http://blog.cocoapods.org/CocoaPods-1.7.2/
It did finally spawn xcode, but the xcode build failed on both dev and build. Can't triage at the moment.
@nklayman About the src-capacitor issue, would this work? ionic-team/capacitor#691 (comment) Sorry i don't know much about it beucase i never used Capacitor, i'm just blindly searching for a solution. |
I'm testing this and I found that And we need to add the platform automatically when using |
The default Android Studio path from Capacitor is not the one I have on my Arch Linux machine.. should we try to read it for users, and change the capacitor.config.json with it? |
app/lib/capacitor/index.js
Outdated
} | ||
} | ||
await this.__runCapacitorCommand(['open', cfg.ctx.targetName]) | ||
if (!/^192/.test(url)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is not always true.. Quasar picked up my local network IP as url... I dont know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rstoenescu what is the best way to test if the Quasar dev server url is on the network or just a localhost url?
I think we can use our own templates for the android/ and ios/ folders... it would be SUPER COOL, it would be nice to use lodash templates and get rid of the cleartext validation |
Android worked easily on an emulator (already had Android installed)... Amazing job @nklayman !! |
@nothingismagick the cocoapods issue is with capacitor (ionic-team/capacitor#626 (comment)). You could open an issue on their repo to provide more helpful output when running the command. Not much I can do since I don't have a Mac. @lucasfernog I made pr on capacitor to fix the npm-client prompt issue, since I added support for yarn to capacitor in the first place. It was already merged, and should be part of the next release. What do you mean by "using your own template for |
The contents that gets copied to /android is inside capacitor/android-template... can we use a custom one? It would be cool |
@lucasfernog You probably could. Instead of running |
Maybe we should have one template of our own.. so we can set it up in a better way |
At that point we might as well make quapacitor |
@nklayman Great job!! You can use "npx cap add ios --verbose" to see what's going on.. |
@nklayman Please tell me if you need any help |
@eladcandroid or anyone else, can you try using a capacitor/cordova plugin? Make sure to pull the latest version and create a new project. |
@eladcandroid - we'd love some help putting together the docs for this as your time permits. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add a _gitignore
file to templates/capacitor with that content
@@ -81,6 +81,8 @@ class Mode { | |||
], | |||
appPaths.capacitorDir | |||
) | |||
// Add copied package.json to .gitignore as it is auto-generated | |||
fse.writeFileSync(appPaths.resolve.capacitor('.gitignore'), 'package.json') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be part of the template/capacitor directory?
@nklayman I've followed your instructions to test the repo on mac, and got this message: |
@eladcandroid I forgot to mention that you need to switch branches before linking. Run |
@nklayman |
@eladcandroid can you try using a plugin on IOS? If that works, then we can merge this. |
Plugins work great out of the box! Here's a screenshot using Device.getInfo() capacitor plugin <template>
<q-page class="flex flex-center">
<q-list bordered separator>
<q-item v-for="(value, key) in info" :key="key" clickable v-ripple>
<q-item-section>
<q-item-label>{{ key }}</q-item-label>
<q-item-label caption>{{ value }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-page>
</template>
<style></style>
<script>
import { Plugins } from "@capacitor/core";
const { Device } = Plugins;
export default {
name: "PageIndex",
data() {
return {
info: {}
};
},
async mounted() {
this.info = await Device.getInfo();
}
};
</script>
|
@nklayman Any additional tasks for me? 👻 |
Although Capacitor is not currently compatible with some Cordova plugins. |
@nklayman Do you need any help to finish with PR? |
Right now I am just waiting on review from razvan. He is extremely busy, but he should get a chance soon. If you are not deploying your app to production now you can use the fork to develop your capacitor app, and then once this gets merged you can switch off the fork and deploy your capacitor app. |
Hello people! I do have a cordova app in production and, uol... It would be GREAT to use capacitor. I do use some plugins: For firebase (notifications and analytics) Would it be compatible? |
If the plugins are compatible with capacitor they should work just fine. I know camera will work, but I'm not sure about firebase, is it a cordova or capacitor plugin? Your app will be "hybrid", meaning it is a native app, but all of your code will run in a webview. |
Lol, the name |
…ramework#4475) * feat(app): add support for building with Capacitor * feat(app/capacitor): add dev support * fix(app/capacitor): support yarn workspaces * fix(app/capacitor): fix dev server host location detection * feat(app/capacitor): use src-capacitor dir * fix(app/capacitor): copy package.json on build/dev * fix(app/mode): crashes if add/remove function returns null * feat(app/capacitor): require at least one platform to be added * feat(app/capacitor): automatically install platform if missing * fix(app/capacitor): rm proper dir on remove * feat(app/capacitor): add generated package.json to .gitignore * feat(docs): add instructions for using capacitor * feat(app/dev): support async mode add * docs(cli/developing-cordova-apps): remove old folder * docs(cli/developing-capacitor-apps): rename folder
What kind of change does this PR introduce? (check at least one)
Does this PR introduce a breaking change? (check one)
The PR fulfills these requirements:
dev
branch and not themaster
branchfix: #xxx[,#xxx]
, where "xxx" is the issue number)Other information:
Have not tested on mac or windows. To test:
app
, install deps, link withyarn link
quasar create capacitor-quasar
(use yarn), or use existing project (backup first!)yarn link @quasar/app
quasar mode add capacitor
, and choose your platformsquasar dev -m capacitor --target [android|ios]
quasar build -m capacitor --target [android|ios]