ãã®è¨äºã§ã¯XCFrameworkãä½æããç½²å(ã³ã¼ãç½²å)ãè¡ãæé ã解説ãã¾ãã 解説åã«ã¾ããè¨äºå ã«åºã¦ããç¨èªã®è§£èª¬ãæ¸ãã¦ããã¾ããç¥ããªãç¨èªãåºã¦ãããããã«æ»ã£ã¦ãã¦ç¢ºèªãã¦ä¸ããã
ç¨èªè§£èª¬
Archive
é å¸ãã¹ãã¢ã«å ¬éæã«å¿ è¦ãªå®è¡å¯è½ãã¡ã¤ã«ãã¢ã»ãããã¡ã¿ãã¼ã¿ãªã©ã®ãªã½ã¼ã¹ãBundleåãããã®ã
Bundle(ãã³ãã«)
æ¨æºåãããé層æ§é ãæã¤ãã£ã¬ã¯ããªã«ãªã½ã¼ã¹ãã¾ã¨ãããã®ãé常ã¯1ã¤ã®ãã¡ã¤ã«ã®æ§ã«æ±ããããå³ã¯ãªãã¯ã¡ãã¥ã¼ãããããã±ã¼ã¸ã®å 容ã表示ããé¸æããã¨ãã£ã¬ã¯ããªã«å«ã¾ããå 容ã確èªã§ããã
åèæ å ±ï¼Placing Content in a Bundle | Apple Developer Documentation
Framework
Dynamic shared library(åçå ±æã©ã¤ãã©ãª)ãStatic Library(éçã©ã¤ãã©ãª)ãã¢ã»ãããã¡ã¿ãã¼ã¿ãªã©ãBundleåãããã®ã
Dynamic shared library(åçå ±æã©ã¤ãã©ãª)
å®è¡æã«ã¢ããªããå©ç¨ããå½¢å¼ã®ã©ã¤ãã©ãªãè¤æ°ã®ã¢ããªããåæã«å©ç¨ããäºãå¯è½ã§ããçºãã¡ã¢ãªãç¯ç´ã§ããã¨ããå©ç¹ãæããã¾ããå¿ è¦ã«ãªã£ãæç¹ã§ãã¼ããããçºã«èµ·åæã«å¿ è¦ã«ã¡ã¢ãªéãæãããããªã©ã®å©ç¹ãæãã¾ãã
Static Library(éçã©ã¤ãã©ãª)
ã¢ããªã®ãã«ãæã«ã¢ããªå ã«åãè¾¼ã¾ããå½¢å¼ã®ã©ã¤ãã©ãªã
ç½²å
ãã®ãã¡ã¤ã«ãXCFrameworkã«å¯¾ãã¦ã以ä¸ã®äºãä¿è¨¼ããä»çµã¿ã
- ç½²åãããæç¹ããå¤æ´ãè¡ããã¦ããªã
- å¶ä½è ã¯ç½²åãã人ã§ãã
å¶ä½è ãç½²åå¦çãè¡ãäºã§ç½²åæ¸ã¿ã®ãã¡ã¤ã«ãXCFrameworkãä½æããäºãã§ãã¾ãã
XCFrameworkãä½æ
ã¾ãã¯Xcodeã§æ®éã«iOSã®Frameworkãä½æãã¾ãã
â»Frameworkã®ä½ææ¹æ³ã«ã¤ãã¦ã¯å¥éæ¤ç´¢ãã¦ä¸ããã
Frameworkãä½æããæã«ã¯Xcodeããã¸ã§ã¯ãã®Build Settingsã¿ãã§ä»¥ä¸ãã®ãæ¤ç´¢ãã¦è¨å®ãå¤æ´ãã¦ä¸ããã
- Build Libraries for DistributionãYes
- Skip InstallãNo
Frameworkã®Xcodeããã¸ã§ã¯ãã®æºåã§ãããã¿ã¼ããã«ãéãã.xcodeprojãã¡ã¤ã«ããããã£ã¬ã¯ããªã¸ç§»åãã¾ãã
ãã£ã¬ã¯ããªã§ä»¥ä¸ã®ã³ãã³ããå®è¡ããã¨iOSç°å¢åãã®archiveãä½æããã¾ãã
ä¾) TestFrameworkã¨ããããã¸ã§ã¯ãã®å ´å
xcodebuild archive \ -project TestFramework.xcodeproj \ -scheme TestFramework \ -destination "generic/platform=iOS" \ -archivePath "archives/TestFramework-iOS"
-projectã§Xcodeã®ããã¸ã§ã¯ãã®ãã¹ãæå®ã-archivePathã§archiveã®çæå ã®ãã¹ãæå®ãã¾ãã
ç¶ãã¦iOSã·ãã¥ã¬ã¼ã¿ç°å¢åãã«ä½æãã¾ããã³ãã³ãã¯ãã¡ãã
xcodebuild archive \ -project TestFramework.xcodeproj \ -scheme TestFramework \ -destination "generic/platform=iOS Simulator" \ -archivePath "archives/TestFramework-iOS_Simulator"
ããã§iOSåãã¨iOSã·ãã¥ã¬ã¼ã¿åãã®archiveãä½æã§ãã¾ããã
次ã«ä»¥ä¸ã®ã³ãã³ãã§2ã¤ã®archiveããXCFrameworkãä½æãã¾ãã
xcodebuild -create-xcframework \ -archive archives/TestFramework-iOS.xcarchive -framework TestFramework.framework \ -archive archives/TestFramework-iOS_Simulator.xcarchive -framework TestFramework.framework \ -output xcframeworks/TestFramework.xcframework
-archiveã§æå®ããarchiveã®ä¸ã®å«ã¾ãã¦ããã©ã®Frameworkã使ç¨ãããã-frameworkã§æå®ãã¾ãã-outputã§æå®ãããã¹ã«XCFrameworkãçæããã¾ãã
ããã§No 'swiftinterface' files found within '(ããã«TestFramework.swiftmoduleã®ãã¹)'
ã¨ããã¨ã©ã¼ã表示ãããæã«ã¯Frameworkä½ææã®è¨å®ã¨ãã¦è¨è¿°ããBuild Libraries for DistributionãYes
ãè¡ããã¦ããã確èªãã¦ä¸ããã
error: the path does not point to a valid framework: (ããã«TestFramework.frameworkã®ãã¹)
ã¨ããã¨ã©ã¼ã表示ãããæã«ã¯Skip InstallãNo
ãè¡ããã¦ããã確èªãã¦ä¸ããã
ãããFrameworkã§ã¯ãªãã.aãã¡ã¤ã«(Static Libraryãã¡ã¤ã«)ããXCFrameworkãä½æãããå ´åã«ã¯-frameworkã®ä»£ããã«-libraryã§.aãã¡ã¤ã«ã®ãã¹ã-headersã§ããããã¡ã¤ã«ã®ãã£ã¬ã¯ããªãæå®ãã¾ãã
(ã³ãã³ãä¾)
xcodebuild -create-xcframework -library products/iOS/usr/local/lib/libMyLibrary.a -headers products/iOS/usr/local/include -library products/iOS_Simulator/usr/local/lib/libMyLibrary.a -headers products/iOS/usr/local/include -output xcframeworks/MyLibrary.xcframework
ç½²å
ç½²åã¯Apple Developer Programã®IDããããã¯èªå·±ç½²å証ææ¸ã§è¡ãã¾ãã
ããã§ã¯Apple Developer Programã®IDã§ç½²åããæ¹æ³ã解説ãã¾ãã
Apple Distributionãã¾ã ä½æãã¦ããªãå ´åã«ã¯ä½æãå¿ è¦ã§ãã
â»Apple Distributionã®ä½ææ¹æ³ã«ã¤ãã¦ã¯å¥éæ¤ç´¢ãã¦ä¸ããã
Apple Distributionãä½æããKeychain(ããã¼ãã§ã¼ã³ã¢ã¯ã»ã¹ãã¢ããª)ã«è¿½å æ¸ã¿ã§æãã°ä»¥ä¸ã®æ§ãªè¨¼ææ¸ãè¦ã¤ããã¯ãã§ãã
ãã®ãApple Distribution: ãã§å§ã¾ãè¡ã®æååã¯ç½²åãè¡ãæã«å¿ è¦ãªã®ã§ã¡ã¢ãã¦ããã¦ä¸ããã
ç½²åãè¡ã
ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ããã¨XCFrameworkã«ç½²åãè¡ããã¾ãã
codesign \ --timestamp \ -s "Apple Distribution: XXXXX (YYYYYYYYYY)" xcframeworks/TestFramework.xcframework
--timestampã§ç½²åæå»ã®èªè¨¼ãè¦æ±ãã¾ãã-sã§Appple Distributionã®æ å ±ãè¨è¼ãã¾ããå ã»ã©ã¡ã¢ãã¦ããApple Distribution:ããå§ã¾ãæååãè¨è¼ãã¦ä¸ãããæå¾ã«ç½²åãè¡ãXCFrameworkã®ãã¹ãæå®ãã¾ãã
ããã§XCFrameworkã®ä½æã¨ç½²åã®ä½æ¥ãçµããã¾ããã
ç½²åç¶æ³ã®ç¢ºèª
ã¾ãç°¡åãªç¢ºèªæ¹æ³ã¨ãã¦ã¯XCFrameworkã®ä¸ã«_CodeSignatureã¨ãããã£ã¬ã¯ããªãåå¨ãããã§ç¢ºèªã§ãã¾ãããã®ãã£ã¬ã¯ããªãåå¨ããå ´åã«ã¯ç½²åæ¸ã¿ã§ãã
Xcodeããã¸ã§ã¯ãã«XCFrameworkã追å æ¸ã¿ã®å ´åã«ã¯XCFrameworkãé¸æããç¶æ ã§å³å´ã«æãã¤ã³ã¹ãã¯ã¿ã¼ã§ãã¡ã¤ã«ã¿ããè¦ãã¨ç¢ºèªã§ãã¾ããããã«æãSignatureã¨ãããããã¯ã«Status Verification succeededã¨ããè¨è¼ãæãã¨ç½²åã«æåãã¦ãã¾ãã