problem with dlopen() in swift xcode

so i am having a problem reading python library file using dlopen. when i use the method in terminal (running swift) it returns te library handle successfully . however when i use the same method without any changes in xcode it returns the handle as nil (i suppose this is some file access problem). now , i have seen some tutorials that recommend deleting app sandbox and editing something in herdened runtime (both should be found in the capabilities and signing section), but i cat find them in my capabilities section in the targets, idk if this is because i have the latest xcode version and that there has been made some changes or what but i cant find them. so all i want to do is run the dlopen command inside xcode if anyone can help i would be so thankful.

There are two likely causes of this:

  • App Sandbox

  • Library validation, part of the hardened runtime

The App Sandbox only applies to apps. You wrote:

but i [can’t] find them in my capabilities section in the targets

What sort of target is this? If it’s a command-line tool target, it won’t have the App Sandbox enabled by default. In that case, I think you can ignore the App Sandbox.

In terms of library validation, that’s enabled by the hardened runtime. The Signing & Capabilities editor should include a Hardened Runtime slice. Is that not there?

idk if this is because i have the latest xcode version

Well, I don’t know either, because you didn’t share what Xcode version you’re using (-:

What Xcode are you testing this with? And on what version of macOS?

How did you create your Xcode project? Using the macOS > Command Line Tool template? Or something else?

When dlopen fails, what error does dlerror report?

Are you working on this code for yourself? Or do you plan to distribute it widely? That matters because the hardened runtime in general, and library validation specifically, has an impact on your distribution path.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

problem with dlopen() in swift xcode
 
 
Q