Tôi đã xây dựng một khung công tác trong Swift. Khuôn khổ sử dụng Cocoapods, một trong các cụm được viết trong Objective C.Khung mỡ nhanh w/Mục tiêu-C Cocoapod
Tôi cũng sử dụng tập lệnh tùy chỉnh để làm cho khung làm khuôn khổ chất béo để hỗ trợ các hệ thống 32/64 bit. (Điều này chạy trong một mục tiêu riêng về dự án và tôi tự hỏi nếu có điều gì đó để làm gì với nó?)
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
if [ "true" == ${ALREADYINVOKED:-false} ]
then
echo "RECURSION: Detected, stopping"
else
export ALREADYINVOKED="true"
// 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) to the copied framework directory
cp -R "${BUILD_DIR}/${CONFIGURATION}-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_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}"
fi
Khi tôi tạo ra khuôn khổ mỡ này và đặt nó vào một dự án tôi muốn sử dụng nó trên trình biên dịch luôn thất bại b/c dự án không thể nhìn thấy mục tiêu C ca cao pod mô-đun.
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ld: framework not found Pusher for architecture x86_64
Không tìm thấy kiến trúc nào khi tôi thay đổi nền tảng xây dựng.
Bất kỳ giải pháp nào tôi có thể tạo một khung mà tôi có thể sử dụng trong một dự án Xcode riêng biệt (cho tất cả iOS hoặc OS X) sẽ thật tuyệt vời.
Tôi tin rằng nó được quản lý bởi ONLY_ACTIVE_ARCH = NO args. Bên cạnh đó nó cũng hoạt động khi không có một cụm ca cao C-Objective. –