Xcode 11ã§å°å ¥ãããxcframeworkã®ãã£ã¬ã¯ããªæ§é
WWDC19ã§ãç®è¦ãããXcode 11ã§ãããã©ã¤ãã©ãªã»ãã¬ã¼ã ã¯ã¼ã¯ã®é
å¸å½¢æ
ã¨ã㦠.xcframework
ã¨ããæ°ãããã©ã¼ããããå°å
¥ããã¦ãã¾ãã
https://developer.apple.com/documentation/xcode_release_notes/xcode_11_beta_release_notes/#3318305
XCFrameworks make it possible to bundle a binary framework or library for multiple platforms âincluding iOS devices, iOS simulators, and UIKit for Mac â into a single distributable .xcframework bundle that your developers can use within their own applications. An .xcframework bundle can be added to an Xcode targetâs Link Libraries phase and Xcode uses the right platformâs version of the included framework or library at build time. Creation of XCFrameworks is supported from the command line using xcodebuild -create-xcframework. Frameworks or libraries bundled in an XCFramework should be built with the Build Libraries for Distribution build setting set to YES. (49948269)
ãã®ãã©ã¼ãããã®å°å ¥ã¯ããªãªã¼ã¹ãã¼ãã«ãæ¸ããã¦ããããã«UIKit for Macï¼Project Catalystï¼ã¨é¢ä¿ãã¦ãããã§ããããã ãã§ã¯ãªããSwift 5.1ã§ã®Module Stability*1ãµãã¼ãã«ãããSwiftã§æ¸ããããã¬ã¼ã ã¯ã¼ã¯ã®ãã¤ããªé å¸ã¨ãé¢é£ããåãã«è¦ãã¾ãã
ããã¾ã§ã¯ãå種SDKãªã©ã§iOSç¨ã®ãã¬ã¼ã ã¯ã¼ã¯ï¼.framework
å½¢å¼ï¼ãé
å¸ããå ´åãiOSã·ãã¥ã¬ã¼ã¿ã¼ç¨ã®frameworkã¨ãiOSããã¤ã¹ç¨ã®frameworkããããããã«ããã¦ãããframeworkã®ãã³ãã«å
ã«å«ã¾ãããã¤ããªãlipo
ã³ãã³ãã§çµåãã¦1ã¤ã®frameworkã«ãããã¨ããæ段ãåããã¦ãã¾ãããCarthageã§frameworkããã«ãããæãããããå¦çãè¡ããã¦ãã¾ãã
ãã ããã®æ¹æ³ã«ã¯å°ãåé¡ããããiOSã¢ããªãApp Storeã«æåºããéã®ããªãã¼ã·ã§ã³ã§ãã¢ããªã«å«ã¾ããframeworkã®ãã¤ããªã«ã·ãã¥ã¬ã¼ã¿ã¼ç¨ã®CPUã¢ã¼ããã¯ãã£ã¼ã®ã¹ã©ã¤ã¹ãå«ã¾ãã¦ããã¨ããªãã¼ã·ã§ã³ã§è¹´ããã¦ãã¾ãã¾ãããã®ããã¹ãã¢æåºç¨ã®ãªãªã¼ã¹ãã«ããè¡ãéã«ã¯ãlipo
ã³ãã³ãã§ã·ãã¥ã¬ã¼ã¿ã¼ç¨ã®ã¹ã©ã¤ã¹ãåãé¤ãå¿
è¦ãããã¾ããCarthageã§ã¯ãã®åé¡ã®å¯¾å¦ã¨ãã¦ãã¢ããªã«frameworkãçµã¿è¾¼ãéã«carthage copy-frameworks
ã³ãã³ãã使ãããã«ãªã£ã¦ãã¾ãã
ä¸æ¹ãæ°ãã.xcframework
å½¢å¼ã§ã¯ãè¤æ°ã®.framework
ã1ã¤ã®ãã³ãã«ï¼ãã£ã¬ã¯ããªï¼ã«ã¾ã¨ããæ§é ã¨ãªã£ã¦ãã¾ãããã®æ§é ã§ã¯ãã¢ããªãããã¤ã¹åãã«ãã«ãããæã«ã¯xcframeworkå
ã®ããã¤ã¹ç¨ã®frameworkãã·ãã¥ã¬ã¼ã¿ã¼åãã«ãã«ãããæã«ã¯ã·ãã¥ã¬ã¼ã¿ã¼ç¨ã®frameworkã使ããã¨ãã§ããã®ã§ãã¹ãã¢æåºç¨ã®ã¢ããªã«ã·ãã¥ã¬ã¼ã¿ã¼ç¨ã®ã¹ã©ã¤ã¹ãå«ã¾ãã¦ãã¾ãã¨ãããã¨ãèµ·ããªããªãã¾ããCarthageã§ãxcframeworkããµãã¼ããããã¨ãcopy-frameworks
ã³ãã³ãã使ç¨ããå¿
è¦ããªããªããã¨ãæå¾
ã§ãã¾ã*2ã
å®éã«.xcframework
ãçæãã¦ãã£ã¬ã¯ããªæ§é ã確èªãã¦ã¿ã¾ãããã·ãã¥ã¬ã¼ã¿ã¼ç¨ã»ããã¤ã¹ç¨ã»UIKit for Macç¨ã®frameworkã¯å
ã«ãã«ãããä¸ã§ãxcframeworkã®çæã¯æ¬¡ã®ã³ãã³ãã§è¡ãã¾ã:
$ xcodebuild -create-framework \ -framework iphonesimulator/Himotoki.framework \ -framework iphoneos/Himotoki.framework \ -framework uikitformac/Himotoki.framework \ -output Himotoki.xcframework
ãã£ã¬ã¯ããªæ§é ã¯æ¬¡ã®ããã«ãªã£ã¦ãã¾ããã
$ tree Himotoki.xcframework Himotoki.xcframework âââ Info.plist âââ ios-armv7_arm64 â  âââ Himotoki.framework â  âââ Headers â  â  âââ Himotoki-Swift.h â  â  âââ Himotoki.h â  âââ Himotoki â  âââ Info.plist â  âââ Modules â  âââ Himotoki.swiftmodule â  â  âââ arm.swiftdoc â  â  âââ arm.swiftinterface â  â  âââ arm.swiftmodule â  â  âââ arm64-apple-ios.swiftdoc â  â  âââ arm64-apple-ios.swiftinterface â  â  âââ arm64-apple-ios.swiftmodule â  â  âââ arm64.swiftdoc â  â  âââ arm64.swiftinterface â  â  âââ arm64.swiftmodule â  â  âââ armv7-apple-ios.swiftdoc â  â  âââ armv7-apple-ios.swiftinterface â  â  âââ armv7-apple-ios.swiftmodule â  â  âââ armv7.swiftdoc â  â  âââ armv7.swiftinterface â  â  âââ armv7.swiftmodule â  âââ module.modulemap âââ ios-i386_x86_64-simulator â  âââ Himotoki.framework â  âââ Headers â  â  âââ Himotoki-Swift.h â  â  âââ Himotoki.h â  âââ Himotoki â  âââ Info.plist â  âââ Modules â  â  âââ Himotoki.swiftmodule â  â  â  âââ i386-apple-ios-simulator.swiftdoc â  â  â  âââ i386-apple-ios-simulator.swiftinterface â  â  â  âââ i386-apple-ios-simulator.swiftmodule â  â  â  âââ i386.swiftdoc â  â  â  âââ i386.swiftinterface â  â  â  âââ i386.swiftmodule â  â  â  âââ x86_64-apple-ios-simulator.swiftdoc â  â  â  âââ x86_64-apple-ios-simulator.swiftinterface â  â  â  âââ x86_64-apple-ios-simulator.swiftmodule â  â  â  âââ x86_64.swiftdoc â  â  â  âââ x86_64.swiftinterface â  â  â  âââ x86_64.swiftmodule â  â  âââ module.modulemap â  âââ _CodeSignature â  âââ CodeResources âââ ios-x86_64-uikitformac âââ Himotoki.framework âââ Headers -> Versions/Current/Headers âââ Himotoki -> Versions/Current/Himotoki âââ Modules -> Versions/Current/Modules âââ Resources -> Versions/Current/Resources âââ Versions âââ A â  âââ Headers â  â  âââ Himotoki-Swift.h â  â  âââ Himotoki.h â  âââ Himotoki â  âââ Modules â  â  âââ Himotoki.swiftmodule â  â  â  âââ x86_64-apple-ios-macabi.swiftdoc â  â  â  âââ x86_64-apple-ios-macabi.swiftinterface â  â  â  âââ x86_64-apple-ios-macabi.swiftmodule â  â  â  âââ x86_64.swiftdoc â  â  â  âââ x86_64.swiftinterface â  â  â  âââ x86_64.swiftmodule â  â  âââ module.modulemap â  âââ Resources â  âââ Info.plist âââ Current -> A
ios-armv7_arm64
ã«ããã¤ã¹ç¨ã®frameworkããios-x86_64-simulator
ã«ã·ãã¥ã¬ã¼ã¿ã¼ç¨ã®frameworkããããã¦ios-x86_64-uikitformac
ã«UIKit for Macç¨ã®frameworkãå«ã¾ãã¦ãããã¨ãåããã¾ãã
ã¾ããããã¬ãã«ã®Info.plist
ã®å
容ã¯æ¬¡ã®ããã«ãªã£ã¦ãã¾ããã
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>AvailableLibraries</key> <array> <dict> <key>LibraryIdentifier</key> <string>ios-x86_64-uikitformac</string> <key>LibraryPath</key> <string>Himotoki.framework</string> <key>SupportedArchitectures</key> <array> <string>x86_64</string> </array> <key>SupportedPlatform</key> <string>ios</string> <key>SupportedPlatformVariant</key> <string>uikitformac</string> </dict> <dict> <key>LibraryIdentifier</key> <string>ios-armv7_arm64</string> <key>LibraryPath</key> <string>Himotoki.framework</string> <key>SupportedArchitectures</key> <array> <string>armv7</string> <string>arm64</string> </array> <key>SupportedPlatform</key> <string>ios</string> </dict> <dict> <key>LibraryIdentifier</key> <string>ios-i386_x86_64-simulator</string> <key>LibraryPath</key> <string>Himotoki.framework</string> <key>SupportedArchitectures</key> <array> <string>i386</string> <string>x86_64</string> </array> <key>SupportedPlatform</key> <string>ios</string> <key>SupportedPlatformVariant</key> <string>simulator</string> </dict> </array> <key>CFBundlePackageType</key> <string>XFWK</string> <key>XCFrameworkFormatVersion</key> <string>1.0</string> </dict> </plist>
xcodebuild -create-xcframework
ã³ãã³ãã®-framework
ãªãã·ã§ã³ã®æ°ãå¢ãããã¨ã§ãããã«macOSãtvOSãwatchOSç¨ã®ãã«ãã追å ãããã¨ãã§ããã¯ãã§ãã
ã¾ã.framework
ã ãã§ãªãã.a
ã®static libraryã.dylib
ã®dynamic libraryã¨ããç¨ã®ãããã¼ããã³ãã«ãããã¨ãã§ããããã«ãªã£ã¦ãã¾ããã³ãã³ãã®ãã«ãã®åºåãè¼ãã¦ããã¾ãã
$ xcodebuild -create-xcframework -help OVERVIEW: Utility for packaging multiple build configurations of a given library or framework into a single xcframework. USAGE: xcodebuild -create-xcframework -framework <path> [-framework <path>...] -output <path> xcodebuild -create-xcframework -library <path> [-headers <path>] [-library <path> [-headers <path>]...] -output <path> OPTIONS: -framework <path> Adds a framework from the given <path>. -library <path> Adds a static or dynamic library from the given <path>. -headers <path> Adds the headers from the given <path>. Only applicable with -library. -output <path> The <path> to write the xcframework to. -help Show this help content.
ä»å¾ã®å種ãã¼ã«ãSDKã§ã®ãµãã¼ãã«æå¾ ãããã§ããã