title: Swift private Framework with backward xcode version compatibility
body: <p>This is my first framework using Swift language and it's private framework. It's worked as expected until new Xcode 9.3 release. After upgrading newer <code>Xcode</code> got an issue like this <code>Module compiled with Swift 4.0.3 cannot be imported in Swift 4.1</code>.</p>
  
  <p>After that only I realized framework doesn't support auto version (Xcode/Swift) upgrade, Did some search found there is a <code>Universal or Fat Binary Framework</code> single build instead of separate build for real device and simulator which I missed in previously.</p>
  
  <pre><code>UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
  
  # Make sure the output directory exists
  
  mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
  
  # Next, work out if we're in SIM or DEVICE
  
  xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
  
  xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos  BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
  
  # Step 2. Copy the framework structure (from iphoneos build) to the universal folder
  
  cp -R "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework" "${UNIVERSAL_OUTPUTFOLDER}/"
  
  # Step 3. Copy Swift modules from iphonesimulator build (if it exists) to the copied framework directory
  
  BUILD_PRODUCTS="${SYMROOT}/../../../../Products"
  
  cp -R "${BUILD_PRODUCTS}/Debug-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/." "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
  
  # Step 4. Create universal binary file using lipo and place the combined executable in the copied framework directory
  
  lipo -create -output "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_PRODUCTS}/Debug-iphonesimulator/${PROJECT_NAME}.framework/${PROJECT_NAME}" "${BUILD_DIR}/${CONFIGURATION}-iphoneos/${PROJECT_NAME}.framework/${PROJECT_NAME}"
  
  # Step 5. Convenience step to copy the framework to the project's directory
  
  cp -R "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework" "${PROJECT_DIR}"
  
  # Step 6. Convenience step to open the project's directory in Finder
  open "${PROJECT_DIR}"
  fi
  </code></pre>
  
  <p>At <code>Edit Scheme</code> -> <code>Archive</code> -> <code>Post-Action</code> -> <code>Run Script</code></p>
  
  <p>This time I am used <code>Swift Compiler - Language</code> -> <code>Swift 3.3</code></p>
  
  <p>And I got expected output this time too in <code>Xcode 9.3</code> with <code>Swift 4.1</code></p>
  
  <p>When I try to run the project with this framework at <code>Xcode 9.2</code> it's show error like this
  <code>Module compiled with Swift 4.1 cannot be imported in Swift 3.2.3:</code></p>
  
  <p>Try to resolve with backward compatibility and I didn't find. How can I run this framework in <code>Xcode 9.2</code></p>
  
  <p>Framework support: <code>Swift</code> and <code>Objective C</code>, Min OS <code>iOS 8.0</code></p>
  
  <h1>**Update**</h1>
  
  <p>Also got something like this error
  <code>compiled with newer version of Swift language (unknown ABI version 0x06) than previous files (4.0) file 'MAC location' for architecture armv7</code>
  And tried <a href="https://stackoverflow.com/a/39657541">this to my project</a></p>