โŒ

Normal view

There are new articles available, click to refresh the page.
Before yesterdayMain stream

How to save file with Capacitor on iOS?

I have the following code (adapted from this tutorial) that I use for saving files from backend:

import { FilesystemDirectory, Plugins } from '@capacitor/core';
const { Filesystem } = Plugins;

await Filesystem.writeFile({
    path: "filename.txt",
    data: "base64 data",
    directory: FilesystemDirectory.Documents,
  });

This codes works fine on Android, even creates the Documents directory in the root of internal storage. Unfortunately, on iOS no file is created, no mater what directory I use (I've tested it with Documents, Data and ExternalStorage). When I put this code block inside try..catch, nothing is thrown, so the operation is supposedly completed successfully, just no file is saved. Tested on one Android device and two iOS.

Build Mobile Application with Quasar and Capacitor

I am trying to generate an apk for my app built with quasar, but it still runs on localhost when the apk has been installed on a mobile device.

Steps I've tried

  • generate Apk from Android Studio as debug
  • generate Apk from Android Studio as release
  • edited the quasar.conf.js file to change the host and port
  • invalidate caches multiple times
  • clean project and rebuild none have worked

when i run from the terminal

quasar build -m capacitor -T android

this is the error I get

> Task :app:dexBuilderRelease FAILED

FAILURE: Build failed with an exception.

I just want my apk to run like a mobile application independent of the local dev server.

quasar.conf.js

    build: {
      vueRouterMode: "hash",
    devServer: {
      open: false,
    },

capacitor.conf.js

{
  "appId": "org.capacitor.appname.app",
  "appName": "appname",
  "bundledWebRuntime": false,
  "npmClient": "npm",
  "webDir": "www"
}

Why can't I 'fetch' some URLs from my Capacitor app on Android?

I'm trying to write a mobile app via Capacitor that makes use of PouchDB. When I run the app in the emulator via Android Studio the connection to the remote CouchDB instance fails. I've tracked this down to a failure in the fetch API for certain URLs when running on Android.

To debug I made a minimal web application and wrapped it using Capacitor to run on Android. The app includes the following code

const testFetch = (url) => {
    console.log("Testing fetch", url)
    fetch(url)
        .then((response) => response.text())
        .then((t) => {
            console.log("Respose from fetch:", url)
            console.log(t)
            console.log("that was it")
        })
        .catch((reason) => {
            console.log("FETCH FAILED", url, reason)
        })
}

I then have three tests:

  testFetch("https://jsonplaceholder.typicode.com/todos/1");   // just some JSON 
  testFetch("http://10.0.2.2:5984/simple");    // local pouchdb instance 
  testFetch("http://10.0.2.2:8080/sample.json");  // local http server + CORS 

The second two use the IP address that is an alias for the development machine when running in the Android emulator. I confirmed that I can access all of these URLs from the browser on the emulator but the app succeeds on the first and fails on the second two (error: TypeError: Failed to fetch). When running the base web app in the browser, all succeed (with localhost instead of 10.0.2.2).

CORS headers are in place on all URLs. As far as I can see the app doesn't even try to access the two servers that fail - no HEAD requests for example. I've also tried various other URLs and can't see a pattern to the failures -- eg. it's not the port number != 80.

Any clues as to what is going on would be appreciated.

Run custom shell script '[CP] Embed Pods Frameworks'

i am maintaining a capacitor ionic project supporting both iOS and android platform. I can build the project locally and run it on a device without any issue. But when archiving the following error pops up:

PhaseScriptExecution [CP]\ Embed\ Pods\ Frameworks 
/Users/fabus/Library/Developer/Xcode/DerivedData/App-
gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveInter
mediates/App/IntermediateBuildFilesPath/App.build/Release-
iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh (in target 
'App' from project 'App')     cd 
/Users/fabus/Development/showmaker/showmaker_festivals/ios/App     
/bin/sh -c /Users/fabus/Library/Developer/Xcode/DerivedData/App-
gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveInter
mediates/App/IntermediateBuildFilesPath/App.build/Release-
iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh
mkdir -p /Users/fabus/Library/Developer/Xcode/DerivedData/App-
gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveInter
mediates/App/BuildProductsPath/Release-iphoneos/App.app/Frameworks 
Symlinked... rsync --delete -av --filter P .*.?????? --links --filter 
"- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --
filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" 
"../../../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Cap
acitor.framework" 
"/Users/fabus/Library/Developer/Xcode/DerivedData/App-
gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveInter
mediates/App/InstallationBuildProductsLocation/Applications/App.app/F
rameworks" building file list ... rsync: link_stat 
"/Users/fabus/Development/showmaker/showmaker_festivals/ios/App/../..
/../IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Capacitor
.framework" failed: No such file or directory (2) done
sent 29 bytes  received 20 bytes  98.00 bytes/sec total size is 0 
 speedup is 0.00 rsync error: some files could not be transferred 
(code 23) at /AppleInternal/Library/BuildRoots/97f6331a-ba75-11ed-
a4bc-
863efbbaf80d/Library/Caches/com.apple.xbs/Sources/rsync/rsync/main.c(
996) [sender=2.6.9] Command PhaseScriptExecution failed with a 
nonzero exit code

I am using following pods:

  pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'

  pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'

  pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'

  pod 'CapacitorBrowser', :path => '../../node_modules/@capacitor/browser'

  pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'

  pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'

  pod 'CapacitorNetwork', :path => '../../node_modules/@capacitor/network'

  pod 'CapacitorPushNotifications', :path => '../../node_modules/@capacitor/push-notifications'

  pod 'CapacitorSplashScreen', :path => '../../node_modules/@capacitor/splash-screen'

  pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'

  pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'

  pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'

I already desintegrated/updated pods in my ios folder. Cleaned the Build folder shift-command-k. Further there's no special chars or whitespaces in my project name and I did renew all my certificates / load them into xcode. Restarting machine does not solve it either.

What I did as well, was checking the option "For install build only" in my Build phases (Targets > App > Build phases) as suggested here

I haven't touched my build files (capacitor.config, package.json, ...) lately

Update:

Executing the command by hand produces following ouput:

/Users/fabus/Library/Developer/Xcode/DerivedData/App-gkhellzebxgrxeeuozvkjsnejnul/Build/Intermediates.noindex/ArchiveIntermediates/App/IntermediateBuildFilesPath/App.build/Release-iphoneos/App.build/Script-9592DBEFFC6D2A0C8D5DEB22.sh: line 2: /Target Support Files/Pods-App/Pods-App-frameworks.sh: No such file or directory
โŒ
โŒ