Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add script to create entitlements file #239

Merged
merged 2 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
.DS_Store
xcuserdata
**/Storefront.xcconfig

*.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = MobileBuyIntegration/MobileBuyIntegration.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = A7XGC83MZE;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = MobileBuyIntegration/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
Expand All @@ -446,6 +448,7 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = MobileBuyIntegration/MobileBuyIntegration.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = A7XGC83MZE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,6 @@
},
"No logs available" : {

},
"Not supported in < iOS 15" : {

},
"OK" : {
"comment" : "Default action"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?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>webcredentials:{STOREFRONT_DOMAIN}</string>
<string>applinks:{STOREFRONT_DOMAIN}</string>
</array>
</dict>
</plist>
18 changes: 13 additions & 5 deletions Samples/MobileBuyIntegration/Storefront.xcconfig.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
STOREFRONT_DOMAIN = <yourdomainhere.myshopify.com>
STOREFRONT_ACCESS_TOKEN = <storefront access token>
// --- Storefront
// --- Find your Storefront API access token under:
// ----- https://admin.shopify.com/store/{STOREFRONT}/settings/apps/development/{APP_ID}/api_credentials

STOREFRONT_DOMAIN = <INSERT_STOREFRONT_DOMAIN>
STOREFRONT_ACCESS_TOKEN = <INSERT_STOREFRONT_ACCESS_TOKEN>

// --- Buyer preference data
EMAIL = [email protected]

FIRST_NAME = Test
LAST_NAME = Test

ADDRESS_1 = The Cloak & Dagger
ADDRESS_2 = 1st Street Southeast
CITY = Calgary
COUNTRY = CA
FIRST_NAME = Test
LAST_NAME = McTest
PROVINCE = AB
ZIP = T1X 0L3
EMAIL = [email protected]
PHONE = +155565708743
23 changes: 23 additions & 0 deletions Samples/MobileBuyIntegration/scripts/generate_entitlements.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -e

CONFIG_FILE="Storefront.xcconfig"
STOREFRONT_DOMAIN=$(grep '^STOREFRONT_DOMAIN' "$CONFIG_FILE" | cut -d '=' -f2 | tr -d ' ')

TEMPLATE_FILE="MobileBuyIntegration/MobileBuyIntegration.entitlements.template"
OUTPUT_FILE="MobileBuyIntegration/MobileBuyIntegration.entitlements"

if [ -z "$STOREFRONT_DOMAIN" ]; then
echo "Error: STOREFRONT_DOMAIN is not set in Storefront.xcconfig"
exit 1
fi

if [ -e "$OUTPUT_FILE" ]; then
echo "Warning: $OUTPUT_FILE already exists."
exit 0
fi

sed "s/{STOREFRONT_DOMAIN}/$STOREFRONT_DOMAIN?mode=developer/g" "$TEMPLATE_FILE" > "$OUTPUT_FILE"

echo "Success: Entitlements file generated at $OUTPUT_FILE with domain $STOREFRONT_DOMAIN"
5 changes: 5 additions & 0 deletions Scripts/setup_entitlements
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

set -e

(cd samples/MobileBuyIntegration && ./scripts/generate_entitlements.sh)
21 changes: 14 additions & 7 deletions Scripts/test_samples
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,22 @@ set -eo pipefail
if [[ -n $CURRENT_SIMULATOR_UUID ]]; then
dest="id=$CURRENT_SIMULATOR_UUID"
else
dest="platform=iOS Simulator,name=iPhone 14"
dest="platform=iOS Simulator,name=iPhone 16"
fi

cd Samples/

touch SimpleAppIntegration/Storefront.xcconfig
touch MobileBuyIntegration/Storefront.xcconfig
touch SwiftUiExample/Storefront.xcconfig
EMPTY_ENTITLEMENTS="""
<?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\"></plist>
"""

xcodebuild clean build -scheme SimpleAppIntegration -sdk iphonesimulator -destination "$dest" -skipPackagePluginValidation | xcpretty -c
xcodebuild clean build -scheme MobileBuyIntegration -sdk iphonesimulator -destination "$dest" -skipPackagePluginValidation | xcpretty -c
xcodebuild clean build -scheme SwiftUIExample -sdk iphonesimulator -destination "$dest" -skipPackagePluginValidation | xcpretty -c
build_app() {
touch "$1/Storefront.xcconfig"
echo $EMPTY_ENTITLEMENTS > "$1/$1/$1.entitlements"
xcodebuild clean build -scheme $1 -sdk iphonesimulator -destination "$dest" -skipPackagePluginValidation | xcpretty -c
}

build_app SimpleAppIntegration
build_app MobileBuyIntegration
build_app SwiftUIExample
Loading