èæ¯
ã¾ããSwift PackageãXcode Projectãããã³Xcode Projectã«Swift Packageã追å ããæ¹æ³ã«ã¤ãã¦èª¬æãã¾ãããªãã説æã¯å ¨ã¦Xcode 15.4ã®æåã«åºã¥ãã¦ãã¾ãã
Swift Packageã¯Swiftã®ã½ã¼ã¹ã³ã¼ããé¢é£ãããªã½ã¼ã¹ãã¡ã¤ã«ã1ã¤ã«ã¾ã¨ããä»çµã¿ã§ããåããSwiftã使ãiOSã¢ããªéçºã¨è¦ªåæ§ãé«ããiOSã¢ããªéçºã«ç¨ããããXcodeã¨ããçµ±åéçºç°å¢ããããåç §ããã¾ããXcodeã§ã¯ã½ããã¦ã§ã¢ãProjectã¨ããåä½ã«åãã¦ç®¡çãããã¨ãå¯è½ãªã®ã§ããããã®Xcode Projectã«ãã¼ã«ã«ã«åå¨ããSwift Packageãèªèº«ã®ä¾åã¨ãã¦è¿½å ããæ¹æ³ã«ã¯2ã¤ããã¾ãã
1ã¤ç®ã®æ¹æ³ï¼Add Package Dependencies...
ããæ¹æ³
1ã¤ç®ã¯ãAdd Package Dependencies...
ããæ¹æ³ã§ãããã®æ¹æ³ã®å°ç·ã¯èªåã調ã¹ãéã以ä¸ã®ï¼ã¤ãããã¾ããè¨ãæããã¨ããã®æ¹æ³ã¯ãã®ï¼ã¤ã®å°ç·ããSwift Packageã追å ããæ¹æ³ã§ãããªãããããã®å°ç·ã使ã£ã¦ããã®å¾ã«è¡¨ç¤ºãããç»é¢ã¯åä¸ã§ãã
- Xcodeã®ã¡ãã¥ã¼ãã
Add Package Dependencies...
ãé¸æ
- Xcodeã®Navigator/Projectããå³ã¯ãªãã¯ã§
Add Package Dependencies...
ãé¸æ
- Xcodeã®Navigator/ProjectããProjectã®è¨å®ãéããPackage Dependenciesã¿ãã«è¡¨ç¤ºããã¦ããï¼ãã¿ã³ãã¯ãªãã¯ãã
+ãã¿ã³ã¯ããã¼ããã¨Add Package Dependencies
ã¨ã¢ããã¼ã·ã§ã³ããã¾ãã
2ã¤ç®ã®æ¹æ³ï¼ãFileã¨ãã¦è¿½å ããæ¹æ³
2ã¤ç®ã¯ãFileã¨ãã¦è¿½å ããæ¹æ³ã§ãããã®æ¹æ³ã¯ä»¥ä¸ã®æé ãè¸ãå¿ è¦ãããã¾ãã
- Xcodeã®Navigator/Projectããå³ã¯ãªãã¯ã§
Add Files to "MyProject"
ãé¸æãã
追å ãããSwift Packageãé¸æ
Navigator/ProjectããGeneralã¿ããéãã
Frameworks,Libraries, and Embedded Content
ã«å ã»ã©è¿½å ããSwift Packageã追å ãã
èªåãæºãã£ã¦ããProjectã§ã¯2ã¤ã®æ¹æ³ã使ããã¦ãããéããæ°ã«ãªãã¾ããã
ç®ç
ãããã®æ¹æ³ãSwift Packageãã¤ã³ãã¼ããã¦å©ç¨ããã¨ããç¹ã§ã¯åãçµæãå¾ããã¾ããã追å ããæ¹æ³ãç°ãªãããã©ã¡ãã使ããè¿·ã£ã¦ãã¾ãã¾ããããããã®éããç¥ã£ã¦è¿·ããªãããã«ããäºããã®çµæãå ±æããäºããã®è¨äºã®ç®çã§ããèæ¯ã¾ã§ã§å¯ããã¤ãæ¹ãå¤ãã¨æãã®ã§ãåå¿è åãã®è¨äºã«ãªãããããã¾ããã
å®é¨
ããããã®æ¹æ³ã使ã£ã¦Swift PackageãXcode Projectã«è¿½å ãã¦ã¿ã¾ããããã¦ãããããã®æ¹æ³ã«ãããXcodeã®è¡¨ç¤ºã¨Xcode Projectã«å«ã¾ããproject.pbxprojã®å·®åãã¾ã¨ãã¾ãããªããproject.pbxprojã¯XMLã§Xcode Projectã®è¨å®ãè¨è¿°ãããã¡ã¤ã«ã§ãã
1ã¤ç®ã®æ¹æ³
ã¾ããXcodeã®è¡¨ç¤ºã¯ä»¥ä¸ã®ã¨ããã§ããNavigator/Projectã«Package Dependenciesã¨ããæ¬ãç¾ãã¦ãããã«è¿½å ããSwift Packageã表示ããã¦ãã¾ãã
次ã«ãproject.pbxprojã®å·®åã¯ä»¥ä¸ã®ã¨ããã§ããFrameworksBuildPhaseã«Swift Packageã追å ããã¦ãã¦ããã«ã対象ã«å«ã¾ãã¦ããäºããããã¾ããã¾ããXCLocalSwiftPackageReference section ãXCSwiftPackageProductDependency section ã追å ããã¦ãã¾ãã
diff --git a/MyProject.xcodeproj/project.pbxproj b/MyProject.xcodeproj/project.pbxproj index 7c40cac..6586b55 100644 --- a/MyProject.xcodeproj/project.pbxproj +++ b/MyProject.xcodeproj/project.pbxproj @@ -14,6 +14,7 @@ F694CF102D083C9200C2DA8F /* MyProjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F694CF0F2D083C9200C2DA8F /* MyProjectTests.swift */; }; F694CF1A2D083C9200C2DA8F /* MyProjectUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F694CF192D083C9200C2DA8F /* MyProjectUITests.swift */; }; F694CF1C2D083C9200C2DA8F /* MyProjectUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F694CF1B2D083C9200C2DA8F /* MyProjectUITestsLaunchTests.swift */; }; + F694CF312D0850C400C2DA8F /* MyPackage in Frameworks */ = {isa = PBXBuildFile; productRef = F694CF302D0850C400C2DA8F /* MyPackage */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -51,6 +52,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F694CF312D0850C400C2DA8F /* MyPackage in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -143,6 +145,9 @@ dependencies = ( ); name = MyProject; + packageProductDependencies = ( + F694CF302D0850C400C2DA8F /* MyPackage */, + ); productName = MyProject; productReference = F694CEFB2D083C9000C2DA8F /* MyProject.app */; productType = "com.apple.product-type.application"; @@ -215,6 +220,9 @@ Base, ); mainGroup = F694CEF22D083C9000C2DA8F; + packageReferences = ( + F694CF2F2D0850C400C2DA8F /* XCLocalSwiftPackageReference "MyPackage" */, + ); productRefGroup = F694CEFC2D083C9000C2DA8F /* Products */; projectDirPath = ""; projectRoot = ""; @@ -582,6 +590,20 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCLocalSwiftPackageReference section */ + F694CF2F2D0850C400C2DA8F /* XCLocalSwiftPackageReference "MyPackage" */ = { + isa = XCLocalSwiftPackageReference; + relativePath = MyPackage; + }; +/* End XCLocalSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + F694CF302D0850C400C2DA8F /* MyPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = MyPackage; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = F694CEF32D083C9000C2DA8F /* Project object */; }
2ã¤ç®ã®æ¹æ³
ã¾ããXcodeã®è¡¨ç¤ºã¯ä»¥ä¸ã®ã¨ããã§ããNavigator/Projectã«ä»ã®ãã¡ã¤ã«ã¨åæ§ã«Swift Packageã表示ããã¦ãã¾ããSwift Packageã®ã¢ã¤ã³ã³ãSwift Packageã表ãð¦ã®ãããªã¢ã¤ã³ã³ã«ãªã£ã¦ãããã¨ãããXcodeã«ããåãSwift Packageãªãããªããã¨Swift Packageèªå®ããã¦ããäºããããã¾ããä¸ä»ã®ãã£ã¬ã¯ããªã¨ã¯ä¸ç·ãç»ãã¦ããããã§ãã
次ã«ãproject.pbxprojã®å·®åã¯ä»¥ä¸ã®ã¨ããã§ããPBXGroupã«å¯¾ããå¤æ´ãå ¥ã£ã¦ããäºãããXcode Projectã管çãã¦ãããã£ã¬ã¯ããªæ§é ã§ããã°ã«ã¼ãã«å¤æ´ãå ¥ã£ã¦ããäºããããã¾ããPBXResourcesBuildPhaseã«ãå«ã¾ãã¦ããããªã½ã¼ã¹ã¨ãã¦ã³ãã¼ãããã¾ããã¾ããXCLocalSwiftPackageReference sectionããªãXCSwiftPackageProductDependency section ã®ã¿ã追å ããã¦ããäºããããã¾ãã
diff --git a/MyProject.xcodeproj/project.pbxproj b/MyProject.xcodeproj/project.pbxproj index 7c40cac..76abb9d 100644 --- a/MyProject.xcodeproj/project.pbxproj +++ b/MyProject.xcodeproj/project.pbxproj @@ -14,6 +14,8 @@ F694CF102D083C9200C2DA8F /* MyProjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F694CF0F2D083C9200C2DA8F /* MyProjectTests.swift */; }; F694CF1A2D083C9200C2DA8F /* MyProjectUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F694CF192D083C9200C2DA8F /* MyProjectUITests.swift */; }; F694CF1C2D083C9200C2DA8F /* MyProjectUITestsLaunchTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F694CF1B2D083C9200C2DA8F /* MyProjectUITestsLaunchTests.swift */; }; + F694CF332D08523A00C2DA8F /* MyPackage in Resources */ = {isa = PBXBuildFile; fileRef = F694CF322D08523A00C2DA8F /* MyPackage */; }; + F694CF362D08524400C2DA8F /* MyPackage in Frameworks */ = {isa = PBXBuildFile; productRef = F694CF352D08524400C2DA8F /* MyPackage */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -44,6 +46,7 @@ F694CF152D083C9200C2DA8F /* MyProjectUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MyProjectUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; F694CF192D083C9200C2DA8F /* MyProjectUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyProjectUITests.swift; sourceTree = "<group>"; }; F694CF1B2D083C9200C2DA8F /* MyProjectUITestsLaunchTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MyProjectUITestsLaunchTests.swift; sourceTree = "<group>"; }; + F694CF322D08523A00C2DA8F /* MyPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = MyPackage; sourceTree = "<group>"; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -51,6 +54,7 @@ isa = PBXFrameworksBuildPhase; buildActionMask = 2147483647; files = ( + F694CF362D08524400C2DA8F /* MyPackage in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -74,10 +78,12 @@ F694CEF22D083C9000C2DA8F = { isa = PBXGroup; children = ( + F694CF322D08523A00C2DA8F /* MyPackage */, F694CEFD2D083C9000C2DA8F /* MyProject */, F694CF0E2D083C9200C2DA8F /* MyProjectTests */, F694CF182D083C9200C2DA8F /* MyProjectUITests */, F694CEFC2D083C9000C2DA8F /* Products */, + F694CF342D08524400C2DA8F /* Frameworks */, ); sourceTree = "<group>"; }; @@ -127,6 +133,13 @@ path = MyProjectUITests; sourceTree = "<group>"; }; + F694CF342D08524400C2DA8F /* Frameworks */ = { + isa = PBXGroup; + children = ( + ); + name = Frameworks; + sourceTree = "<group>"; + }; /* End PBXGroup section */ /* Begin PBXNativeTarget section */ @@ -143,6 +156,9 @@ dependencies = ( ); name = MyProject; + packageProductDependencies = ( + F694CF352D08524400C2DA8F /* MyPackage */, + ); productName = MyProject; productReference = F694CEFB2D083C9000C2DA8F /* MyProject.app */; productType = "com.apple.product-type.application"; @@ -231,6 +247,7 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + F694CF332D08523A00C2DA8F /* MyPackage in Resources */, F694CF062D083C9200C2DA8F /* Preview Assets.xcassets in Resources */, F694CF032D083C9200C2DA8F /* Assets.xcassets in Resources */, ); @@ -582,6 +599,13 @@ defaultConfigurationName = Release; }; /* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + F694CF352D08524400C2DA8F /* MyPackage */ = { + isa = XCSwiftPackageProductDependency; + productName = MyPackage; + }; +/* End XCSwiftPackageProductDependency section */ }; rootObject = F694CEF32D083C9000C2DA8F /* Project object */; }
ããã£ãäº
ã¾ãã2ã¤ãã®æ¹æ³ã§ã¯Swift Packageã®ãã£ã¬ã¯ããªãã°ã«ã¼ãã«å«ã¾ãã¾ãããã®ããSwift Packageã追å ããéã«ããã©ã«ãã§ãCopy Bundle Resourcesã«Swift Packageãå«ã¾ãã¾ãããã®ãããä½ã対å¿ãè¡ããªãã¨Swift Packageãã¢ããªã«å«ã¾ãã¾ãã以ä¸ããã«ãããã¢ããªã®ä¸èº«ã§ããSwift Packageã®ãã£ã¬ã¯ããªãã¢ããªå ã«ã³ãã¼ããã¦ããäºããããã¾ããåé¿ããã«ã¯Copy Bundle Resourcesããåãé¤ãã ãã§è¯ãã§ãã
ã¾ãã2ã¤ç®ã®æ¹æ³ã§ã¯XCLocalSwiftPackageReference sectionãããã¾ãããã¾ãã1ã¤ç®ã®æ¹æ³ã¯Navigatorã«localã¨ãã表è¨ãåºã¦ããã®ã«å¯¾ãã¦2ã¤ç®ã§ã¯è¡¨è¨ããã¾ãããXCLocalSwiftPackageReference sectionã¯ãããã£ã表è¨ã®åå²å¦çã«ç¨ãããã¦ããã®ããããã¾ããã
æå¾ã«2ã¤ç®ã®æ¹æ³ã§ã®ã¿Xcode Projectã®ãã¹ããã©ã³ã«Swift Packageã®Targetã追å ã§ãã¾ãããä¸ã«ããããã®æ¹æ³ã«ããã¦ããã¹ããã©ã³ã«ãã¹ãã¿ã¼ã²ããã追å ããç»é¢ãç»åã§è¨è¼ãã¾ãããã®å·®åã¯Swift Packageãã°ã«ã¼ãã«å«ã¾ãã¦ããå½±é¿ããããã¾ããã1ã¤ç®ã®æ¹æ³ã§ã¯ãã¹ããã©ã³ã«ç»é²ã§ããªãäºãSwift Forumã«ã¦è¨åããã¦ãã¾ãã*1ãã2ã¤ç®ã®æ¹æ³ã§ãªããã¾ãåä½ãããã®æ å ±ã¯è¦ã¤ãããã¾ããã§ãã...ãããããPBXFileReference sectionã¨PBXGroup sectionã®å·®åãåãæ¶ãã¨1ã¤ç®ã®æ¹æ³ã¨åæ§ã«ãã¹ãã¿ã¼ã²ããã«è¿½å ã§ããªããªã£ãã®ã§ãã°ã«ã¼ãã¨ãã¦ãªãã¡ã¬ã³ã¹ãã¦ããããé¢ä¿ããããã«æãã¾ããã
çµè«
- åºæ¬1ã¤ç®ã®æ¹æ³ã§OK
- 1ã¤ç®ã®æ¹æ³ã§ã·ã¥ãã¨ã§ããªããããªäºãããã°(e.g. ãã¹ããã©ã³ã«è¿½å )ã2ã¤ç®ãæ¤è¨ãã
- ãã ãã2ã¤ç®ã®æ¹æ³ã使ãå ´åã¯Copy Bundle ResourcesããSwift Packageãåãé¤ã