-
coltonboyd
@cvp it’s all good. Your code gave me a good starting place and led me to the code I got so thank you!
-
coltonboyd
For anybody following this thread I figured how to present
SFSafariViewController
from an already presented view:####################################################################### # Necessary imports. from objc_util import * ####################################################################### class WebView(): @on_main_thread def __init__(self,url,uiview,bar_tint_color,control_tint_color): self.safari_view_controller = ObjCClass("SFSafariViewController").alloc().initWithURL_(nsurl(url)) self.safari_view_controller.preferredBarTintColor = bar_tint_color self.safari_view_controller.preferredControlTintColor = control_tint_color self.view_controller = ObjCClass('UIViewController').viewControllerForView_(ObjCInstance(uiview)) @on_main_thread def present(self): self.view_controller.presentViewController_animated_completion_(self.safari_view_controller,True,None)
-
coltonboyd
Also to add, I added the code above to a blank
main.py
file in a blank Xcode project and it worked just fine. I think it has something to do with the Appui.View
that I am presenting. -
coltonboyd
@cvp to clarify I am attempting to run this is the most current Xcode Template. Your code is good starting place but when I tried it was just a blank white screen. The code I am trying to incorporate is:
from objc_util import * SFSafariViewController = ObjCClass('SFSafariViewController') @on_main_thread def open_in_safari_vc(url, tint_color=None): vc = SFSafariViewController.alloc().initWithURL_(nsurl(url)) if tint_color is not None: vc.view().tintColor = tint_color app = UIApplication.sharedApplication() root_vc = app.keyWindow().rootViewController() root_vc.presentViewController_animated_completion_(vc, True, None) vc.release() open_in_safari_vc('http://apple.com', UIColor.orangeColor())
Basically I have an
ui.View
called App that is presented from the point of where the iOS app starts. When clicking on a button view on this App class I want it to open a SFSafariViewController with the designated url given to theopen_in_safari_vc
function.When I attempt this in the Xcode Template I get this error:
[Presentation] Attempt to present <SFSafariViewController: 0x7fbfa7a98000> on <PYAViewController: 0x7fbfa4408e80> (from <PYAViewController: 0x7fbfa4408e80>) whose view is not in the window hierarchy.
I hope this clarifies what I'm trying to do.
-
coltonboyd
I was wondering if any of you that are good with
objc_util
could help me out.I would like to present a
SFSafariViewController
as aui.View
from aui.View
that is already presented.Or be able to add
SFSafariViewController
as a subview for the already presented view.Thx in advance.
-
coltonboyd
Sooo update on this issue. I moved all my external code for google sheet & Twilio messaging into the script file thinking that would solve the issue.
And it didn’t, same error with the same naming convention. All the modules that I need have a lot of init.py files so I wonder if Apple doesn’t allow files with that name specifically or what.
So as a test I took out those files and just tried to upload my Pythonista code and it worked flawlessly. At least I pinpointed exactly what files are causing this error, but it’s sad because those modules are important for the functionality of my app.
-
coltonboyd
@JonB this might be some of my own doing. I wanted to add google sheet api and Twilio messaging support in my app.
I added those files into the site packages and performed the ‘import Pythonista’ trick to all files so that no singing issues would occur.Since these files were apart of the original template, these files my need to exist in the Script folder of the template.
I’m pretty sure when I make this switch everything should be fine.
-
coltonboyd
Hello all,
A few months ago I got a Pythonista 3 App Template to work and uploaded my game to the App Store successfully. Since then I've tried to post another app to the App Store. I get past the validation stage and upload stage just fine but then a few minutes later apple hits me with this error:ITMS-90048: This bundle is invalid - Your archive contains paths that are not allowed: ('init.py')
Has anybody that has downloaded my app template had this problem? Any help would awesome. Thx
-
coltonboyd
@pavlinb There is a Pythonista 3 Xcode Template that you place your code in. You must have a Mac with Xcode installed and have a little bit of knowledge on how to upload apps to the App Store to configure.
-
coltonboyd
@brx thank you for the download!! I’m sorry to hear about the plane not moving for you :/ the game uses the motion module for detecting tilting on a certain axis. It might be something in your settings maybe? Everyone else that has downloaded the game has not had any issues so far.
-
coltonboyd
Hey everybody!
(If you are in the Pythonista app slack and saw this message already, then feel free to ignore this)
I am happy to announce I have uploaded my first ever game to the iOS App Store! (Never thought I would ever say this). The game is called “Flyboy Adventure Game”. And this game was created entirely with python 3 through the Pythonista 3 app on my iPad Mini 5th gen.
I would love as much feedback as possible on how you like the game and if I should maybe invest some time into making another game! The complete source code and assets for the game are listed on the developer site link(Github) through the App Store if you would like to learn how I made it. Also there is a link through the developer site for an updated Pythonista 3 template that will not error when going through App Store review.
I decided a price of .99 cents due to my own hatred of iOS game ads. So hopefully this will not discourage you guys from trying it out. Any and all support would be much appreciated!
Here is the link to the game:
https://apps.apple.com/us/app/flyboy-adventure-game/id1531792355
-
coltonboyd
@Ichicoro lol I hate myself. This should work, let me know if it doesn’t.
https://www.dropbox.com/s/nq899u5gv54o5t8/Pythonista3AppTemplate Updated .zip?dl=0
-
coltonboyd
To anybody that needs it, here is the correct and updated Pythonista 3 Template:
https://www.dropbox.com/h?preview=Pythonista3AppTemplate+Updated+.zip
-
coltonboyd
@vovaburm oops I must have uploaded the wrong version then off my desktop, my bad! I’m glad you got it to work!
-
coltonboyd
@JonB I’m glad you mentioned that. I forgot to inform that to get past signing errors I used @RomSpy ’s last template he posted from this forum link:
https://forum.omz-software.com/topic/5837/xcode-template
After getting past the signing errors is when I started getting the UIWebView deprecated rejections from Apple. That is when I stumbled upon this forum post and tried out your idea of downloading the hex editor, etc. I first tried replacing UIWebView with WKWebView like Apple suggested, but it ended up crashing my app after launch. Replacing it with UIBarItem had no effect.
Here is my latest version of the Pythonista 3 App Template that I used for my game I’m currently publishing to the App Store as we speak.
https://www.dropbox.com/s/442v3cp90oyk8rd/Pythonista3AppTemplate Updated .zip?dl=0
-
coltonboyd
Of course, just for reference the Hex editor I used was SlickEditPro2019. You can download a free trial and it’s pretty easy to use.
I’m currently trying to upload a updated Pythonista 3 Template to my Dropbox but it’s taking forever.
-
coltonboyd
@ruohola sorry this is a little late and I hope this information is still relevant for you. I took @JonB 's advice and went into the P3kit framework and edited the P3kit file. For me it popped up as a unix executable, so I needed to download a hex editor to go in and modify it.
All I did was command-F and find all the instances of UIWebView and replace them all with UIBarItem. This is an API with the same character length and the API isn't deprecated. Save the file and make sure it is still in your project directory.
I archived and uploaded my build last night and the App Store did not reject the build. so this is a good working solution. My app is a 2D shooting game called Flyboy Adventure Game and it is currently under beta review as we speak. I've tested my game on Testflight and it works great, so hopefully there is no long term repercussions from using this workaround.