Share
Embed
5分でわかる!Xcode 11から使えるXCFrameworks
「iOSDC Japan 2019」での発表資料です #iosdc
- https://iosdc.jp/2019/
- https://fortee.jp/iosdc-japan-2019/proposal/54d74689-a15f-4807-89e4-08e5ceab0372
Sho Ikeda
September 06, 2019
Annual Pro sale · Save $30
Have presentations of your own?
Share with private links, password protection, and more control over your work.
Transcript
30 slides
-
5ͰΘ͔Δʂ Xcode 11͔Β͑Δ XCFrameworks Sho Ikeda / @ikesyo iOSDC Japan
2019 2019-09-06 Fri #iosdc -
Sho Ikeda / @ikesyo • ͍͚͠ΐʔʗా ᠳ • ͯͳ@ژ •
εϚʔτϑΥϯΞϓϦ։ൃ • iOS / Android / React Native • Swiftίϛολʔ • https://twitter.com/ikesyo • https://github.com/ikesyo -
XCFrameworks • WWDC19ͷηογϣϯ • What's New in Swift - WWDC
2019 - Videos - Apple Developer • Binary Frameworks in Swift - WWDC 2019 - Videos - Apple Developer • [New!] ϑϨʔϜϫʔΫͷόΠφϦ༻ͷ৽ ϑΥʔϚοτ • .xcframework֦ுࢠ -
XCFrameworks Multiplatform Support • 1ͭͷ.xcframeworkͷதʹෳͷϓϥοτϑΥʔ Ϝ༻ͷ.frameworkΛόϯυϧ͢Δ • macOS • iOS
Simulator, iOS Device, Mac Catalyst (UIKit for Mac), • tvOS Simulator, tvOS Device • watchOS Simulator, watchOS Device -
XCFrameworks Mac Catalyst (UIKit for Mac) • Mac CatalystiOSͷѥछ •
͜Ε·ͰͷiOSͰͷόΠφϦ • iOS Deviceͷarmv7ͱarm64ɺiOS Simulatorͷx86_64ʢͱi386ʣ Λ1ͭʹ·ͱΊͨFat Binary • lipoίϚϯυͰ݁߹͢Δ • Mac CatalystCPUΞʔΩςΫνϟx86_64 • 1ͭͷFat BinaryͰiOS SimulatorͱMac CatalystΛڞଘͤ͞ΒΕͳ͍ • ඞવతʹ͢Δඞཁ͕͋Δ -
XCFrameworks Mac Catalyst (UIKit for Mac) • ϓϥοτϑΥʔϜຖʹframework͕͞Ε͍ͯΔ • iOS
SimulatorͱMac Catalyst͕ڞଘͰ͖Δ • carthage copy-frameworks͕ෆཁʹͳΔʢରԠͪʣ • ετΞਃ࣌ʹxcframeworkͷத͔ΒɺiOS Device༻ͷ framework͕ຒΊࠐ·ΕΔʢiOS SimulatorͷຒΊࠐ· Εͳ͍ʣ • ετΞਃ༻ͷFat Binary͔ΒSimulatorͷCPUΞʔΩς ΫνϟΛऔΓআ͘ඞཁ͕ͳ͘ͳΔ -
Build Settings • "Build Libraries for Distribution" • > Frameworks
or libraries bundled in an XCFramework should be built with the Build Libraries for Distribution build setting set to YES. • "Supports Mac Catalyst" • "Derive Mac Catalyst Product Bundle Identifier" -
Building Frameworks • xcodebuild archive: Multiple Destinations including Simulator xcodebuild
archive \ -scheme FooBarBaz-iOS -destination "generic/platform=iOS" \ -destination "generic/platform=iOS Simulator" \ -destination "generic/platform=macOS" SKIP_INSTALL=NO -
Building Frameworks xcodebuild archive -scheme Himotoki-iOS \ -destination "generic/platform=iOS" \
-archivePath build/iphoneos \ SKIP_INSTALL=NO xcodebuild archive -scheme Himotoki-iOS \ -destination "generic/platform=iOS Simulator" \ -archivePath build/iphonesimulator \ SKIP_INSTALL=NO xcodebuild archive -scheme Himotoki-iOS \ -destination "generic/platform=macOS" \ -archivePath build/maccatalyst \ SKIP_INSTALL=NO ... -
Creating XCFrameworks $ xcodebuild -create-xcframework \ -framework build/macosx.xcarchive/Products/@rpath/Himotoki.framework \ -framework
build/iphoneos.xcarchive/Products/@rpath/Himotoki.framework \ -framework build/iphonesimulator.xcarchive/Products/@rpath/Himotoki.framework \ -framework build/maccatalyst.xcarchive/Products/@rpath/Himotoki.framework \ -framework build/appletvos.xcarchive/Products/@rpath/Himotoki.framework \ -framework build/appletvsimulator.xcarchive/Products/@rpath/Himotoki.framework \ -framework build/watchos.xcarchive/Products/@rpath/Himotoki.framework \ -framework build/watchsimulator.xcarchive/Products/@rpath/Himotoki.framework \ -output Himotoki.xcframework -
XCFrameworks: Directory Structure Himotoki.xcframework ├── Info.plist ├── ios-armv7_arm64 │ └──
Himotoki.framework ├── ios-i386_x86_64-simulator │ └── Himotoki.framework ├── ios-x86_64-maccatalyst │ └── Himotoki.framework ├── macos-x86_64 │ └── Himotoki.framework ├── tvos-arm64 │ └── Himotoki.framework ├── tvos-x86_64-simulator │ └── Himotoki.framework ├── watchos-armv7k_arm64_32 │ └── Himotoki.framework └── watchos-i386-simulator └── Himotoki.framework -
XCFrameworks: 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>watchos-armv7k_arm64_32</string> <key>LibraryPath</key> <string>Himotoki.framework</string> <key>SupportedArchitectures</key> <array> <string>armv7k</string> <string>arm64_32</string> </array> <key>SupportedPlatform</key> <string>watchos</string> </dict> <dict> <key>LibraryIdentifier</key> <string>watchos-i386-simulator</string> <key>LibraryPath</key> <string>Himotoki.framework</string> <key>SupportedArchitectures</key> <array> <string>i386</string> </array> <key>SupportedPlatform</key> <string>watchos</string> <key>SupportedPlatformVariant</key> <string>simulator</string> </dict> <dict> <key>LibraryIdentifier</key> <string>ios-x86_64-maccatalyst</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>maccatalyst</string> </dict> <dict> <key>LibraryIdentifier</key> <string>macos-x86_64</string> <key>LibraryPath</key> <string>Himotoki.framework</string> <key>SupportedArchitectures</key> <array> <string>x86_64</string> </array> <key>SupportedPlatform</key> <string>macos</string> </dict> <dict> <key>LibraryIdentifier</key> <string>tvos-x86_64-simulator</string> <key>LibraryPath</key> <string>Himotoki.framework</string> <key>SupportedArchitectures</key> <array> <string>x86_64</string> </array> <key>SupportedPlatform</key> <string>tvos</string> <key>SupportedPlatformVariant</key> <string>simulator</string> </dict> <dict> <key>LibraryIdentifier</key> <string>tvos-arm64</string> <key>LibraryPath</key> <string>Himotoki.framework</string> <key>SupportedArchitectures</key> <array> <string>arm64</string> </array> <key>SupportedPlatform</key> <string>tvos</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> <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> </array> <key>CFBundlePackageType</key> <string>XFWK</string> <key>XCFrameworkFormatVersion</key> <string>1.0</string> </dict> </plist> -
<dict> <key>AvailableLibraries</key> <array> ... <dict> <key>LibraryIdentifier</key> <string>ios-x86_64-maccatalyst</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>maccatalyst</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> -
<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> -
xcodebuild -create- xcframework $ 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. -allow-internal-distribution Specifies that the created xcframework contains information not suitable for public distribution. -help Show this help content.