Configure associated domain from .xcconfig - ios

I have an app with multiple schemes, where I want to have a different associated domain for each scheme.
I have the following .entitlements file:
<?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.developer.associated-domains</key>
<array>
<string>applinks:$(ASSOCIATED_DOMAIN)</string>
<string>webcredentials:(ASSOCIATED_DOMAIN)</string>
</array>
</dict>
</plist>
My .xcconfig files look like this (?mode=developer is only there to verify everything is working and will be removed):
// ...
ASSOCIATED_DOMAIN="my.domain.com?mode=developer"
I tried to verify my link with the following command, but this opens mobile Safari:
xcrun simctl openurl booted 'https://my.domain.com/app/link'
My /.well-known/apple-app-site-association file is accessible and when I inline my domain and remove the $(ASSOCIATED_DOMAIN) the app link works as expected by opening the app instead of Safari. In this case, my .entitlements file looks like 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.developer.associated-domains</key>
<array>
<string>applinks:my.domain.com?mode=developer</string>
<string>webcredentials:my.domain.com?mode=developer</string>
</array>
</dict>
</plist>
Does anybody have a suggestion what might be wrong? Thanks!

Instead of using a variable for the ASSOCIATED_DOMAIN value, consider specifying a separate entitlements file for each of the schemes.
In the relevant xcconfig file, this can be done by setting:
CODE_SIGN_ENTITLEMENTS = [location of the file].entitlements

Related

How to modify info.plist?

So i need to disable ATS in my xcode project by typing
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
in my info.plist. However my info.plist file contains only
<?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>LastAccessedDate</key>
<date>2022-11-06T09:15:11Z</date>
<key>WorkspacePath</key>
<string>/Users/markmarus/Desktop/name/name.xcodeproj</string>
</dict>
</plist>
There also is a scm.plist which contains
<?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>Version</key>
<integer>5</integer>
</dict>
</plist>
After adding ATS settings and starting simulator up the info.plist file just deletes added lines so it changes nothing.
The Info.plist generated by Xcode starts with a uppercase letter and contains much more information than your obviously self-generated one.
If you want to modify the Xcode Info.plist do it the GUI in the Info tab of the target. After adding a custom key-value pair it appears also in the project navigator and you can open it as Source Code to modify the property list text directly.

How to turn off the OneDrive tutorial using a plist

I want to turn the tutorial off and set the default folder, so I'm not asked when the machine boots.
I have created a plist based on the instruction (https://learn.microsoft.com/en-us/onedrive/deploy-and-configure-on-macos), and when I log into OneDrive via the app, nothing changed. I'm still asked for the drive location, and the tutorial still runs.
Plist File: com.microsoft.OneDrive.plist
Location: /Users/syacko/Library/Preferences
<?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>DefaultFolder</key>
<dict>
<key>Path</key>
<string>/Users/syacko</string>
<key>TenantId</key>
<string>ee19ff16-4eb9-4f7e-acdb-XXXXXXXXX</string>
</dict>
<key>DisableTutorial</key>
<true/>
</dict>
</plist>

Exclude an applink subdomain in the entitlements

When dealing with universal links, how can I exclude a specific subdomain? What should I add in my entitlement file if I wanted to exclude help.example.com so that that url is opened in the browser?
My entitlement file looks like:
<?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.developer.associated-domains</key>
<array>
<string>applinks:www.example.com</string>
<string>applinks:*.example.com</string>
</array>
</dict>
</plist>

Set read only a .plist file item

I have a plist file used to store informations as parameters of my application.
It can be configurable by Settings on device and I can set items value programmatically.
Everything working well, but I would like to set items Enable\Disable based on condition.
For example, for some reason I would like to put my item used to store a text information disabled, so the user on device can't edit this parameter on Settings device. Is it possible?
<?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>DefaultValue</key>
<string></string>
<key>Key</key>
<string>USERNAME</string>
<key>KeyboardType</key>
<string>Alphabet</string>
<key>Title</key>
<string>User</string>
<key>Type</key>
<string>PSTextFieldSpecifier</string>
</dict>
</plist>
If you want that kind of flexibility, provide a settings interface within your app rather than relying on the Settings app.

xcode - how use MobileWiFi.framework

In my private app (not jailbroken), I need to read wifi RSSI values of enterprise hotspots. I read about MobileWiFi.framework.
I am trying to use the example code "Getting the WiFi signal strength" found here but without lucky.
Probably, I am not properly use the framework.
Anyone could tell me the steps to do that?
visit : // http://iphonedevwiki.net/index.php/MobileWiFi.framework
<key>com.apple.wifi.manager-access</key>
</true>
Your custom entitlements file should finally look something like that:
<?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>keychain-access-groups</key>
<array>
<string>YOUR_APP_BUNDLE_ID</string>
</array>
<key>com.apple.wifi.manager-access</key>
</true>
</dict>
</plist>

Resources