Extracting entitlements from Xcode capabilities - xcode

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!

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 build MacOS app with hardened runtime in AppBundler

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>

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>

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

Xcode4 derived/build/intermediate products data path: must it really be defined in user settings?

Plenty resources tell how to set these folders, but I am still not satisfied with the infrastructure. What I need is this:
I do not want to use Default folders (as preset in clean Xcode 4 installation, with default Project or Workspace settings).
I want to put them into a dir relative to Project (or Workspace)
Hence I made necessary changes to Project settings, files are being put where expected, but Project as well as Workspace setting, that tells Xcode to put the eproducts where they shell be, are stored in xcuserdata/$USER.xcuserdatad/Workspace{or Project}.settings.
Which (.settings) is naturally unacceptable to be tracked in SCM.
<?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>IDEWorkspaceUserSettings_BuildLocationStyle</key>
<integer>1</integer>
<key>IDEWorkspaceUserSettings_BuildSubfolderNameStyle</key>
<integer>0</integer>
<key>IDEWorkspaceUserSettings_DerivedDataCustomLocation</key>
<string>obj/iphone</string>
<key>IDEWorkspaceUserSettings_DerivedDataLocationStyle</key>
<integer>2</integer>
<key>IDEWorkspaceUserSettings_IssueFilterStyle</key>
<integer>0</integer>
<key>IDEWorkspaceUserSettings_LiveSourceIssuesEnabled</key>
<true/>
<key>IDEWorkspaceUserSettings_SnapshotAutomaticallyBeforeSignificantChanges</key>
<true/>
<key>IDEWorkspaceUserSettings_SnapshotLocationStyle</key>
<integer>0</integer>
</dict>
</plist>
As a result - if there is another checkout made by other user, he opens the Project (or Workspace), ending up with build products being put into default paths (user's home folder), instead of those specified in Workspace{or Project}.settings XML file - because, the xcuserdata/ folder is not tracked and user has different login of course.
I would expect the XML file sibling the contents.xcworspace XML, wiht possibliity to override in user-settings. Obivously, this is not available, at least not documented, is it?
So is there another possibility that would fit my needs?

Resources