diff --git a/ios/build.zsh b/ios/build.zsh
index 59fbf46..62294b1 100755
--- a/ios/build.zsh
+++ b/ios/build.zsh
@@ -5,6 +5,14 @@ SCRIPT_DIR=${0:a:h}
cd "$SCRIPT_DIR"
source .env
+function sediment() {
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ sed -i '' "$@"
+ else
+ sed -i "$@"
+ fi
+}
+
# 絶対パスに変換
REPO_DIR="$SCRIPT_DIR/../repos/social-app"
APP_NAME="Aiat"
@@ -41,6 +49,22 @@ else
fi
function cleanup_build {
+ # 1.8. Update package.json version (prevent App Store version conflict)
+ echo "1.8. Updating package.json version..."
+ if [ -n "$APP_VERSION" ]; then
+ PACKAGE_JSON="$REPO_DIR/package.json"
+ # Use node to update version in package.json
+ node -e "
+ const fs = require('fs');
+ const pkg = JSON.parse(fs.readFileSync('$PACKAGE_JSON', 'utf8'));
+ pkg.version = '$APP_VERSION';
+ fs.writeFileSync('$PACKAGE_JSON', JSON.stringify(pkg, null, 2) + '\n');
+ "
+ echo " ✅ Set version to $APP_VERSION"
+ else
+ echo " ⚠️ APP_VERSION not set in .env"
+ fi
+
# 2. Prebuild (Generate ios directory)
echo "2. Running Expo Prebuild..."
# Clean old ios folder to remove old entitlements/AppClip targets
@@ -55,16 +79,50 @@ function cleanup_build {
pod install
cd ..
- # 4. Signing (Manual Step)
- echo "4. Opening Xcode for Signing..."
+ # 4. Signing (Automated)
+ echo "4. Configuring Xcode Signing..."
XCODE_PROJ="ios/${APP_NAME}.xcodeproj"
- # Fallback search if variable name logic differs
if [ ! -d "$XCODE_PROJ" ]; then
XCODE_PROJ=$(find ios -name "*.xcodeproj" | head -n 1)
fi
+ PBXPROJ="$XCODE_PROJ/project.pbxproj"
- open "$XCODE_PROJ"
- read
+ # Set DEVELOPMENT_TEAM in pbxproj
+ if [ -n "$DEVELOPMENT_TEAM" ]; then
+ echo " Setting DEVELOPMENT_TEAM=$DEVELOPMENT_TEAM"
+ sediment "s/PRODUCT_BUNDLE_IDENTIFIER = /DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM; PRODUCT_BUNDLE_IDENTIFIER = /g" "$PBXPROJ"
+ sediment "s/DEVELOPMENT_TEAM = \"\";/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM;/g" "$PBXPROJ"
+ sediment "s/DEVELOPMENT_TEAM = ;/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM;/g" "$PBXPROJ"
+ fi
+
+ # Create/Update entitlements file with App Group
+ ENTITLEMENTS_FILE="ios/${APP_NAME}/${APP_NAME}.entitlements"
+ if [ -n "$APP_GROUP" ]; then
+ echo " Setting APP_GROUP=$APP_GROUP"
+ cat > "$ENTITLEMENTS_FILE" << EOF
+
+
+
+
+ aps-environment
+ production
+ com.apple.security.application-groups
+
+ ${APP_GROUP}
+
+
+
+EOF
+ if ! grep -q "CODE_SIGN_ENTITLEMENTS" "$PBXPROJ"; then
+ sediment "s/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM;/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM; CODE_SIGN_ENTITLEMENTS = ${APP_NAME}\\/${APP_NAME}.entitlements;/g" "$PBXPROJ"
+ fi
+ fi
+
+ echo "✅ Signing configured automatically"
+
+ # (Old manual step - commented out)
+ # open "$XCODE_PROJ"
+ # read
}
case $1 in
@@ -80,11 +138,12 @@ mkdir -p "$BUILD_DIR"
# アーカイブ(詳細ログ出力)
xcodebuild -workspace "$WORKSPACE" \
- -scheme "$SCHEME" \
- -configuration Release \
- -archivePath "$BUILD_DIR/${APP_NAME}.xcarchive" \
- -allowProvisioningUpdates \
- archive 2>&1 | tee "$BUILD_DIR/build.log"
+ -scheme "$SCHEME" \
+ -configuration Release \
+ -archivePath "$BUILD_DIR/${APP_NAME}.xcarchive" \
+ -allowProvisioningUpdates \
+ DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
+ archive 2>&1 | tee "$BUILD_DIR/build.log"
# アーカイブ成功確認
if [ ! -d "$BUILD_DIR/${APP_NAME}.xcarchive" ]; then
diff --git a/ios/preview.zsh b/ios/preview.zsh
index 070c575..0f2802e 100755
--- a/ios/preview.zsh
+++ b/ios/preview.zsh
@@ -5,6 +5,14 @@ cd $d
source $d/.env
+function sediment() {
+ if [[ "$OSTYPE" == "darwin"* ]]; then
+ sed -i '' "$@"
+ else
+ sed -i "$@"
+ fi
+}
+
#xcrun simctl uninstall booted $BUNDLE_ID
echo "Running iOS preview workflow..."
@@ -34,6 +42,21 @@ else
echo "⚠️ Warning: $ASSETS_DIR not found"
fi
+# 1.8. Update package.json version (prevent App Store version conflict)
+echo "1.8. Updating package.json version..."
+if [ -n "$APP_VERSION" ]; then
+ PACKAGE_JSON="$REPO_DIR/package.json"
+ node -e "
+ const fs = require('fs');
+ const pkg = JSON.parse(fs.readFileSync('$PACKAGE_JSON', 'utf8'));
+ pkg.version = '$APP_VERSION';
+ fs.writeFileSync('$PACKAGE_JSON', JSON.stringify(pkg, null, 2) + '\n');
+ "
+ echo " ✅ Set version to $APP_VERSION"
+else
+ echo " ⚠️ APP_VERSION not set in .env"
+fi
+
# 2. Prebuild (Generate ios directory)
echo "2. Running Expo Prebuild..."
# Clean old ios folder to remove old entitlements/AppClip targets
@@ -48,25 +71,62 @@ cd ios
pod install
cd ..
-# 4. Signing (Manual Step)
-echo "4. Opening Xcode for Signing..."
+# 4. Signing (Automated)
+echo "4. Configuring Xcode Signing..."
XCODE_PROJ="ios/${APP_NAME}.xcodeproj"
-# Fallback search if variable name logic differs
if [ ! -d "$XCODE_PROJ" ]; then
XCODE_PROJ=$(find ios -name "*.xcodeproj" | head -n 1)
fi
+PBXPROJ="$XCODE_PROJ/project.pbxproj"
-open "$XCODE_PROJ"
-echo "========================================================"
-echo " [ACTION REQUIRED] "
-echo " Xcode opened ($XCODE_PROJ)."
-echo " 1. Go to 'Signing & Capabilities' tab."
-echo " 2. Select your Team."
-echo " 3. Verify 'App Clip' target is gone."
-echo " 4. Ensure no red errors exist."
-echo " Press ENTER here once you are done to continue building."
-echo "========================================================"
-read
+# Set DEVELOPMENT_TEAM in pbxproj
+if [ -n "$DEVELOPMENT_TEAM" ]; then
+ echo " Setting DEVELOPMENT_TEAM=$DEVELOPMENT_TEAM"
+ # Add DEVELOPMENT_TEAM to all build configurations
+ sediment "s/PRODUCT_BUNDLE_IDENTIFIER = /DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM; PRODUCT_BUNDLE_IDENTIFIER = /g" "$PBXPROJ"
+ # Also set where it might already exist but be empty
+ sediment "s/DEVELOPMENT_TEAM = \"\";/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM;/g" "$PBXPROJ"
+ sediment "s/DEVELOPMENT_TEAM = ;/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM;/g" "$PBXPROJ"
+fi
+
+# Create/Update entitlements file with App Group
+ENTITLEMENTS_FILE="ios/${APP_NAME}/${APP_NAME}.entitlements"
+if [ -n "$APP_GROUP" ]; then
+ echo " Setting APP_GROUP=$APP_GROUP"
+ cat > "$ENTITLEMENTS_FILE" << EOF
+
+
+
+
+ aps-environment
+ development
+ com.apple.security.application-groups
+
+ ${APP_GROUP}
+
+
+
+EOF
+ # Add CODE_SIGN_ENTITLEMENTS to pbxproj if not present
+ if ! grep -q "CODE_SIGN_ENTITLEMENTS" "$PBXPROJ"; then
+ sediment "s/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM;/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM; CODE_SIGN_ENTITLEMENTS = ${APP_NAME}\\/${APP_NAME}.entitlements;/g" "$PBXPROJ"
+ fi
+fi
+
+echo "✅ Signing configured automatically"
+
+# (Old manual step - commented out)
+# open "$XCODE_PROJ"
+# echo "========================================================"
+# echo " [ACTION REQUIRED] "
+# echo " Xcode opened ($XCODE_PROJ)."
+# echo " 1. Go to 'Signing & Capabilities' tab."
+# echo " 2. Select your Team."
+# echo " 3. Verify 'App Clip' target is gone."
+# echo " 4. Ensure no red errors exist."
+# echo " Press ENTER here once you are done to continue building."
+# echo "========================================================"
+# read
# 5. Run
echo "5. Building and Running..."