Xcode Template for Pythonista
-
I am trying to upload a Pythonista project to the Apple App Store.
I have tried many, many time and keep getting code signing errors.
I am using Xcode 8.2.1
So this is what I have done:Started with new Xcode Swift single view project, archived it and was able to submit it to the App Store. So my certificates are all working. I downloaded the Xcode template and then archived it. When I submit to Apple, it hangs on the code signing for a really long time and then comes back with this error:
ERROR ITMS-90035: "Invalid Signature. Code object is not signed at all. Make sure you have signed your application with a distribution certificate, not an ad hoc certificate or a development certificate. Verify that the code signing settings in Xcode are correct at the target level (which override any values at the project level). Additionally, make sure the bundle you are uploading was built using a Release target in Xcode, not a Simulator target. If you are certain your code signing settings are correct, choose "Clean All" in Xcode, delete the "build" directory in the Finder, and rebuild your release target. For more information, please consult https://developer.apple.com/library/ios/documentation/Security/Conceptual/CodeSigningGuide/Introduction/Introduction.html"
The only thing I can figure out is that it seems to be trying to code sign the PythonistaKit.framework and does not seem to be able to. I can see "PythonistaKit.framework (0 Entitlements), just before I validate it.
Wondering if anyone else is able to reproduce this error, or even better have a fix to the problem.
Thanks
-
@RomSpy Yes, that's something I'd really like to do soon, and I've already done some of the work required, but it's still kind of a mess.
-
Is there an up-to-date summary of the idea for packaging up a Pythonista project to make an app? I see that the template linked from
https://forum.omz-software.com/topic/1911/new-xcode-template-beta
doesn't exist anymore, and I'm not sure where to begin learning.
-
@sreyemnayr I tried your re-worked script and it worked well.
I used#import pythonista\n
rather than#\input texinfo\n
To make it run faster I prepend 10 strings in each iteration, e.g.f.write("#import pythonista\n" * 10 + source)
and set counter to increment by 10.
-
Hello everyone,
Here is a reworked script that adds the comments at the top but preservers coding= comments.
It is not perfect, but it helped me succesfully submit an app to the Appstore, I hope it is of help to every one.#import pythonista # Change the ********** to point to the directory containing the Pythonista framework : project_path = '**********/PythonistaAppTemplate' pylib_path1 = '%s/PythonistaKit.framework/pylib' % project_path pylib_path2 = '%s/PythonistaKit.framework/pylib_ext' % project_path MAX_REPEATS = 10 import shutil import os import subprocess def check_is_executable(file_path): file_output = subprocess.check_output(['file', file_path]) if 'executable' in file_output: return True, file_output return False, file_output def fix_executable(file_path, dry_run=False): with open(file_path, 'r') as f: source = f.readlines() if 'coding:' in source[0].lower(): firstline = source[0] start = 1 else: firstline = '' start = 0 if dry_run: if firstline: print(firstline) else: with open(file_path, 'w') as f: f.write(firstline + '#import pythonista\n' * MAX_REPEATS + ''.join(source[start:])) is_executable, out = check_is_executable(file_path) return not is_executable def fix_pylib(pylib_path, dry_run=False): print ("fixing", pylib_path) for path, dirs, files in os.walk(pylib_path): print(path, dirs, files) for filename in files: full_path = full_path = os.path.join(path, filename) is_executable, file_output = check_is_executable(full_path) if is_executable: extension = os.path.splitext(full_path)[1].lower() if extension in ['.py', '.pym'] or filename == 'command_template': if dry_run: print '### Executable found: %s' % (filename,) fixed = fix_executable(full_path, dry_run) else: print 'Fixing %s...' % (filename,) fixed = False counter = 0 while not fixed: fixed = fix_executable(full_path) counter += MAX_REPEATS print 'Fixed with '+str(counter)+' dummy lines.' else: print '### Executable found, but does not seem to be Python code: %s' % (full_path,) if __name__ == '__main__': fix_pylib(pylib_path1, False) fix_pylib(pylib_path2, False)
Cheers
Andre
-
so, this may be a stupid question, but my understanding of this problem is that
file
is running locally, and is getting rejected locally.so, why not just edit /usr/share/file/magic (or copy it, edit it, then file -C to compile it to a new .mgc), or create an alias to file with a -m argument pointing to your custom magic file. It should be possible to edit the entry for pythonm or add custom search for the shebang or coding lines, to simply output a safe mimetype,
-
Hi Jon,
I think that is a very good question and a very interesting option to explore as it would avoid modifying the framework. I'll look into it as soon as I get a chance and report my findings back.
Cheers
Andre
-
I really want to have a new Xcode template for Pythonista 3. I realize that I've already bought Pythonista so I'm not generating new income for @omz.... so I hereby pledge to send money via Paypal/Zelle (or any other method) to @omz to help support his time for the production of a new Xcode template. I'd gladly pay $25 for a new template. I'd even pay this annually if it would be updated regularly.
Thoughts anyone? @omz?? How can we help get a new Xcode template made?
-
@TheRealBret Good news!
@omz said:Here's a first attempt at a Python 3-based Xcode template: https://www.dropbox.com/s/5l94m0xjbot5je0/Pythonista3AppTemplate.zip?dl=1
This is roughly equivalent to the current App Store version (not the 3.3 beta), and not final, just something to play around with for people interested in the Xcode template. Let me know if anything's unclear.
-
Indeed - I’m very happy to see the new template. Thank you!
My offer still stands - I would like a way to give a donation to @omz to help offset continued development of Pythonista. I can’t see how my payment a year ago is helping today.
-
Is it possible for someone to upload a version of the template for python3 with the fix to include the line at the top of all the files already done? I am having lots of trouble doing it myself.
-
Any update on the template? As of April 2020 the template is completely broken since it uses the deprecated
UIWebView
API which is not allowed anymore: https://forum.omz-software.com/topic/6474/python3-xcode-template-broken-because-of-deprecated-uiwebview
-
Is the binary signed in some way? I wonder if you were to edit it in a hex editor, and replace UIWebView with some other nonsense class name (same number of characters).
Since objc is message based, there is nothing linked to support UIWebView, just a runtime call with a c string with the classname. As long as you never instantiate a webview, things won't crash.
-
This post is deleted!last edited by
-
This post is deleted!last edited by eliotradisa
-
@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.
-
@coltonboyd, thanks for sharing, this is great news. I am (again) tempted to put something to the App Store.
-
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 It might be good if you could document the various steps you went through from start to end -- for instance did you have to do the workaround so
file
doesn't flag .py files as executable? Anything else you had to modify from the template?
-
@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 said:
Thanks! But it seems that you upload version with WKWebView. I changed that to UIBarItem and it worked