Re: Minimal Swift/iOS Delivery Example?

"yacin (as yacin at defmacro dot cc)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
howdy Matthew

> On Aug 1, 2025, at 1:04 AM, Matthew Sinclair-Day (as msd at sinclair-day dot com) <[email protected]> wrote:
> I don't have experience integrating LW with iOS, but iOS development is a familiar domain. Here are some questions and approaches that might (or might not) be helpful to debugging:
> 
> <snip>
> 
thanks for the helpful suggestions! i clearly didn’t read the LispWorks header file closely enough, because 1 actually means it was successfully initialized and all other values means it failed. it was in fact initializing properly.

the next hurdle i ran into was how to call my code from Swift. i had sent another message to the HUG, but it included enough code it was rejected due to size. i reached out the LispWorks support and they were able to help me out. the tl;dr here is i was defining the methods for my LispWorks-generated class with an @objc protocol and trying to call them directly. these symbols are _not_ present in the delivered .o file. this should have been obvious from the provided example, which does everything dynamically based on the string naming the class and a selector naming the method. for anyone following along at home, it looks something like this in Swift:

@objc protocol FooServerProtocol {
    func setDB(path: NSString)
}

...

        guard let serverClass = NSClassFromString(“FooServer") as? NSObject.Type else {
            print("FATAL ERROR: The ‘FooServer' class was not found.")
            return
        }

        let instance = serverClass.init()

        let selector = #selector(FooServerProtocol.setDB(path:))
        if instance.responds(to: selector) {
            instance.perform(selector, with: "path/to/server.db")
            print("Set DB path")
        }

a little clunky, but it works like a charm now!
> Problems linking against libcrypto and others on iOS and macOS are not new. I am fuzzy on the details, but you might try linking against a specific version of libcrypto.dylib. Or you might need to build and bundle your own OpenSSL; perhaps, there is a Swift package that does the heavy lifting? For some reason, I am under the impression Apple wants apps to bring along their copies of these sorts of dependencies.
> 
> Could the removal of CL+SSL on :IOS-DELIVER be breaking something in your CL code and causing LW initialization to fail?
> 
good to know it’s a common problem. the :IOS-DELIVER was added so it would build/initialize properly without that functionality for now. i cannot recall the error exactly, but if DEXADOR (and thus CL+SSL) was included, the app either failed to compile or even startup.

now i’m currently fighting with the app suspending, presumably trashing the memory in Lisp land, and causing a hard crash when the app is resumed. it works fine on a fresh Xcode deploy, but trying to re-open the app it crashes immediately. if folks have ideas here, i’m all ears, but i may just reach out to support again as it isn’t covered in the docs/examples from what i can tell.

cheers

yacin
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.