fix ios build scpt
This commit is contained in:
@@ -5,6 +5,14 @@ SCRIPT_DIR=${0:a:h}
|
|||||||
cd "$SCRIPT_DIR"
|
cd "$SCRIPT_DIR"
|
||||||
source .env
|
source .env
|
||||||
|
|
||||||
|
function sediment() {
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
sed -i '' "$@"
|
||||||
|
else
|
||||||
|
sed -i "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# 絶対パスに変換
|
# 絶対パスに変換
|
||||||
REPO_DIR="$SCRIPT_DIR/../repos/social-app"
|
REPO_DIR="$SCRIPT_DIR/../repos/social-app"
|
||||||
APP_NAME="Aiat"
|
APP_NAME="Aiat"
|
||||||
@@ -41,6 +49,22 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
function cleanup_build {
|
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)
|
# 2. Prebuild (Generate ios directory)
|
||||||
echo "2. Running Expo Prebuild..."
|
echo "2. Running Expo Prebuild..."
|
||||||
# Clean old ios folder to remove old entitlements/AppClip targets
|
# Clean old ios folder to remove old entitlements/AppClip targets
|
||||||
@@ -55,16 +79,50 @@ function cleanup_build {
|
|||||||
pod install
|
pod install
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# 4. Signing (Manual Step)
|
# 4. Signing (Automated)
|
||||||
echo "4. Opening Xcode for Signing..."
|
echo "4. Configuring Xcode Signing..."
|
||||||
XCODE_PROJ="ios/${APP_NAME}.xcodeproj"
|
XCODE_PROJ="ios/${APP_NAME}.xcodeproj"
|
||||||
# Fallback search if variable name logic differs
|
|
||||||
if [ ! -d "$XCODE_PROJ" ]; then
|
if [ ! -d "$XCODE_PROJ" ]; then
|
||||||
XCODE_PROJ=$(find ios -name "*.xcodeproj" | head -n 1)
|
XCODE_PROJ=$(find ios -name "*.xcodeproj" | head -n 1)
|
||||||
fi
|
fi
|
||||||
|
PBXPROJ="$XCODE_PROJ/project.pbxproj"
|
||||||
|
|
||||||
open "$XCODE_PROJ"
|
# Set DEVELOPMENT_TEAM in pbxproj
|
||||||
read
|
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
|
||||||
|
<?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>aps-environment</key>
|
||||||
|
<string>production</string>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>${APP_GROUP}</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
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
|
case $1 in
|
||||||
@@ -80,11 +138,12 @@ mkdir -p "$BUILD_DIR"
|
|||||||
|
|
||||||
# アーカイブ(詳細ログ出力)
|
# アーカイブ(詳細ログ出力)
|
||||||
xcodebuild -workspace "$WORKSPACE" \
|
xcodebuild -workspace "$WORKSPACE" \
|
||||||
-scheme "$SCHEME" \
|
-scheme "$SCHEME" \
|
||||||
-configuration Release \
|
-configuration Release \
|
||||||
-archivePath "$BUILD_DIR/${APP_NAME}.xcarchive" \
|
-archivePath "$BUILD_DIR/${APP_NAME}.xcarchive" \
|
||||||
-allowProvisioningUpdates \
|
-allowProvisioningUpdates \
|
||||||
archive 2>&1 | tee "$BUILD_DIR/build.log"
|
DEVELOPMENT_TEAM="$DEVELOPMENT_TEAM" \
|
||||||
|
archive 2>&1 | tee "$BUILD_DIR/build.log"
|
||||||
|
|
||||||
# アーカイブ成功確認
|
# アーカイブ成功確認
|
||||||
if [ ! -d "$BUILD_DIR/${APP_NAME}.xcarchive" ]; then
|
if [ ! -d "$BUILD_DIR/${APP_NAME}.xcarchive" ]; then
|
||||||
|
|||||||
@@ -5,6 +5,14 @@ cd $d
|
|||||||
|
|
||||||
source $d/.env
|
source $d/.env
|
||||||
|
|
||||||
|
function sediment() {
|
||||||
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
|
sed -i '' "$@"
|
||||||
|
else
|
||||||
|
sed -i "$@"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#xcrun simctl uninstall booted $BUNDLE_ID
|
#xcrun simctl uninstall booted $BUNDLE_ID
|
||||||
|
|
||||||
echo "Running iOS preview workflow..."
|
echo "Running iOS preview workflow..."
|
||||||
@@ -34,6 +42,21 @@ else
|
|||||||
echo "⚠️ Warning: $ASSETS_DIR not found"
|
echo "⚠️ Warning: $ASSETS_DIR not found"
|
||||||
fi
|
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)
|
# 2. Prebuild (Generate ios directory)
|
||||||
echo "2. Running Expo Prebuild..."
|
echo "2. Running Expo Prebuild..."
|
||||||
# Clean old ios folder to remove old entitlements/AppClip targets
|
# Clean old ios folder to remove old entitlements/AppClip targets
|
||||||
@@ -48,25 +71,62 @@ cd ios
|
|||||||
pod install
|
pod install
|
||||||
cd ..
|
cd ..
|
||||||
|
|
||||||
# 4. Signing (Manual Step)
|
# 4. Signing (Automated)
|
||||||
echo "4. Opening Xcode for Signing..."
|
echo "4. Configuring Xcode Signing..."
|
||||||
XCODE_PROJ="ios/${APP_NAME}.xcodeproj"
|
XCODE_PROJ="ios/${APP_NAME}.xcodeproj"
|
||||||
# Fallback search if variable name logic differs
|
|
||||||
if [ ! -d "$XCODE_PROJ" ]; then
|
if [ ! -d "$XCODE_PROJ" ]; then
|
||||||
XCODE_PROJ=$(find ios -name "*.xcodeproj" | head -n 1)
|
XCODE_PROJ=$(find ios -name "*.xcodeproj" | head -n 1)
|
||||||
fi
|
fi
|
||||||
|
PBXPROJ="$XCODE_PROJ/project.pbxproj"
|
||||||
|
|
||||||
open "$XCODE_PROJ"
|
# Set DEVELOPMENT_TEAM in pbxproj
|
||||||
echo "========================================================"
|
if [ -n "$DEVELOPMENT_TEAM" ]; then
|
||||||
echo " [ACTION REQUIRED] "
|
echo " Setting DEVELOPMENT_TEAM=$DEVELOPMENT_TEAM"
|
||||||
echo " Xcode opened ($XCODE_PROJ)."
|
# Add DEVELOPMENT_TEAM to all build configurations
|
||||||
echo " 1. Go to 'Signing & Capabilities' tab."
|
sediment "s/PRODUCT_BUNDLE_IDENTIFIER = /DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM; PRODUCT_BUNDLE_IDENTIFIER = /g" "$PBXPROJ"
|
||||||
echo " 2. Select your Team."
|
# Also set where it might already exist but be empty
|
||||||
echo " 3. Verify 'App Clip' target is gone."
|
sediment "s/DEVELOPMENT_TEAM = \"\";/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM;/g" "$PBXPROJ"
|
||||||
echo " 4. Ensure no red errors exist."
|
sediment "s/DEVELOPMENT_TEAM = ;/DEVELOPMENT_TEAM = $DEVELOPMENT_TEAM;/g" "$PBXPROJ"
|
||||||
echo " Press ENTER here once you are done to continue building."
|
fi
|
||||||
echo "========================================================"
|
|
||||||
read
|
# 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
|
||||||
|
<?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>aps-environment</key>
|
||||||
|
<string>development</string>
|
||||||
|
<key>com.apple.security.application-groups</key>
|
||||||
|
<array>
|
||||||
|
<string>${APP_GROUP}</string>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
||||||
|
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
|
# 5. Run
|
||||||
echo "5. Building and Running..."
|
echo "5. Building and Running..."
|
||||||
|
|||||||
Reference in New Issue
Block a user