Code Monkey home page Code Monkey logo

Comments (4)

cclauss avatar cclauss commented on July 24, 2024 2
import objc_util
from plistlib import dumps, loads
bundle_id = objc_util.ObjCClass('NSBundle').mainBundle().bundleIdentifier()
main_bundle = objc_util.ObjCClass('NSBundle').bundleWithIdentifier_(bundle_id)
info_plist_path = str(main_bundle.pathForResource_ofType_('Info', 'plist'))
with open(info_plist_path, 'rb') as f:
    info_plist_data = f.read()
info_plist = loads(info_plist_data)

-->

import plistlib
import sys
from pathlib import Path

info_plist = plistlib.loads((Path(sys.executable).parent / "Info.plist").read_bytes())

from pythonista-issues.

mikaelho avatar mikaelho commented on July 24, 2024

The actual error message is:
The operation couldn’t be completed. (NSNetServicesErrorDomain error -72008.)

It looks like since iOS 14 there has been a new security requirement where multipeer (Bonjour) network usage must be declared in plist as follows:

<key>NSBonjourServices</key>
--
<array>
<string>_multipeertest._tcp</string>
</array>

… where multipeertest should match the service key provided to the multipeer framework.

This is a problem for Pythonista, since it is only one app from Apple’s point of view, with a singular plist.

In theory, there could be a known value set in plist, which would then be used for all multipeer Pythonista scripts. To ensure that you only connect peers expected by your script, you would need to add some additional validation to filter peers by initial data.

from pythonista-issues.

bbkiwi avatar bbkiwi commented on July 24, 2024

Thanks for the info. With the 'help' of Chat GTP-3 I got understanding about what is required. Is the service key, that same as the server_type string in your MultipeerConnectivity class? (If so should the same restrictions eg 1-15 chars.. apply). Should a request for adding the key to the plist be made? Chat GTP-3 (with quite a bit of prompting) suggested code below to modify the plist but for me to discover that overwriting it is not permitted.
Cheers, Bill

import objc_util
from plistlib import dumps, loads
bundle_id = objc_util.ObjCClass('NSBundle').mainBundle().bundleIdentifier()
main_bundle = objc_util.ObjCClass('NSBundle').bundleWithIdentifier_(bundle_id)
info_plist_path = str(main_bundle.pathForResource_ofType_('Info', 'plist'))
with open(info_plist_path, 'rb') as f:
    info_plist_data = f.read()
info_plist = loads(info_plist_data)
info_plist['NSBonjourServices'] = 'mptest-tcp'
modified_info_plist_data = dumps(info_plist)
with open(info_plist_path, 'wb') as f:
    f.write(modified_info_plist_data) ## fails

from pythonista-issues.

cclauss avatar cclauss commented on July 24, 2024

Yes. Apple's iOS security will not allow the modification of any application's permissions except when digitally signed by the application's original author prior to Apple's review for submission into the App Store.

from pythonista-issues.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.