Forum Archive

appex loads code from icloud

oliep

As far as I understand it is not possible to run an appex that lives inside the icloud folder. So I came to the idea of having a tiny appex wrapper script local that loads the main program from the icloud folder. The following code kinda works (not really):

sys.path.append('/privat/var/mobile/Library/Mobile Documents/iCloud~com~omz~software~Pythonista3')
from Documents import TheMainCode
TheMainCode.doSomething()

But it has some nasty side effects. For example changing anything in the icloud file only has effect on the iOS device after a complete restart. And some variables seem to survive subsequent calls. Can someone please help me to understand what's happening here and if there is a working way of programmatically importing code from icloud?

cvp

@oliep if via share/Pythonista3/edit scripts you don't receive this

It will appear in next version (I've the beta, thus no more able to test App Store version)

cvp

@oliep was a bug in actual version see here

cvp

@oliep If you want to share text to a Pythonista script, even on iCloud, you could write a shortcut in the IOS Shortcuts app which will be shared and will receive as "Shortcut input" the shared text.
Your shortcut could then open url pythonista://your script.py?action=run&root=icloud&args=ShortcutInput Magic variable.

See shortcut

Of course, instead of sharing to Pythonista, you will have to share to your shortcut.
That's while waiting for the new version of Pythonista.

oliep

@cvp Perfect! Thanks a lot!

cvp

@oliep sadly, this solution does not work for a file sharing, only for text sharing

oliep

@cvp Oh yeah. I've just figured that. To bad. The bug/missing feature in workflow is already a year old. Bummer. Let's hope for the best.

cvp

@oliep The beta version contains the feature, if you need it urgently, ask @omz to be part of the test.

JonB

The beta signup link is
https://testflight.apple.com/join/qDkBu2ur