Crear un marco universal de iOS

He creado un marco iOS universal. En Xcode, es un "objective agregado" que utiliza un script de construcción y la herramienta de línea de command lipo para poner iphonesimulator y iphoneos-binarys en un solo contenedor binary. El command para build el iphonesimulator-binary es

 xcodebuild -project MMFramework.xcodeproj -scheme "$SCHEME_NAME" \ -sdk iphonesimulator -configuration ${CONFIGURATION} clean build \ CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator 

(He reemplazado el nombre del proyecto por "MMFramework", pero este no es el problema).

Al usar Xcode 6, el iphonesimulator binary crea sin problemas. Cuando uso Xcode 7 obtengo errores, como, por ejemplo,

 // (with Xcode 7) #import <sys/utsname.h> ^^Error: Could not build module 'Darwin' 

Además, xcodebuild se comporta de manera diferente en Xcode7. Xcode 6 traduce mi command xcodebuild a llamadas como

 # with Xcode 6 CompileC build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/Objects-normal/i386/MPThreadIdAtom.o MPThreadIdAtom.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler cd /Volumes/Development/myProject/frameworks/MMFramework export LANG=en_US.US-ASCII /Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch i386 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=/Users/michael/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/michael/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Xclang -fmodule-implementation-of -Xclang MMFramework -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclanetworking-selector -Wno-deprecated-implementations -DDEBUG=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode6.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator8.4.sdk -fexceptions -fasm-blocks -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -g -Wno-sign-conversion -fobjc-abi-version=2 -fobjc-legacy-dispatch -mios-simulator-version-min=7.0 -iquote /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/MMFramework-generated-files.hmap -I/Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/MMFramework-own-target-headers.hmap -I/Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/MMFramework-all-non-framework-target-headers.hmap -ivfsoverlay /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/all-product-headers.yaml -iquote /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/MMFramework-project-headers.hmap -I/Volumes/Development/myProject/frameworks/MMFramework/build/Debug-iphonesimulator/include -I/Applications/Xcode6.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include -I/Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/DerivedSources/i386 -I/Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/DerivedSources -F/Volumes/Development/myProject/frameworks/MMFramework/build/Debug-iphonesimulator -MMD -MT dependencies -MF /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/Objects-normal/i386/MPThreadIdAtom.d --serialize-diagnostics /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/Objects-normal/i386/MPThreadIdAtom.dia -c /Volumes/Development/myProject/frameworks/MMFramework/MPThreadIdAtom.m -o /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphonesimulator/iOSMMFramework.build/Objects-normal/i386/MPThreadIdAtom.o 

Pero con Xcode 7, puede ver que finalmente cree que el iphonesimulator se ejecuta en la plataforma ARM. Parece confundido si quiere build un iphonesimulator o un iphoneos-binary.

 # With Xcode 7 CompileC build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/Objects-normal/armv7/MPThreadIdAtom.o MPThreadIdAtom.m normal armv7 objective-c com.apple.compilers.llvm.clang.1_0.compiler cd /Volumes/Development/myProject/frameworks/MMFramework export LANG=en_US.US-ASCII export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/libexec:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/bin:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/usr/local/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/local/bin:/Applications/Xcode.app/Contents/Developer/Tools:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -gmodules -fmodules-cache-path=/Users/michael/Library/Developer/Xcode/DerivedData/ModuleCache -fmodules-prune-interval=86400 -fmodules-prune-after=345600 -fbuild-session-file=/Users/michael/Library/Developer/Xcode/DerivedData/ModuleCache/Session.modulevalidation -fmodules-validate-once-per-build-session -Wnon-modular-include-in-framework-module -Werror=non-modular-include-in-framework-module -Xclang -fmodule-implementation-of -Xclang MMFramework -Wno-trigraphs -fpascal-strings -O0 -fno-common -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wunreachable-code -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wconditional-uninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-selector-match -Wundeclanetworking-selector -Wno-deprecated-implementations -DDEBUG=1 -DOBJC_OLD_DISPATCH_PROTOTYPES=0 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk -fstrict-aliasing -Wprotocol -Wdeprecated-declarations -miphoneos-version-min=7.0 -g -Wno-sign-conversion -fobjc-abi-version=2 -iquote /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/MMFramework-generated-files.hmap -I/Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/MMFramework-own-target-headers.hmap -I/Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/MMFramework-all-non-framework-target-headers.hmap -ivfsoverlay /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/all-product-headers.yaml -iquote /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/MMFramework-project-headers.hmap -I/Volumes/Development/myProject/frameworks/MMFramework/build/Debug-iphonesimulator/include -I/Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/DerivedSources/armv7 -I/Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/DerivedSources -F/Volumes/Development/myProject/frameworks/MMFramework/build/Debug-iphonesimulator -MMD -MT dependencies -MF /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/Objects-normal/armv7/MPThreadIdAtom.d --serialize-diagnostics /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/Objects-normal/armv7/MPThreadIdAtom.dia -c /Volumes/Development/myProject/frameworks/MMFramework/MPThreadIdAtom.m -o /Volumes/Development/myProject/frameworks/MMFramework/build/Intermediates/MMFramework.build/Debug-iphoneos/iOSMMFramework.build/Objects-normal/armv7/MPThreadIdAtom.o While building module 'Foundation' imported from /Volumes/Development/myProject/frameworks/MMFramework/MPThreadIdAtom.h:9: While building module 'CoreFoundation' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6: While building module 'Darwin' imported from /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/System/Library/Frameworks/CoreFoundation.framework/Headers/CoreFoundation.h:11: In file included from <module-includes>:1: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.2.sdk/usr/include/sys/cdefs.h:707:2: error: Unsupported architecture #error Unsupported architecture 

Entonces, ¿alguien ha creado un marco universal de iOS con Xcode 7 con éxito? ¿O cometí algún error?

Xcode 7 es la versión seleccionada en mi sistema:

 $ xcode-select -p /Applications/Xcode.app/Contents/Developer 

Se instala bajo /Applications/Xcode.app y Xcode 6 vive bajo /Applications/Xcode6.app.


Aquí está mi script de compilation:

 #!/bin/sh echo "XXX 0" ###################### # Options ###################### FRAMEWORK_NAME="MMFramework" SCHEME_NAME="iOSMMFramework" SIMULATOR_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework" DEVICE_LIBRARY_PATH="${BUILD_DIR}/${CONFIGURATION}-iphoneos/${FRAMEWORK_NAME}.framework" UNIVERSAL_LIBRARY_DIR="${BUILD_DIR}/${CONFIGURATION}-iphoneuniversal" FRAMEWORK="${UNIVERSAL_LIBRARY_DIR}/${FRAMEWORK_NAME}.framework" ###################### # Build Frameworks ###################### echo "XXX 1" xcodebuild -project MMFramework.xcodeproj -scheme "$SCHEME_NAME" -sdk iphonesimulator -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphonesimulator 2>&1 echo "XXX 2" xcodebuild -project MMFramework.xcodeproj -scheme "$SCHEME_NAME" -sdk iphoneos -configuration ${CONFIGURATION} clean build CONFIGURATION_BUILD_DIR=${BUILD_DIR}/${CONFIGURATION}-iphoneos 2>&1 ###################### # Create directory for universal ###################### echo "XXX 3" rm -rf "${UNIVERSAL_LIBRARY_DIR}" mkdir "${UNIVERSAL_LIBRARY_DIR}" mkdir "${FRAMEWORK}" ###################### # Copy files Framework ###################### echo "XXX 5" cp -r "${DEVICE_LIBRARY_PATH}/." "${FRAMEWORK}" ###################### # Make an universal binary ###################### echo "XXX 7" lipo "${SIMULATOR_LIBRARY_PATH}/${FRAMEWORK_NAME}" "${DEVICE_LIBRARY_PATH}/${FRAMEWORK_NAME}" -create -output "${FRAMEWORK}/${FRAMEWORK_NAME}" | echo echo "XXX 8" # For Swift framework, Swiftmodule needs to be copied in the universal framework if [ -d "${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then cp -f ${SIMULATOR_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo fi if [ -d "${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/" ]; then cp -f ${DEVICE_LIBRARY_PATH}/Modules/${FRAMEWORK_NAME}.swiftmodule/* "${FRAMEWORK}/Modules/${FRAMEWORK_NAME}.swiftmodule/" | echo fi echo "XXX 9" 

y mi objective universal Xcode contiene dos fases de compilation: "Dependencias de destino (0 elementos)" y "Ejecutar secuencia de commands". El guión es:

 iOSMMFramework/universal-buildscript.sh 2>&1 |tee ~/my-log.txt 

el my-log.txt es solo para debugging, y de ahí es de donde obtuve los files de logging.

Xcode 6 tiene un SDKROOT de "iphonesimulator8.4", Xcode 7 tiene un SDKROOT de "iphonesimulator9.2".

Y he personalizado la location de la carpeta de compilation en PROJECT_DIR / build. (Sin embargo, cambiarlo a la location pnetworkingeterminada no hace una diferencia.)


Con Xcode 7.2 (7C68) NO funciona. Con Xcode 6.4 (6E35b) funciona.

Estoy usando el mismo command y puedo crear un marco universal.

 xcodebuild -project "${PROJECT_FILE_PATH}" \ -target "${TARGET_NAME}" \ -configuration "${CONFIGURATION}" \ -sdk "${1}" \ ONLY_ACTIVE_ARCH=NO \ BUILD_DIR="${BUILD_DIR}" \ OBJROOT="${OBJROOT}" \ BUILD_ROOT="${BUILD_ROOT}" \ SYMROOT="${SYMROOT}" 

¿Puedes intentar eliminar el command clean build de xcodebuild? Uso diferente shellscript.