I developed and Java based application to fetch system info. I bundled the Java application into an app using AppBundler. Just double clicking the app works fine in macOS. Now to upload the app in the macOS App Store I signed the app with entitlement. Once I signed the app it is not working. My JNA code snippet is as below:
import java.nio.charset.StandardCharsets;
import com.sun.jna.Native;
import com.sun.jna.platform.mac.IOKit.IORegistryEntry;
import com.sun.jna.platform.mac.IOKitUtil;
...
...
IORegistryEntry platformExpert = IOKitUtil.getMatchingService("IOPlatformExpertDevice");
if (platformExpert != null) {
byte[] data = platformExpert.getByteArrayProperty("manufacturer");
if (data != null) {
manufacturer = Native.toString(data, StandardCharsets.UTF_8);
}
data = platformExpert.getByteArrayProperty("model");
if (data != null) {
model = Native.toString(data, StandardCharsets.UTF_8);
}
serialNumber = platformExpert.getStringProperty("IOPlatformSerialNumber");
uuid = platformExpert.getStringProperty("IOPlatformUUID");
platformExpert.release();
}
now when I'm running this app I'm getting below error in the terminal:
Jul 16, 2021 8:35:21 PM com.sun.jna.Native extractFromResourcePath
INFO: Looking in classpath from sun.misc.Launcher$AppClassLoader@5c647e05 for /com/sun/jna/darwin-x86-64/libjnidispatch.jnilib
Jul 16, 2021 8:35:21 PM com.sun.jna.Native extractFromResourcePath
INFO: Found library resource at jar:file:/Users/<username>/Desktop/app-macos-installer-builder_v3/macOS-x64/application/MyApp.app/Contents/Java/MyApp_lib/jna-5.8.0.jar!/com/sun/jna/darwin-x86-64/libjnidispatch.jnilib
Jul 16, 2021 8:35:21 PM com.sun.jna.Native extractFromResourcePath
INFO: Extracting library to /Users/ahs-cbe-pp/Library/Containers/com.pkg.MyApp/Data/Library/Caches/JNA/temp/jna5601997128572859092.tmp
Jul 16, 2021 8:35:21 PM com.sun.jna.Native loadNativeDispatchLibraryFromClasspath
INFO: Trying /Users/<username>/Library/Containers/com.pkg.MyApp/Data/Library/Caches/JNA/temp/jna5601997128572859092.tmp
Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/<username>/Library/Containers/com.pkg.MyApp/Data/Library/Caches/JNA/temp/jna5601997128572859092.tmp: dlopen(/Users/<username>/Library/Containers/com.pkg.MyApp/Data/Library/Caches/JNA/temp/jna5601997128572859092.tmp, 1): no suitable image found. Did find:
/Users/<username>/Library/Containers/com.pkg.MyApp/Data/Library/Caches/JNA/temp/jna5601997128572859092.tmp: code signature in (/Users/<username>/Library/Containers/com.pkg.MyApp/Data/Library/Caches/JNA/temp/jna5601997128572859092.tmp) not valid for use in process using Library Validation: library load disallowed by system policy
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1934)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
at java.lang.Runtime.load0(Runtime.java:810)
at java.lang.System.load(System.java:1086)
at com.sun.jna.Native.loadNativeDispatchLibraryFromClasspath(Native.java:1019)
at com.sun.jna.Native.loadNativeDispatchLibrary(Native.java:989)
at com.sun.jna.Native.<clinit>(Native.java:195)
at com.sun.jna.platform.mac.IOKit.<clinit>(IOKit.java:51)
at com.sun.jna.platform.mac.IOKitUtil.<clinit>(IOKitUtil.java:39)`
I've given following entitlement:
<?xml version="1.0" encoding="UTF-8"?>
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.print</key>
<true/>
<key>com.apple.security.scripting-targets</key>
<true/>
<key>com.apple.security.get-task-allow</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-executable-page-protection</key>
<true/>
</dict>
</plist>
Can anyone help me what is going wrong here?