kivy / kivy-ios

Toolchain for compiling Python / Kivy / other libraries for iOS
https://kivy.org/docs/guide/packaging-ios.html
MIT License
779 stars 240 forks source link

Non-public API usage - The app references non-public symbols: _ffi_* #572

Closed jda5 closed 3 years ago

jda5 commented 3 years ago

Versions

Describe the bug

My app runs fine on the simulators and on a device, but when I archive the project and distribute it to App Store Connect I receive an email from Apple saying that my app has been rejected. The email reads:

ITMS-90338: Non-public API usage - The app references non-public symbols in ccc-graphs-12: _ffi_call, _ffi_closure_alloc, _ffi_closure_free, _ffi_prep_cif, _ffi_prep_closure_loc, _ffi_type_double, _ffi_type_float, _ffi_type_pointer, _ffi_type_sint16, _ffi_type_sint32, _ffi_type_sint64, _ffi_type_sint8, _ffi_type_uint16, _ffi_type_uint32, _ffi_type_uint64, _ffi_type_uint8, _ffi_type_void. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed. For further information, visit the Technical Support Information at http://developer.apple.com/support/technical/

To Reproduce

  1. Install the toolchain and create an Xcode project.
  2. In the Xcode project: Build Phases --> Run Script add "-O --no-perms"
  3. Resolve warnings (use Xcode recommended updates). This includes changing the architecture to "Standard architecture" and migrating deprecated languages -- NOTE. This step is not necessary! The exact same issue is reproduced without this step.
  4. Add an icon image set to app.
  5. In Signings & Capabilities configure the Team and Bundle Identifier.
  6. In Sources --> main.m change #include "Python.h" to an absolute path, i.e. "/path/to/kivy-ios/dist/root/python3/include/python3.8/Python.h" as is explained here.
  7. In the <yourapp>-Info.plist file specify why you need the camera or that you don't use it, as is explained here.
  8. In General select "Requires full screen"

At this point, the project should be ready to upload. Build for "Any iOS Device" and click on Products --> Archive. After going through all the steps in the archive window, I am shown a message saying that the upload has been successful. This is shortly followed by the aforementioned rejection email.

Logs

No logs provided. However, the following may be of use:

Running toolchain status returns:

audiostream  - Not built
click        - Not built
curly        - Not built
cymunk       - Not built
distribute   - Not built
ffmpeg       - Not built
ffpyplayer   - Not built
flask        - Not built
freetype     - Build OK (built at 2020-12-09 20:02:24.391901)
host_setuptools - Not built
host_setuptools3 - Build OK (built at 2020-12-09 20:15:39.468316)
hostlibffi   - Build OK (built at 2020-12-09 20:02:48.271488)
hostopenssl  - Build OK (built at 2020-12-09 20:04:16.254736)
hostpython3  - Build OK (built at 2020-12-09 20:13:40.614943)
ios          - Build OK (built at 2020-12-09 20:22:42.687770)
itsdangerous - Not built
jinja2       - Not built
kivent_core  - Not built
kivy         - Build OK (built at 2020-12-09 20:29:01.150111)
libcurl      - Not built
libffi       - Build OK (built at 2020-12-09 20:06:13.337783)
libjpeg      - Not built
libpng       - Not built
libzbar      - Not built
markupsafe   - Not built
netifaces    - Not built
numpy        - Not built
openssl      - Build OK (built at 2020-12-09 20:08:59.288718)
photolibrary - Not built
pil          - Not built
pillow       - Not built
pkgresources - Not built
plyer        - Not built
pycrypto     - Not built
pykka        - Not built
pyobjus      - Build OK (built at 2020-12-09 20:23:58.339146)
python3      - Build OK (built at 2020-12-09 20:22:21.701912)
pyyaml       - Not built
sdl2         - Build OK (built at 2020-12-09 20:10:14.409268)
sdl2_image   - Build OK (built at 2020-12-09 20:14:17.752407)
sdl2_mixer   - Build OK (built at 2020-12-09 20:15:23.982876)
sdl2_ttf     - Build OK (built at 2020-12-09 20:15:35.183602)
werkzeug     - Not built
zbarlight    - Not built

Additionally, following the steps listed here, I navigated to the archive I uploaded to Apple and I ran the following commands in the terminal:

nm <App Name> | grep ffi_call nm <App Name> | grep ffi_closure_alloc nm <App Name> | grep ffi_closure_free

etc.

The only only unique output of the above commands was that for nm <App Name> | grep ffi_call which returned:

0000000100d1a2ea s ___pyx_k_pointer_before_ffi_call
U _ffi_call

The remaining command all returned U _ffi_closure_alloc etc.

Additional information

You can find Apple's private API here.

Things I have tried in vain:

Unlinking ffilib.a from the project

Now doing so causes the build to fail on the simulators, but the errors I receive are:

Screenshot 2020-12-11 at 18 11 15

This makes me think that the error lies with the libffi.a static library, though I can't be too sure.

Anyway, thanks for taking the time out to read this. I am at the end of my wits, so any insight into the problem or suggestion - seriously anything at all - is hugely appreciated.

Python3-8 commented 3 years ago

Hi, I'm on macOS Catalina and I keep getting these errors during the validation of my archives: The first error (when I'd disabled iPad support): FirstError.png Second error (when I'd enabled iPad support): iPadEnabled.png Third error (when I'd deleted the ~/Library/Developer/Xcode/DerivedData/ModuleCache.noindex directory): ModuleCacheDeleted.png May I know if you encountered these issues too? If so, may I know what you did to fix them?

jda5 commented 3 years ago

Hi @Python3-8

This isn’t at all related to my issue, but no I’ve not encountered the above.

However, having a brief look through your error message it reads “.../YourApp/.buildozer/android/platform/...”

This strikes me as a problem. Xcode is exclusively for iOS, so perhaps there are some crossed wires from when you built your app for Android using buildozer. Are you using a virtual environment for kivy-iOS?

Like I’ve said I’ve not had this issue, but I’d investigate the above.

Python3-8 commented 3 years ago

I don't get what you mean by virtual environment for kivy-ios but to install packages, I used ./toolchain.py pip install <package> and ./toolchain.py build <package>. And you're right, I was wondering why Xcode was using my buildozer stuff.

jda5 commented 3 years ago

@Python3-8

On the main kivy-ios page it advises people to install the toolchain in a virtual environment. This prevents frameworks from “overlapping”. The way I do this is by running the following commands in the terminal:

sudo mkdir kivy-ios cd kivy-ios sudo python3 -m venv venv . venv/bin/activate

Then install Cython and kivy-ios

sudo pip3 install Cython==0.29.17 sudo pip3 install kivy-ios

At this point you’ll be ready to build the toolchain. You won’t need the .py suffix either simply run:

sudo toolchain build python3 kivy

Then create the Xcode project. All this information, including the prerequisites, can be found on the main kivy-ios page

Python3-8 commented 3 years ago

Will this stop Xcode from using my .buildozer folder?

jda5 commented 3 years ago

I think yes but don’t hold me to that. Try it and let me know.

If it doesn’t work, do you mind creating a separate post for people to comment on? Your issue is not related to the one I’ve posted, but I am still happy to help you. I just think that each post should focus only on one issue. Tag me in your new post and I’ll carry on helping you as best as I can. Thanks

Python3-8 commented 3 years ago

Thank you very much for your help. Before I try it with a virtual environment, I'll see if people have come up with other solutions because I don't want to have to rebuild my whole project without knowing if it's gonna work.

misl6 commented 3 years ago

@jda5 I just had an App verified by Apple, by using latest kivy-ios master and Xcode 12.2

Can you please try to upgrade and also try to use latest kivy-ios master and report back if the issue persists?

jda5 commented 3 years ago

Hi @misl6,

Thanks for getting back to me, and taking the time to respond. So happy that you managed to get the app onto App Store Connect, that is really positive news, as I was starting to think that it wasn't possible.

The update will take some time, and will try it tomorrow (it is 12:45 am where I am at the moment). Do you mind giving me a little more information on what Python version you are running, what iOS version, what recipes you built and how you built your app? I used the older version of Kivy (not 2.0.0, the one that came before that - 2.0.0 came out after I finished building the app). I also used pipenv to create a virtual environment for my project, though am more than happy to change things around to align my specs with yours.

Thanks

jda5 commented 3 years ago

@misl6

Now that I have upgraded to Xcode 12.2 I am unable to build recipes. Running sudo toolchain build python3 openssl kivy eventually leads to the following error:

[DEBUG   ] /Users/jacobstrauss/Documents/Python/kivy-ios/build/hostpython3/x86_64/Python-3.8.2/Modules/posixmodule.c:9058:13: error: 
[DEBUG   ]       implicit declaration of function 'preadv' is invalid in C99
[DEBUG   ]       [-Werror,-Wimplicit-function-declaration]
[DEBUG   ]         n = preadv(fd, iov, cnt, offset);
[DEBUG   ]             ^
[DEBUG   ] /Users/jacobstrauss/Documents/Python/kivy-ios/build/hostpython3/x86_64/Python-3.8.2/Modules/posixmodule.c:9629:18: error: 
[DEBUG   ]       implicit declaration of function 'pwritev' is invalid in C99
[DEBUG   ]       [-Werror,-Wimplicit-function-declaration]
[DEBUG   ]         result = pwritev(fd, iov, cnt, offset);
[DEBUG   ]                  ^
[DEBUG   ] 4 warnings and 2 errors generated.
[DEBUG   ] make: *** [Modules/posixmodule.o] Error 1
[DEBUG   ] make: *** Waiting for unfinished jobs....
Exception in thread background thread for pid 56224:
Traceback (most recent call last):
  File "/Users/jacobstrauss/.pyenv/versions/3.8.2/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/Users/jacobstrauss/.pyenv/versions/3.8.2/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/sh.py", line 1637, in wrap
    fn(*rgs, **kwargs)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/sh.py", line 2561, in background_thread
    handle_exit_code(exit_code)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/sh.py", line 2265, in fn
    return self.command.handle_command_exit_code(exit_code)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/sh.py", line 865, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_2: 

  RAN: /usr/bin/make -C /Users/jacobstrauss/Documents/Python/kivy-ios/build/hostpython3/x86_64/Python-3.8.2/native-build -j4

  STDOUT:
clang -Qunused-arguments -fcolor-diagnostics -c -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -arch x86_64 -mmacosx-version-min=10.12 -I/Users/jacobstrauss/Documents/Python/kivy-ios/dist/hostlibffi/usr/local/include --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -arch x86_64 -mmacosx-version-min=10.12 -I/Users/jacobstrauss/Documents/Python/kivy-ios/dist/hostlibffi/usr/local/include  -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration  -I/User... (130061 more, please see e.stdout)

  STDERR:

Traceback (most recent call last):
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/bin/toolchain", line 8, in <module>
    sys.exit(main())
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 1497, in main
    ToolchainCL()
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 1270, in __init__
    getattr(self, args.command)()
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 1323, in build
    build_recipes(args.recipe, ctx)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 1121, in build_recipes
    recipe.execute()
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 700, in execute
    self.build_all()
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 85, in _cache_execution
    f(self, *args, **kwargs)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 794, in build_all
    self.build(arch)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 85, in _cache_execution
    f(self, *args, **kwargs)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 781, in build
    self.build_arch(arch)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 833, in build_arch
    getattr(self, build)()
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/recipes/hostpython3/__init__.py", line 71, in build_x86_64
    shprint(sh.make, "-C", build_subdir, self.ctx.concurrent_make,
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/kivy_ios/toolchain.py", line 67, in shprint
    for line in cmd:
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/sh.py", line 911, in next
    self.wait()
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/sh.py", line 841, in wait
    self.handle_command_exit_code(exit_code)
  File "/Users/jacobstrauss/Documents/Python/kivy-ios/venv/lib/python3.8/site-packages/sh.py", line 865, in handle_command_exit_code
    raise exc
sh.ErrorReturnCode_2: 

  RAN: /usr/bin/make -C /Users/jacobstrauss/Documents/Python/kivy-ios/build/hostpython3/x86_64/Python-3.8.2/native-build -j4

  STDOUT:
clang -Qunused-arguments -fcolor-diagnostics -c -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -arch x86_64 -mmacosx-version-min=10.12 -I/Users/jacobstrauss/Documents/Python/kivy-ios/dist/hostlibffi/usr/local/include --sysroot=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -arch x86_64 -mmacosx-version-min=10.12 -I/Users/jacobstrauss/Documents/Python/kivy-ios/dist/hostlibffi/usr/local/include  -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration  -I/User... (130061 more, please see e.stdout)

Any idea what the problem could be?

misl6 commented 3 years ago

@jda5 I assume you're not using latest kivy-ios==master, but the pip installable version. The pip installable version is outdated, can you please clone the kivy-ios repo and install it from source? (be sure to uninstall the pip installed version before)

jda5 commented 3 years ago

@misl6 I installed kivy-ios master and Xcode 12.2! This worked great, and I've even managed to get my app onto my iPhone running iOS 14.2 (instead of a device running an older version of iOS) - so thanks for that!

Unfortunately, when I archive the project, even though it passes the validation checks, upon distributing it I still receive the same rejection email saying:

ITMS-90338: Non-public API usage - The app references non-public symbols in ccc-graphs-14: _ffi_call, _ffi_closure_alloc, _ffi_closure_free, _ffi_prep_cif, _ffi_prep_closure_loc, _ffi_type_double, _ffi_type_float, _ffi_type_pointer, _ffi_type_sint16, _ffi_type_sint32, _ffi_type_sint64, _ffi_type_sint8, _ffi_type_uint16, _ffi_type_uint32, _ffi_type_uint64, _ffi_type_uint8, _ffi_type_void. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed.

Would it be possible to change these method names before compiling the toolchain?

Python3-8 commented 3 years ago

You could try using this method to build kivy-ios. I didn't use a virtual environment, but I'm at the stage where my app is available on TestFlight.

jda5 commented 3 years ago

@Python3-8 thanks, will give that go soon. May I ask what recipes did you build and what modules did you install?

Python3-8 commented 3 years ago

My app didn't require many modules since it was really basic and was the second ever app that I'd tried to publish. I built python3, kivy, and plyer. I used pip to install kivymd because my app was a material design app.

jda5 commented 3 years ago

@Python3-8 Thanks for the tip but sadly this didn't work for me. Glad to hear that you managed to get in on TestFlight though. This could potentially be an error with OpenSSL but my gut tells me its something to do with ffilib. Still though I want to know what you did, that I didn't. What iOS are you running? Which version of Python? etc.

Python3-8 commented 3 years ago

Sorry to hear it didn’t work for you.

Python3-8 commented 3 years ago

I'm using iOS 14.1, Xcode 12.1, Python 3.8.3, Kivy 2.0.0, KivyMD 0.104.2.dev0, Cython 0.29.17, and macOS Catalina (iMac, 27" Late 2009). I know that it's not a problem with OpenSSL because a person that I know got this error while submitting an app that doesn't use OpenSSL.

misl6 commented 3 years ago

@jda5 can you please list and describe all the steps you're doing? (from the very first step to the latest). I need something very detailed, in order to be able to reproduce your issue.

jda5 commented 3 years ago

@misl6 Sure thing, here is what I did:

  1. Install macOS Catalina version 10.15.7 and install Xcode version 12.2
  2. Build a Kivy app with Python 3.7.7 (version managed with pyenv) using a pipenv virtual environment. Instead of using the requests library I built the app by making use of Kivy's UrlRequest module. The app uses custom fonts and makes use a screen manager to navigate between several .kv files. Save the principle Python file as main.py. --- Note: I have reproduced this error with and without the use of the requests library.
  3. In the terminal run xcode-select --install followed by brew install autoconf automake libtool pkg-config and finally brew link libtool
  4. Set the global Python version to 3.8.2 by running pyenv global 3.8.2 --- Note: I have reproduced this error with and without this step
  5. In the terminal navigate to a desired directory and run sudo git clone https://github.com/kivy/kivy-ios.git
  6. Upon completion enter cd kivy-ios/
  7. Run sudo python3 -m venv venv to create a virtual environment and activate it with . venv/bin/activate
  8. Enter sudo pip install -e .
  9. Enter sudo pip install Cython==0.29.17
  10. Enter sudo python toolchain.py build python3 openssl kivy
  11. Enter sudo python toolchain.py pip install requests --- Note: I have reproduced this error with and without this step
  12. Enter sudo python toolchain.py create <app_name> ~/path/to/app/files
  13. Enter open . and right click on the folder called kivy-ios. Then change the permission for all users to read & write, then select to apply the changes to all enclosing files.
  14. Open the Xcode project
  15. In the panel on the left navigate to Warnings then select Update to recommended settings --- Note: I have reproduced this error with and without this step.
  16. In Build Phases -> Run Script add -O —no-perm
  17. Add an icon image to the app.
  18. In Signing & Capabilities add your team.
  19. Change the bundle identifier so that it matches the one you have created on App Store Connect.
  20. In the <app_name>-Info.plist file specify why you need the camera or that you don't use it, as is explained here.
  21. In Sources -> main.m change #include "Python.h" to an absolute path, i.e. #include "/path/to/kivy-ios/dist/root/python3/include/python3.8/Python.h" as is explained here.
  22. Similarly, in the pystate.h change #include "cpython/initconfig.h"to #include "/path/to/kivy-ios/dist/root/python3/include/python3.8/cpython/initconfig.h"
  23. Test the app on the simulators, but before doing so in Architectures add arm64 to the excluded architectures .
  24. Test the app on an iPhone running iOS 14.2, but before building remove arm64 from the excluded architectures.
  25. If the app passes the tests in the previous two steps. Select Generic iOS Device in Build Settings
  26. In the General page of the app settings tick Requires full screen
  27. ClickBuild -> Archive
  28. In the Archive window select Validate - there are a few options to select here, I just went with the default settings each time.
  29. If the app passes validation select Distribute - again there are a few option, but I went with the default.

After this I receive the aforementioned rejection email.

Hope this helps. Let me know if there is any other information you would like to see.

misl6 commented 3 years ago

@jda5 Can you please redo the whole thing, starting from step 5, by not using sudoat all?

jda5 commented 3 years ago

Hi @misl6, I followed each step to the letter, but without including sudo in any of my commands and unfortunately got the same error.

The only new thing I can think of (that I haven't previously mentioned) is that in a directory /Library/Developer/CommandLineTools/SDKs/MacOSX11.0.sdk/usr/include is a folder called ffi with a bunch of .h files. These files contain some of the aforementioned variable names, such as ffi_call etc. Could this be the issue?

nikosgrikos commented 3 years ago

I'm experiencing exactly the same issues as jda5 when I try and archive my app. Running on MacOS Catalina and Xcode12.2.

misl6 commented 3 years ago

@nikosgrikos Can you also please try to write down a step by step guide on how to reproduce your issue? Have you changed anything into the xcode project settings?

jda5 commented 3 years ago

@misl6 Yesterday I did a clean reinstall. I removed Xcode and all the accompanying files (including the command line tools), removed all kivy-ios files and removed every single file that mentions ffi (such as a brew formula). I then installed Xcode 12.3, and the Kivy-ios master... and still got the same issue. The only related issue I could possibly find is a warning when building to a simulator which reads:

could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame

I don't know how helpful that is, but I really don't know where to go with this anymore.

misl6 commented 3 years ago

@jda5 Can you join us over here? : https://chat.kivy.org/ (#ios-support) We will report back here what We have found out after a chat.

nikosgrikos commented 3 years ago

Versions

Python : 3.7.9 MacOS version : 10.15.5 XCode Version : 12.2 Cython version : 0.29.21

The steps listed are after the Kivy-ios folder has been created. If you need the steps beforehand, then let me know and I’ll start all over, but they are pretty similar to the way @jda5 has implemented them. My app includes references to AdMob

  1. In terminal, sudo python toolchain.py create ~/path/to/app/files
  2. Navigate to folder and change permissions
  3. Open app name.xcodeproj
  4. In signing and capabilities, change script to include “-O —no-perms”
  5. Add developer name
  6. Cd app name
  7. In terminal, Pod init
  8. In terminal, Open -a Xcode Podfiles
  9. Add pod ‘Firebase/Core’ and pod ‘Firebase/AdMob’
  10. Add GoogleService-Info.plist into Resouces folder
  11. In terminal, pod install
  12. In terminal, open app name.xcworkspace
  13. Under build settings for app name, change “Enable module C and Objective C” to Yes
  14. Under build settings for app name, in “Other Linker Flags”, add “-ObjC” and “$(inherited)”
  15. Under build settings for app name, change “Framework search paths” to include “$(inherited)”. Actually this is defaulted
  16. Under build settings for app name, change “Header search paths” to include “$(inherited)”
  17. Under pod settings, change “Build active architecture” to “No”
  18. Close Xcode
  19. In terminal, pod install
  20. In terminal, open app name.xcworkspace
  21. Change main.m to include code for ads. I followed these instructions: https://docs.google.com/document/d/1NaUxVcO-hGYKiVw1VkaVjqjZShN71zuQZkUZoL4wgJw/edit?usp=sharing
  22. Change main.m to include absolute path for Python.h
  23. Change app name code accordingly to call ads
  24. Change app name plist, add GADApplicationIdentifier with my AdMob application ID
  25. Add icon image
  26. Run on my iPhone SE. Great it works and with test ads.
  27. Now, steps to get on AppStore
  28. Under build settings, change full screen to 1
  29. Under copy bundle, dereference lib file
  30. Change build to Any iOS device (arm64)
  31. Under Product menu and scheme, edit scheme to say Release instead of debug (this probably makes no difference to the issue)
  32. Under Product menu, choose archive, then validate following defaults
  33. All is good, select distribute and follow defaults

After following above, I end up with exactly the same issues as @jda5 in an email from Apple support

ITMS-90338: Non-public API usage - The app references non-public symbols in numberbuster3: _ffi_call, _ffi_closure_alloc, _ffi_closure_free, _ffi_prep_cif, _ffi_prep_closure_loc, _ffi_type_double, _ffi_type_float, _ffi_type_pointer, _ffi_type_sint16, _ffi_type_sint32, _ffi_type_sint64, _ffi_type_sint8, _ffi_type_uint16, _ffi_type_uint32, _ffi_type_uint64, _ffi_type_uint8, _ffi_type_void. If method names in your source code match the private Apple APIs listed above, altering your method names will help prevent this app from being flagged in future submissions. In addition, note that one or more of the above APIs may be located in a static library that was included with your app. If so, they must be removed. For further information, visit the Technical Support Information at http://developer.apple.com/support/technical/

ITMS-90683: Missing Purpose String in Info.plist - Your app's code references one or more APIs that access sensitive user data. The app's Info.plist file should contain a NSCameraUsageDescription key with a user-facing purpose string explaining clearly and completely why your app needs the data. Starting Spring 2019, all apps submitted to the App Store that access user data are required to include a purpose string. If you're using external libraries or SDKs, they may reference APIs that require a purpose string. While your app might not use these APIs, a purpose string is still required. You can contact the developer of the library or SDK and request they release a version of their code that doesn't contain the APIs. Learn more (https://developer.apple.com/documentation/uikit/core_app/protecting_the_user_s_privacy).

Granted, the second one has a workaround, but the first is an issue.

jda5 commented 3 years ago

For completeness (since my build has changed, and since I have posted this in Discord and want to share this with anyone who is not in the group) below is every command/action I have done to create the Xcode project and upload to TestFlight

  1. Start with a clean build (remove all existing kivy-ios files)

In the terminal

  1. git clone https://github.com/kivy/kivy-ios.git
  2. cd kivy-ios/
  3. python3 -m venv venv
  4. . venv/bin/activate
  5. pip install -e .
  6. pip install Cython==0.29.17
  7. python toolchain.py build python3 openssl kivy
  8. python toolchain.py pip install requests
  9. Not in terminal: Change the permissions of all the files in the Kivy-ios folder to Read & Write
  10. python toolchain.py create <app_name> ~/path/to/python/files

Once the project has been created

  1. Change the permission of all the files in the folder to Read & Write

Open the Xcode project

  1. In “Signing & Capabilities > Signing” add a Team
  2. In “General > Identity” rename the app and change the bundle identifier
  3. In “General > Deployment Info" select “Requires full screen
  4. In the info.plist file add a reason for referencing the camera
  5. Add an icon image to the app.

Test on simulator

  1. In “Build Settings > Architectures” add “arm64” to “excluded architectures
  2. Build app on any simulator — PASSED

Test on device

  1. In “Build Settings > Architectures” remove “arm64” from “excluded architectures
  2. Connect device and build -- PASSED

Upload to TestFlight

  1. Change build to “Any iOS Device
  2. Select “Products > Archive” — FAILED



REASON:
/path/to/folder/kivy-ios/ccc-graphs-22-ios/main.m:8:10: 'Python.h' file not found

  1. In “main.m” file, line 8, change #include "Python.h” to #include “/path/to/folder/kivy-ios/dist/root/python3/include/python3.8/Python.h”

  2. Select “Products > Archive” — FAILED



REASON:
/path/to/folder/kivy-ios/dist/root/python3/include/python3.8/cpython/pystate.h:9:10: 'cpython/initconfig.h' file not found

  1. In “pystate.h” file, line 9, change #include "cpython/initconfig.h” to #include “/path/to/folder/kivy-ios/dist/root/python3/include/python3.8/cpython/initconfig.h”

  2. Select “Products > Archive” — PASSED

In Organiser window

  1. Select app and click “Validate App
  2. For each screen click “Next” without changing the default settings — PASSED
  3. Select “Distribute App > TestFlight
  4. For each screen click “Next” without changing the default settings — PASSED (Xcode say it has been successfully uploaded)

Email

After waiting about 5 minutes I receive the aforementioned rejection email

@nikosgrikos you no longer need to include -O --no-perms in the Build Phases by not running sudo in the toolchain build and Xcode creation. This doesn't solve our problem but its I think its a neat observation.

nikosgrikos commented 3 years ago

After experimenting, I've noticed you can upload a 'Debug' version to the App Store instead of a 'Release' version. This stops the ITMS-90338 message being invoked. To do this, under the product menu select 'Scheme' and then 'Edit Scheme', press 'Archive' and then choose 'Debug' instead of 'Release'. Whether this is the correct approach or not, I don't know, but it gets around the problem. Perhaps someone can with some knowledge on this can comment.

jda5 commented 3 years ago

@nikosgrikos It works! All good on my end, have uploaded a build to App Store connect. Thank you!

nikosgrikos commented 3 years ago

That's good to hear! I hope the approach is acceptable when publishing an app. Waiting for @misl6 to comment.

misl6 commented 3 years ago

Uhm, the headers that were not found + the Debug/Release thing ringed the bell. Thank you @nikosgrikos for finding the workaround.

Can you please try this PR(https://github.com/kivy/kivy-ios/pull/582) and check if all the process works flawlessly? When using this PR over master you should be able to avoid the following steps:

misl6 commented 3 years ago

Hi @nikosgrikos , @jda5

You had the chance to test the provided PR?

jda5 commented 3 years ago

@misl6 not yet, but am more than happy to test it soon. I must confess though I am quite new to GitHub and am not sure how to test your PR. Do you mind sending me some instructions on how to properly test your PR, and I'll try it out, writing output logs at each stage.

nikosgrikos commented 3 years ago

Same here. I am a newbie.

On Thu, 31 Dec 2020 12:09 pm Mirko, notifications@github.com wrote:

@nikosgrikos https://github.com/nikosgrikos Can you also please try to write down a step by step guide on how to reproduce your issue? Have you changed anything into the xcode project settings?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/kivy/kivy-ios/issues/572#issuecomment-752912841, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASF25RS4FB7BETHGG7HLAI3SXREURANCNFSM4UXBDVHA .

misl6 commented 3 years ago

The process is pretty the same as building kivy-ios on top of master.

Given that you have successfully cloned the kivy-ios repo via git clone https://github.com/kivy/kivy-ios.git, inside the kivy-ios folder you have to launch the two following commands:

git fetch origin pull/582/head:test-pr-582 git checkout test-pr-582

In order to be sure that you did it right, a git log should show "Fixes header and library search paths on Release" as the topmost commit.

If it's ok, then you can start by creating the venv and continue to follow the standard procedure.

As mentioned here, you can avoid doing the following steps thanks to this PR:

Uhm, the headers that were not found + the Debug/Release thing ringed the bell. Thank you @nikosgrikos for finding the workaround.

Can you please try this PR(#582) and check if all the process works flawlessly? When using this PR over master you should be able to avoid the following steps:

  • In “Build Settings > Architectures” add “arm64” to “excluded architectures”
  • In “main.m” file, line 8, change #include "Python.h” to #include “/path/to/folder/kivy-ios/dist/root/python3/include/python3.8/Python.h”
  • In “pystate.h” file, line 9, change #include "cpython/initconfig.h” to #include “/path/to/folder/kivy-ios/dist/root/python3/include/python3.8/cpython/initconfig.h”

At the end of the test, you can revert to the repo master by doing git checkout master inside the kivy-ios folder.

jda5 commented 3 years ago

@misl6 Thanks, I will test it either tonight or tomorrow.

jda5 commented 3 years ago

@misl6 Good news, the PR works perfectly, and have uploaded a build to App Store Connect! Below are all the steps I took and the output logs.

  1. Start with a clean build (remove all existing kivy-ios files)

In the terminal

  1. git clone https://github.com/kivy/kivy-ios.git
  2. cd kivy-ios
  3. git fetch origin pull/582/head:test-pr-582

remote: Enumerating objects: 8, done. remote: Counting objects: 100% (8/8), done. remote: Compressing objects: 100% (2/2), done. remote: Total 8 (delta 6), reused 8 (delta 6), pack-reused 0 Unpacking objects: 100% (8/8), done. From https://github.com/kivy/kivy-ios

  • [new ref] refs/pull/582/head -> test-pr-582
  1. git checkout test-pr-582

Switched to branch 'test-pr-582'

  1. git log

commit f9ac7712f40461c4732503f78ec1db0930b3b83b (HEAD -> test-pr-582) Author: Mirko Galimberti me@mirkogalimberti.com Date: Tue Jan 5 18:01:47 2021 +0100

Fixes header and library search paths on Release

  1. python3 -m venv venv
  2. pip install -e .
  3. pip install Cython==0.29.17
  4. python toolchain.py build python3 openssl kivy

[DEBUG ] New State: kivy.install at 2021-01-20 22:42:36.218754 [DEBUG ] New State: kivy.build_all at 2021-01-20 22:42:36.226161

  1. python toolchain.py pip install requests
  2. python toolchain.py create <app_name> ~/path/to/python/files

Once the project is created

  1. Change the permission of all the files in the folder to Read & Write

In Xcode

  1. In “Signing & Capabilities > Signing” add a Team
  2. In “General > Identity” rename the app and change the bundle identifier
  3. In “General > Deployment Info" select “Requires full screen”
  4. In the info.plist file add a reason for referencing the camera
  5. Add an icon image to the app.

Interestingly, at this stage, in previous builds, an error message would pop up saying something about a permission error regarding the icon images. I always ignored it as it didn't actually bear any consequences to my project. However, I didn't receive the error message this time.

Test on simulator

  1. Build app on any simulator — PASSED

Test on device

  1. Connect device and build -- PASSED

Upload to TestFlight

  1. Change build to “Any iOS Device”
  2. Select “Products > Archive” — PASSED



In Organiser window

  1. Select app and click “Validate App”
  2. For each screen click “Next” without changing the default settings — PASSED
  3. Select “Distribute App > TestFlight
  4. For each screen click “Next” without changing the default settings — PASSED

Email

Dear Jacob,

The following build has completed processing:

Platform: iOS App Name: Build Number: Version Number: App SKU: App Apple ID: *****

You can now use this build for TestFlight testing or submit it to the App Store.

If you have any questions regarding your app, click Contact Us in App Store Connect.

Regards,

The App Store team

Sure enough the build is on App Store Connect! Should I revert back to the repo master, or am I okay to leave the PR as is?

Lastly, I want to say a massive thank you for all you have done to support me and @nikosgrikos!

misl6 commented 3 years ago

@jda5 It's a pleasure. Thank you for getting a try on the recent changes. You can revert back to master, BTW, meanwhile, kivy-ios==1.2.1 got released and contains these changes.

Python3-8 commented 3 years ago

I just want to say (this might help people) that I think this error is Mac-specific. Because I was having issues with validating my archive in December so I asked an experienced Flutter iOS developer for help. When he built my app, archived it, and tried distributing the archive he did get some errors but he managed to fix them. When he actually distributed it, he got the non-public API usage error. His Mac is an Apple Mac Mini that runs Catalina. When I managed to fix the errors on my Mac and distributed the package to App Store Connect I did NOT get the non-public API usage error. My Mac is a 27" Late 2009 iMac that runs a patched version of Catalina.