How to build MacOS app with hardened runtime in AppBundler - gradle

I am using AppBundler plugin in gradle to build my Java app.
Now to have my app notarized, Apple requires the app to be built with 'hardened runtime' option.
Does anyone know how to achieve this?

I added the following entitlements when signing my app and fixed the problem.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
</dict>
</plist>

Related

Is WorkspaceSettings.xcsettings file required to be uploaded to git?

I am developing an iOS app and I was committing my works using bitbucket. During committing, I found a file named "WorkspaceSettings.xcsettings". And the has the following contents in it:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PreviewsEnabled</key>
<false/>
</dict>
</plist>
What is the use of this file and is it required to be uploaded to my repository?
If this file is located in
<Project>.xcworkspace/xcuserdata/<user>.xcuserdata/
in particular within a folder xcuserdata, then it's user specific.
Anything within a folder named xcuserdata is considered by Xcode to be user specific which you usally won't want to be stored in the git repo.
Your .gitignore file should contain a line
xcuserdata/
which ensures, that no user specifc data will be part of the repo.

How to add version and copyright info to a file in MacOs

I am building an executable in GoLang for MacOs.
I need to add version and copyright information to the built file.
How do I do this during the go build process or afterwards?
For example the iBooks application has this information
P.S.
I usually build for Windows only where I use Versioninfo format to add file properties but cannot find something equivalent for MacOs
iBooks is an application bundle, not a single binary like you would build with go. So you would need to find a way of wrapping the go binary in an app bundle in order to get this detail, and if it was applicable to your executable.
If you right click on the iBooks icon and then select "Show Package Contents", then navigate into the Contents folder you will find (among other files+folders) an Info.plist file and a version.plist file which hold the definition of the copyright and version respectively.
Info.plist
...
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2013–2018 Apple Inc. All rights reserved.</string>
...
version.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BuildAliasOf</key>
<string>iBooks</string>
<key>BuildVersion</key>
<string>1</string>
<key>CFBundleShortVersionString</key>
<string>1.14</string>
<key>CFBundleVersion</key>
<string>1458.15</string>
<key>ProjectName</key>
<string>iBooks</string>
<key>SourceVersion</key>
<string>1458015000000000</string>
</dict>
</plist>

MacOS app bundle compiled from qt, icon on and off

I have been annoyed by this problem for a long time.
Firstly I compiled an executable by qt-5.8.0 in qt-creator.
Then I manually built .app directory MyApp.app, by the operations introduced on the Internet, I successfully built an app without any icon.
Then I built the .icns file and put it under Resources directory and manually set up Info.plist file under the Contents directory, Info.plist file is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleIconFile</key>
<string>icon.icns</string>
</dict>
And then when I put the .app file into some directories, it displays the icon properly, but when I move it to other certain directories it fails, say ~/Desktop.
I am really confused by the problem, and I haven't use Xcode during the whole process.
Thanks for any advice!

How to fix the provisioning profile error in objective c?

After using Automatically manage signing also its showing the error.
1).WatchSwift Extension requires a provisioning profile. Select a provisioning profile for the "Debug" build configuration in the project editor.
2).Code signing is required for product type 'WatchKit Extension' in SDK 'watchOS 3.2'
Set the automatic provisioning profile for the WatchKit and WatchKit Extension target
Go to Capabilities Tab and select the Appgroups then only you can use the WatchKit as its some dependency requirement.
Go that the AppID on developer portal and link it with AppGroup ID created first in the AppGroup section and then enabling in the APPID liek you enable push.
After this, the profiles will get expired So make sure to regenerate it again in the Profiles or else Xcode will regenerate it for you.
Once you have done all this you may see an APPNAME.entitlement file added to the Xcode project which looks something like thi:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>application-identifier</key>
<string>TEAMID.com.yourapp.bundleID</string>
<key>com.apple.security.application-groups</key>
<array>
<string>group.yourapp.bundleID</string> . //This is one your created in Apple AooGroup section.
</array>
<key>keychain-access-groups</key>
<array>
<string>TEAMID.yourkeychaingroups</string> //optional
</array>
<key>com.apple.developer.pass-type-identifiers</key>
<array>
<string>TEAMID.*</string>
</array>
<key>com.apple.developer.siri</key> . //optional
<true/>
<key>get-task-allow</key>
<false/>
</dict>
</plist>
Note your details may vary based on your target.
WatchKit Target Entitlement may show this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>application-identifier</key>
<string>TEAMID.com.yourapp.bundleID.watchkitapp</string>
<key>keychain-access-groups</key>
<array>
<string>TEAMID.com.yourapp.bundleID.watchkitapp</string>
</array>
</dict>
</plist>
WatchKitExtension Target Entitlement may show this:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.yourapp.bundleID</string>
</array>
</dict>
</plist>
Finally refer the apple doc if still issue exist:https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/ConfiguringYourApp/ConfiguringYourApp.html

Extracting entitlements from Xcode capabilities

I need to obtain an entitlement file generated by Xcode automatically when you're building a project.
Normally (even when you don't have any explicit capabilities selected), you can find one at $DERIVED_FILES_DIR/$PRODUCT_NAME.xcent, it contains generic information about your team and keychain access.
Does anyone know a way to generate it bypassing the build phase.
I want to figure out a flow that is unrelated to the fact whether explicit entitlement file was specified or when Capabilities pane was used to specify them.
Perhaps I'm missing something obvious, any information would be greatly appreciated.
I actually found a way (thanks to Apple's engineers):
$ codesign -d --entitlements - /path/to/app/bundle.app:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.files.user-selected.read-only</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>
hope it helps you, too!

Resources