4
有沒有什麼辦法如何在xcode中有一個框架的兩個版本,一個爲模擬器構建,一個爲生產而建造,另一個在項目中使用,基於我爲什麼構建? 我在製作tvOS應用程序的胖框架時遇到問題(但也適用於iOS),它需要位代碼,所以我認爲這樣的解決方案會是什麼?建築與可可觸摸框架
有沒有什麼辦法如何在xcode中有一個框架的兩個版本,一個爲模擬器構建,一個爲生產而建造,另一個在項目中使用,基於我爲什麼構建? 我在製作tvOS應用程序的胖框架時遇到問題(但也適用於iOS),它需要位代碼,所以我認爲這樣的解決方案會是什麼?建築與可可觸摸框架
我對我的框架項目使用下面的腳本。
將聚合目標添加到您的工作區。在構建階段 - >運行腳本下添加下面的腳本。
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO 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
SIMULATOR_SWIFT_MODULES_DIR="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule/."
if [ -d "${SIMULATOR_SWIFT_MODULES_DIR}" ]; then
cp -R "${SIMULATOR_SWIFT_MODULES_DIR}" "${UNIVERSAL_OUTPUTFOLDER}/${PROJECT_NAME}.framework/Modules/${PROJECT_NAME}.swiftmodule"
fi
# 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_DIR}/${CONFIGURATION}-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}"
你在描述靜態框架嗎?我正在問動態的... – Ondrej
@Ondrej這是我用來創建胖框架的腳本:1.'lipo -create -output「NAME」「Debug-iphonesimulator/NAME.framework/NAME」「Debug-iphoneos /NAME.framework/NAME「''2.'cp -R Debug-iphoneos/NAME.framework ./NAME.framework' 3.'mv NAME。/ NAME.framework/NAME' 4.'xcrun lipo -info NAME.framework/NAME'這可能會以某種方式幫助你。 :) – DevAndArtist
那是蘋果appstore安全嗎? – Ondrej