omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Xcode Template for Pythonista

    Pythonista
    29
    68
    65706
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mrcoxall
      mrcoxall last edited by

      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

      1 Reply Last reply Reply Quote 0
      • polymerchm
        polymerchm last edited by

        Not that I have tried it, but you might try it as an objective-c project since I believe that's how OMZ wrote pytonista.

        1 Reply Last reply Reply Quote 0
        • omz
          omz last edited by

          @mrcoxall I'm aware of this problem, as it's also been affecting the main Pythonista app for a while. The reason for the error seems to be a server-side change in the way code signatures are verified. In short, iTunes Connect seems to use the file utility to check for executables in the bundle, and it then treats every Python file as an executable that should be signed (which isn't actually possible, as far as I'm aware). Of course, this is pretty much an edge case, as most iOS apps don't contain any scripts.

          In recent betas (when the problem started appearing), I've used a somewhat dirty hack to work around this: The file utility basically uses some heuristics to determine the type of file (text/executable...), and it's possible to trick it into recognizing Python files as something else. There are probably multiple ways to do this – the one I'm using is to prepend files with a line that contains #\input texinfo, which makes file think that it's a TeX document.

          I'm using a script similar to this for automating the process:

          # Change these:
          pylib_path1 = '<something like ".../PythonistaKit.framework/pylib">'
          pylib_path2 = '<something like ".../PythonistaKit.framework/pylib_ext">'
          
          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):
          	with open(file_path, 'r') as f:
          		source = f.read()
          	with open(file_path, 'w') as f:
          		f.write('#\input texinfo\n' + source)
          	is_executable, out = check_is_executable(file_path)
          	return not is_executable
          
          def fix_pylib(pylib_path, dry_run=False):
          	for path, dirs, files in os.walk(pylib_path):
          		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 == '.py' or extension == '.pym' or filename == 'command_template':
          					if dry_run:
          						print '### Executable found: %s' % (filename,)
          					else:
          						print 'Fixing %s...' % (filename,)
          						fixed = fix_executable(full_path)
          						if not fixed:
          							print '### FIXING %s FAILED' % (full_path,)
          						else:
          							print 'Fixed'
          				else:
          					print '### Executable found, but does not seem to be Python code: %s' % (full_path,)
          
          if __name__ == '__main__':
          	fix_pylib(pylib_path1)
          	fix_pylib(pylib_path2)
          
          mrcoxall stepper 3 Replies Last reply Reply Quote 0
          • mrcoxall
            mrcoxall @omz last edited by

            @omz Thanks so much for getting back to me.
            I will give it a try and see what happens.

            By any chance do you have an update to the GitHub repo with the changes already made to the pylib and pylib_ext, so that I do not have to run the scrip and change anything?

            Thanks again, Patrick

            1 Reply Last reply Reply Quote 0
            • polymerchm
              polymerchm last edited by

              Trying to run my app via xcode and the current template. How do you force it to run the Python 3 interpretor?

              1 Reply Last reply Reply Quote 0
              • mrcoxall
                mrcoxall @omz last edited by

                @omz I have used your script and changed all the files in pylib and pylib_ext. I even placed the header at the top of the files in "scripts". It still compiles OK to simulator and devices but I am still getting a code signing error.

                error screenshot

                Any ideas?
                Here is my fork with the fix: https://github.com/Mr-Coxall/PythonistaAppTemplate

                1 Reply Last reply Reply Quote 0
                • omz
                  omz last edited by

                  @mrcoxall It looks like you're submitting the app directly from the Xcode organizer? Try exporting the archive first ("for App Store deployment"), and then submit it using the Application Loader tool (right-click Xcode in Dock -> Open Developer Tool...). Not sure if this will actually fix the error, but I've seen similar problems in the past that only happened with Xcode, and not with Application Loader.

                  mrcoxall marcus67 2 Replies Last reply Reply Quote 0
                  • polymerchm
                    polymerchm last edited by

                    @omz Based on my experiments, am I correct in assuming that the template only has the 2.7 interpretor? Any hope the the 3.5/3.6 template will be forthcoming? I am learning swift just in case.

                    1 Reply Last reply Reply Quote 1
                    • mrcoxall
                      mrcoxall @omz last edited by

                      @omz I tried as you suggest and used the Application Loader. Same problem happening. Still getting code signing errors. Have tried using "Auto code signing" and even old school downloading the certificate myself and still getting the same messages.
                      Have you been able to get anything uploaded to the App Store?
                      Do you have a template that I could try?

                      Thanks

                      1 Reply Last reply Reply Quote 0
                      • mrcoxall
                        mrcoxall last edited by

                        Wondering if anyone has been able to submit an app successfully since Jan 1, 2017.
                        I still am getting signing errors and have no workaround that will work.
                        I have app waiting to get approved and need a solution.

                        Thanks

                        1 Reply Last reply Reply Quote 0
                        • JonB
                          JonB last edited by

                          Have you tried the recommendations here?
                          http://stackoverflow.com/questions/39889093/itunes-software-service-authentication-error-domain-error-434

                          1 Reply Last reply Reply Quote 0
                          • kyelewis
                            kyelewis last edited by

                            I know this is an older thread, but I just wanted to confirm that with the texinfo fix, I have successfully submitted and had an app approved in the last few days.

                            So the fix is required to get past the automatic filter, but submission is OK with the workaround.

                            1 Reply Last reply Reply Quote 1
                            • marcus67
                              marcus67 @omz last edited by

                              @omz Getting back to the question of @polymerchm : Is it possible to run python3 in Xcode? Using a she-bang line like "#! python3" does not work. sys.version still returns "2.7.5 (default, Feb 15 2016, 15:15:36)". Thanks!

                              1 Reply Last reply Reply Quote 0
                              • omz
                                omz last edited by

                                @marcus67 It's currently not possible, I'm afraid.

                                1 Reply Last reply Reply Quote 0
                                • mrcoxall
                                  mrcoxall last edited by

                                  @omz Thanks for getting back to me.

                                  I was wondering if there is any explanation on why it is no longer possible?
                                  I used Pythonista last year with my grade 11 programming course and got over a dozen apps published on the App Store. I have just started using it again with this years group and told them we will be doing the same thing. If there is anything I can do to help the process along, please let me know. We will not be starting to write the final apps until December.

                                  Thanks

                                  1 Reply Last reply Reply Quote 0
                                  • JonB
                                    JonB last edited by

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • JonB
                                      JonB last edited by

                                      @mrcoxall Did youthe texinfo trick? Sounds like @kyelewis got something submitted in january or february.

                                      TheRealBret 1 Reply Last reply Reply Quote 0
                                      • TheRealBret
                                        TheRealBret @JonB last edited by

                                        @JonB The texinfo trick continues to work. Had an app accepted just last week.

                                        1 Reply Last reply Reply Quote 0
                                        • ccc
                                          ccc last edited by ccc

                                          Would it be possible to create a repo or a page on Pythonista-Tools that could be a FAQ for using the template? It seems like there are several prereqs and then several steps to complete the process and it would be great to have a landing page for sharing all that tribal knowledge.

                                          1 Reply Last reply Reply Quote 0
                                          • TheRealBret
                                            TheRealBret last edited by

                                            I spoke too soon. I had to upgrade Xcode because of iOS11 compatibility, and now I'm back to getting the code signing errors for all the .py files, even if they have the texinfo header. Building apps for local distribution works fine, I just can't sign the code as part of the validation process for the App Store.

                                            TheRealBret 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors