ai/at
1
0

add ios social-app

This commit is contained in:
2025-12-06 21:14:08 +09:00
parent 948551c185
commit 2361c87f26
8 changed files with 307 additions and 136 deletions

215
ios/setup.zsh Executable file
View File

@@ -0,0 +1,215 @@
#!/bin/zsh
d=${0:a:h}
cd $d
APP_NAME="syuis"
APP_SLUG="syuis"
APP_SCHEME="syui"
BUNDLE_ID="is.syu"
APP_GROUP="group.is.syu"
SERVICE_URL="https://syu.is"
HELP_URL="https://syu.is/help"
PRIVACY_URL="https://syu.is/privacy"
TERMS_URL="https://syu.is/terms"
REPO_DIR="../repos/social-app"
CONFIG_FILE="$REPO_DIR/app.config.js"
CONSTANTS_FILE="$REPO_DIR/src/lib/constants.ts"
# Sed compatibility wrapper
function sediment() {
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "$@"
else
sed -i "$@"
fi
}
echo "Configuring $APP_NAME..."
# Check if repo exists
if [ ! -d "$REPO_DIR" ]; then
echo "Cloning social-app..."
git clone https://github.com/bluesky-social/social-app "$REPO_DIR"
else
echo "Updating social-app..."
pushd "$REPO_DIR"
git stash -u
if ! git pull; then
echo "Git pull failed. Resetting..."
git reset --hard HEAD
git pull
fi
popd
fi
# Backup config if not exists (or restore from backup to start fresh)
if [ ! -f "$CONFIG_FILE.bak" ]; then
cp "$CONFIG_FILE" "$CONFIG_FILE.bak"
else
cp "$CONFIG_FILE.bak" "$CONFIG_FILE"
fi
# 1. app.config.js modifications
echo "Updating app.config.js..."
# Replace name
sediment "s/name: 'Bluesky'/name: '$APP_NAME'/g" "$CONFIG_FILE"
sediment "s/slug: 'bluesky'/slug: '$APP_SLUG'/g" "$CONFIG_FILE"
sediment "s/scheme: 'bsky'/scheme: '$APP_SCHEME'/g" "$CONFIG_FILE"
# Replace Bundle ID and App Group
sediment "s/xyz.blueskyweb.app/$BUNDLE_ID/g" "$CONFIG_FILE"
sediment "s/group.app.bsky/$APP_GROUP/g" "$CONFIG_FILE"
# REMOVE App Clip Configuration (Critical for Personal Team Signing)
# Use Python for safer multi-line removal than sed
echo "Removing App Clip configuration..."
python3 -c "
import sys
import re
try:
with open('$CONFIG_FILE', 'r') as f:
lines = f.readlines()
with open('$CONFIG_FILE', 'w') as f:
skip = 0
for i, line in enumerate(lines):
if skip > 0:
skip -= 1
continue
# Remove the plugin import line
if 'withStarterPackAppClip.js' in line:
continue
# Check if this line defines the AppClip target
# Structure we expect:
# {
# targetName: 'BlueskyClip',
# ...
# },
# We look for the targetName, and if found, we attempt to remove the preceding '{' line if possible
if \"targetName: 'BlueskyClip'\" in line:
# We found the target. We need to NOT write this line.
# And we need to ensure the PREVIOUS line (which was '{') is not written?
# Since we are writing sequentially, we can't pop easily unless we buffer.
# Actually, simpler: Read file, modify list, write back.
continue
else:
pass
# Retry with list manipulation approach
out = []
i = 0
while i < len(lines):
line = lines[i]
# Remove plugin import
if 'withStarterPackAppClip.js' in line:
i += 1
continue
# Identify the block start
# We look ahead. If lines[i] is '{' and lines[i+1] has 'BlueskyClip', we skip the block.
if i + 1 < len(lines) and lines[i].strip() == '{' and \"targetName: 'BlueskyClip'\" in lines[i+1]:
# Found the start of the block.
# Skip until we find the closing '},'
# Typical block is 4 lines.
# {
# targetName: 'BlueskyClip',
# bundleIdentifier: ...,
# },
# We'll just skip 4 lines to be safe matching the observed file structure
i += 4
continue
out.append(line)
i += 1
f.writelines(out)
except Exception as e:
print(f'Error processing file: {e}')
sys.exit(1)
"
# Inject NSAppTransportSecurity for development/preview (Allow Arbitrary Loads)
if ! grep -q "NSAppTransportSecurity" "$CONFIG_FILE"; then
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' "/ios: {/a\\
infoPlist: {\\
NSAppTransportSecurity: {\\
NSAllowsArbitraryLoads: true,\\
},\\
}," "$CONFIG_FILE"
else
sed -i "/ios: {/a\\
infoPlist: {\\
NSAppTransportSecurity: {\\
NSAllowsArbitraryLoads: true,\\
},\\
}," "$CONFIG_FILE"
fi
fi
# 2. constants.ts modifications
echo "Updating constants.ts..."
sediment "s|export const BSKY_SERVICE = 'https://bsky.social'|export const BSKY_SERVICE = '$SERVICE_URL'|g" "$CONSTANTS_FILE"
sediment "s|export const BSKY_SERVICE_DID = 'did:web:bsky.social'|export const BSKY_SERVICE_DID = 'did:web:syu.is'|g" "$CONSTANTS_FILE"
sediment "s|export const PUBLIC_BSKY_SERVICE = 'https://public.api.bsky.app'|export const PUBLIC_BSKY_SERVICE = 'https://bsky.syu.is'|g" "$CONSTANTS_FILE"
sediment "s|const HELP_DESK_LANG = 'en-us'|const HELP_DESK_LANG = 'ja-jp'|g" "$CONSTANTS_FILE"
sediment "s|export const HELP_DESK_URL = \`https://blueskyweb.zendesk.com/hc/\${HELP_DESK_LANG}\`|export const HELP_DESK_URL = '$HELP_URL'|g" "$CONSTANTS_FILE"
# 3. Footer/Link replacements (Global text replacement for specific URLs)
echo "Replacing links..."
grep -r "https://bsky.social/about/blog" "$REPO_DIR/src" -l | xargs -I {} zsh -c "if [[ \"\$OSTYPE\" == \"darwin\"* ]]; then sed -i '' \"s|https://bsky.social/about/blog|$HELP_URL|g\" {}; else sed -i \"s|https://bsky.social/about/blog|$HELP_URL|g\" {}; fi"
grep -r "https://bsky.social/about/blog/jobs" "$REPO_DIR/src" -l | xargs -I {} zsh -c "if [[ \"\$OSTYPE\" == \"darwin\"* ]]; then sed -i '' \"s|https://bsky.social/about/blog/jobs|$HELP_URL|g\" {}; else sed -i \"s|https://bsky.social/about/blog/jobs|$HELP_URL|g\" {}; fi"
grep -r "/support/privacy" "$REPO_DIR/src" -l | xargs -I {} zsh -c "if [[ \"\$OSTYPE\" == \"darwin\"* ]]; then sed -i '' \"s|/support/privacy|$PRIVACY_URL|g\" {}; else sed -i \"s|/support/privacy|$PRIVACY_URL|g\" {}; fi"
grep -r "/support/tos" "$REPO_DIR/src" -l | xargs -I {} zsh -c "if [[ \"\$OSTYPE\" == \"darwin\"* ]]; then sed -i '' \"s|/support/tos|$TERMS_URL|g\" {}; else sed -i \"s|/support/tos|$TERMS_URL|g\" {}; fi"
# 4. Icon replacement
if [ -f "icon.png" ]; then
echo "Updating icon..."
cp "icon.png" "$REPO_DIR/assets/icon.png"
cp "icon.png" "$REPO_DIR/assets/icon-android-notification.png"
fi
# 5. Build Fixes (Entitlements and NSE Sounds)
echo "Applying build fixes..."
# Fix 1: Create Config Plugin to Allow Entitlements Modification
cat <<EOF > "$REPO_DIR/plugins/withCodeSignEntitlements.js"
const { withXcodeProject } = require('expo/config-plugins');
module.exports = function withCodeSignEntitlements(config) {
return withXcodeProject(config, (config) => {
const xcodeProject = config.modResults;
const configurations = xcodeProject.pbxXCBuildConfigurationSection();
for (const key in configurations) {
const buildSettings = configurations[key].buildSettings;
if (buildSettings) {
buildSettings['CODE_SIGN_ALLOW_ENTITLEMENTS_MODIFICATION'] = 'YES';
}
}
return config;
});
};
EOF
# Register the plugin in app.config.js
# We insert it into the plugins array. Finding a safe anchor.
# 'expo-video' is in the plugins array.
sediment "s/'expo-video',/'expo-video', '.\/plugins\/withCodeSignEntitlements.js',/g" "$CONFIG_FILE"
# Fix 2: Disable soundFiles in Notification Extension to avoid 'no rule to process dm.aiff'
# The main app handles sounds via expo-notifications. The extension adding it as a source fails.
NOTIF_EXT_FILE="$REPO_DIR/plugins/notificationsExtension/withNotificationsExtension.js"
if [ -f "$NOTIF_EXT_FILE" ]; then
echo "Patching withNotificationsExtension.js..."
sediment "s/const soundFiles = \['dm.aiff'\]/const soundFiles = []/g" "$NOTIF_EXT_FILE"
fi
echo "Setup complete. App Clip configuration removed. Build fixes applied."