ai/at
1
0

add ios social-app

This commit is contained in:
2025-12-06 21:14:08 +09:00
parent 948551c185
commit 5362bf7f7b
36 changed files with 400 additions and 159 deletions

232
ios/setup.zsh Executable file
View File

@@ -0,0 +1,232 @@
#!/bin/zsh
d=${0:a:h}
cd $d
source $d/config.zsh
# 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 [ -d "app-icons" ]; then
echo "Updating icons from app-icons/ directory..."
# Copy the entire contents of the user-provided app-icons directory to the repo's assets/app-icons
# This covers all variants (Aurora, Bonfire, etc.) as the user has prepared them.
cp -rf "app-icons/"* "$REPO_DIR/assets/app-icons/"
# Also update the main app icons referenced by default
if [ -f "app-icons/ios_icon_default_next.png" ]; then
cp "app-icons/ios_icon_default_next.png" "$REPO_DIR/assets/icon.png"
cp "app-icons/ios_icon_default_next.png" "$REPO_DIR/assets/icon-android-notification.png"
fi
# Force app.config.js to use the 'default_next' PNG instead of the complex .icon directory
sediment "s|'./assets/app-icons/ios_icon_default.icon'|'./assets/app-icons/ios_icon_default_next.png'|g" "$CONFIG_FILE"
elif [ -f "icon.png" ]; then
echo "Updating ALL icons from single icon.png..."
# 1. Overwrite the files that app.config.js points to by default
cp "icon.png" "$REPO_DIR/assets/icon.png"
cp "icon.png" "$REPO_DIR/assets/icon-android-notification.png"
# 2. Overwrite ALL icons in app-icons/ since no specific set was provided
echo "Overwriting all assets/app-icons/*.png..."
find "$REPO_DIR/assets/app-icons" -name "*.png" -exec cp "icon.png" {} \;
# 3. Handle ios_icon_default.icon special case
TARGET_ICON_DIR="$REPO_DIR/assets/app-icons/ios_icon_default.icon"
if [ -d "$TARGET_ICON_DIR" ]; then
cp "icon.png" "$TARGET_ICON_DIR/icon.png" 2>/dev/null || true
fi
# 4. Force app.config.js to point to PNG
sediment "s|'./assets/app-icons/ios_icon_default.icon'|'./assets/app-icons/ios_icon_default_next.png'|g" "$CONFIG_FILE"
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."