7

这是我第一个使用 Swift 语言的框架,它是私有框架。在新的 Xcode 9.3 发布之前,它按预期工作。升级更新后Xcode遇到这样的问题Module compiled with Swift 4.0.3 cannot be imported in Swift 4.1

在那之后,我才意识到框架不支持自动版本(Xcode/Swift)升级,是否有一些搜索发现有一个Universal or Fat Binary Framework单独的构建,而不是我之前错过的真实设备和模拟器的单独构建。

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

Edit Scheme-> Archive-> Post-Action->Run Script

这次我习惯了Swift Compiler - Language->Swift 3.3

这次我也得到了预期的Xcode 9.3输出Swift 4.1

当我尝试使用此框架运行项目时,Xcode 9.2会显示如下错误 Module compiled with Swift 4.1 cannot be imported in Swift 3.2.3:

尝试通过向后兼容性解决,但我没有找到。我怎样才能运行这个框架Xcode 9.2

框架支持:SwiftObjective C,Min OSiOS 8.0

**更新**

也得到了类似这个错误的东西 并在我的项目中compiled with newer version of Swift language (unknown ABI version 0x06) than previous files (4.0) file 'MAC location' for architecture armv7 尝试了这个

4

0 回答 0