Forum Archive

[Solved] XCode Template with objc_util module ...

Brun0oO

Hi,

I've built a sample using objc_util module and I deployed it on my device (using a personal team signing certificate).
When I start the application on my device, it fails on a "load_framework" command.
The script runs without any problem on Pythonista, it fails 'only' when he is invoked from the xcode template.
Could you give me an explanation please ? Is it possible to use load_framework within the xcode template ?

Thank you..

JonB

StackOverflow says:
https://stackoverflow.com/questions/24333981/ios-app-with-framework-crashed-on-device-dyld-library-not-loaded-xcode-6-beta

Apparantly Brandon's response is the one to follow

Brun0oO

@JonB : the link you provided is very interesting but in my case, it's the command "load_framework" that is throwing an exception not the framework itself.... so I got :

load_framework('SceneKit')
NameError : name 'load_framework' is not defined

I've tried to add the SceneKit framework using the Brandon's method but I got the same error...
The crazy thing is that the same script runs perfectly under the pythonista editor...

FYI : I'm using a python 2.7 script with iOS 11.1 / XCode 9.1 Beta and my device is an iPhone 6S+

dgelessus

It's possible that the objc_util version in the Xcode template doesn't have the load_framework function yet - it's relatively new, I'm not sure if it's even in any App Store release yet. The function is implemented in pure Python code though, so you can copy it from your iPhone's objc_util.py to the Xcode template's objc_util.py.

JonB

Oh, I misread your original post. This is the load_framework from objc_util.

def load_framework(name):
    return NSBundle.bundleWithPath_('/System/Library/Frameworks/%s.framework' % (name,)).load()
Brun0oO

@dgelessus : you're right ! I've extracted objc_util.py from my current Pythonista and have copied it to the XCode Template project (PythonistaAppTemplate/PythonistaKit.framework/pylib/site-packages directory ). Now, I can test my app :o)

@JonB : I don't need to add the framework I want to load in my xcode project. I've removed the framework in the xcode project and my app can be launched without any problem...Perhaps as it's an Apple framework, I don't need to add it....My xcode knowledge is a little low ;o)

Thank you for your help...