title: Xcode 12.4 Builds for Simulator and Device but Archiving Fails with Pods-MYAPP-frameworks.sh: line 131: ARCHS[@]: unbound variable
body: <p>I am using Xcode 12.4 (updated from 12.2 hoping that my problem would be fixed). As you know with xcode 12.x we deleted VALIDARCHS, added arm64 to excluded archs in project and pod files (for simulators only). Otherwise there were build problems. I have finished my development and I am ready for apple's test flight and then eventually app store. As you know we need to archive the app and upload from organizer. However, my application's archiving fails.
  My problem is that I can successfully build my application for all of simulators and real devices however, when I try to archive the app it gives me an error:</p>
  <p><a href="https://i.stack.imgur.com/Bzlfw.png" rel="nofollow noreferrer">Error Image Here</a></p>
  <p>The bash script is PODS' script line 131 is part:
  intersected_archs=&quot;$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)&quot;</p>
  <pre><code># Strip invalid architectures
  strip_invalid_archs() {
    binary=&quot;$1&quot;
    warn_missing_arch=${2:-true}
    # Get architectures for current target binary
    binary_archs=&quot;$(lipo -info &quot;$binary&quot; | rev | cut -d ':' -f1 | awk '{$1=$1;print}' | rev)&quot;
    # Intersect them with the architectures we are building for
    intersected_archs=&quot;$(echo ${ARCHS[@]} ${binary_archs[@]} | tr ' ' '\n' | sort | uniq -d)&quot;
    # If there are no archs supported by this binary then warn the user
    if [[ -z &quot;$intersected_archs&quot; ]]; then
      if [[ &quot;$warn_missing_arch&quot; == &quot;true&quot; ]]; then
        echo &quot;warning: [CP] Vendored binary '$binary' contains architectures ($binary_archs) none of which match the current build architectures ($ARCHS).&quot;
      fi
      STRIP_BINARY_RETVAL=1
      return
    fi
    stripped=&quot;&quot;
    for arch in $binary_archs; do
      if ! [[ &quot;${ARCHS}&quot; == *&quot;$arch&quot;* ]]; then
        # Strip non-valid architectures in-place
        lipo -remove &quot;$arch&quot; -output &quot;$binary&quot; &quot;$binary&quot;
        stripped=&quot;$stripped $arch&quot;
      fi
    done
    if [[ &quot;$stripped&quot; ]]; then
      echo &quot;Stripped $binary of architectures:$stripped&quot;
    fi
    STRIP_BINARY_RETVAL=0
  }
  </code></pre>
  <p>What I have done so far?</p>
  <ul>
  <li>Probably checked every solution on stackoverflow,apple forums, github etc.</li>
  <li>My source variable in the script is changed to source:-  as you can see in the previous picture</li>
  <li>I tried xcodebuild archive and other things gone bad there so I dont want to touch terminal for archive.</li>
  <li>While looking for solutions as post install workaround for podfile, I changed it but nothing worked.</li>
  <li>Tried different configs for both project and pods.</li>
  <li>Tried to make a workaround in strip_invalid_archs() in the bash script but obtained other errors.</li>
  <li>Even tried to manually define ARCHS in strip_invalid_archs() since I could not find anything</li>
  </ul>
  <p>I feel like something is wrong with architectures and since archiving needs all of the available  archs, it somehow cant archive it. I also think that it is a pod issue but I am really lost.</p>
  <p>Here are my project and pod configs for architectures:</p>
  <p><a href="https://i.stack.imgur.com/Ljqo7.png" rel="nofollow noreferrer">Project</a></p>
  <p><a href="https://i.stack.imgur.com/nGHoy.png" rel="nofollow noreferrer">Pod</a></p>
  <pre><code># Uncomment the next line to define a global platform for your project
  platform :ios, '14.3'
  minimum_deployment_target = 14.3
  
  target 'MYAPP' do
    # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
    use_frameworks!
  
    # Pods for MYAPP
  pod 'Firebase/Core'
  pod 'Firebase/Auth'
    pod 'Firebase/Database'
          pod 'Firebase/Firestore'
    pod 'Firebase/Storage'
  pod 'Firebase/Messaging'
  target 'MYAPPTests' do
      inherit! :search_paths
      # Pods for testing
    end
  
    target 'MYAPPUITests' do
      inherit! :search_paths
      # Pods for testing
    end
  
  post_install do |installer|
      installer.generated_projects.each do |project|
          project.targets.each do |target|
              target.build_configurations.each do |config|
                  # Ensure we set all Pods to match the minimum deployment target specified by the app
                  config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = minimum_deployment_target
              end
          end
      end
  installer.pods_project.build_configuration_list.build_configurations.each do |configuration|
          configuration.build_settings['ARCHS'] = 'arm64 armv7'
      end
  end
  
  
  
  end
  
  
  </code></pre>
  <p><em><strong><strong>EDIT</strong></strong></em>
  The postinstall part in the podfile was added after the archiving failed. Archiving does not work even if I dont have postinstall part in my podfile.</p>
  <p>Thanks in advance. It is really disappointing to not be able to archive the app when I think I finished it. I have already spent a few days just on this. It would be great if you can help. Thank you</p>