Skip to content

Commit b4602b9

Browse files
committed
fix(xcode): 移除 xcframework 的 framework 引用
xcframework 不适合添加到 Link Binary With Libraries, 现改为仅添加文件引用和 build phase,不再调用 AddFrameworkToProject。
1 parent de0784d commit b4602b9

1 file changed

Lines changed: 28 additions & 6 deletions

File tree

Editor/PostProcessBuildHelper.Folder.cs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ private static void AddFolderBuild(PBXProject proj, string targetGuid, string ma
4444
{
4545
//获得源文件下所有目录文件
4646
string currDir = Path.Combine(xcodePath, root);
47-
if (root.EndsWith(".framework") || root.EndsWith(".bundle") || root.EndsWith(".xcframework"))
47+
if (root.EndsWith(".framework") || root.EndsWith(".bundle"))
4848
{
49-
Debug.LogFormat("add framework/bundle/xcframework to build:{0}->{1}", currDir, root);
49+
Debug.LogFormat("add framework/bundle to build:{0}->{1}", currDir, root);
5050
string fileGuid = proj.AddFile(currDir, root, PBXSourceTree.Source);
5151
proj.AddFileToBuild(targetGuid, fileGuid);
5252
if (root.EndsWith(".bundle"))
@@ -58,6 +58,14 @@ private static void AddFolderBuild(PBXProject proj, string targetGuid, string ma
5858
return;
5959
}
6060

61+
if (root.EndsWith(".xcframework"))
62+
{
63+
Debug.LogFormat("add xcframework to build:{0}->{1}", currDir, root);
64+
string fileGuid = proj.AddFile(currDir, root, PBXSourceTree.Source);
65+
proj.AddFileToBuild(targetGuid, fileGuid);
66+
return;
67+
}
68+
6169
if (root.EndsWith(".a"))
6270
{
6371
Debug.LogFormat("add static library to build:{0}->{1}", currDir, root);
@@ -73,9 +81,9 @@ private static void AddFolderBuild(PBXProject proj, string targetGuid, string ma
7381
string name = Path.GetFileName(folder);
7482
string filePath = Path.Combine(currDir, name);
7583
string projectPath = Path.Combine(root, name);
76-
if (folder.EndsWith(".framework") || folder.EndsWith(".bundle") || folder.EndsWith(".xcframework"))
84+
if (folder.EndsWith(".framework") || folder.EndsWith(".bundle"))
7785
{
78-
Debug.LogFormat("add framework/bundle/xcframework to build:{0}->{1}", filePath, projectPath);
86+
Debug.LogFormat("add framework/bundle to build:{0}->{1}", filePath, projectPath);
7987
string fileGuid = proj.AddFile(filePath, projectPath, PBXSourceTree.Source);
8088
proj.AddFileToBuild(targetGuid, fileGuid);
8189
if (folder.EndsWith(".bundle"))
@@ -88,6 +96,13 @@ private static void AddFolderBuild(PBXProject proj, string targetGuid, string ma
8896
}
8997
AutoAddSearchPath(proj, xcodePath, targetGuid, filePath);
9098
}
99+
else if (folder.EndsWith(".xcframework"))
100+
{
101+
Debug.LogFormat("add xcframework to build:{0}->{1}", filePath, projectPath);
102+
string fileGuid = proj.AddFile(filePath, projectPath, PBXSourceTree.Source);
103+
proj.AddFileToBuild(targetGuid, fileGuid);
104+
AutoAddSearchPath(proj, xcodePath, targetGuid, filePath);
105+
}
91106
else if (folder.EndsWith(".a"))
92107
{
93108
Debug.LogFormat("add static library to build:{0}->{1}", filePath, projectPath);
@@ -110,9 +125,9 @@ private static void AddFolderBuild(PBXProject proj, string targetGuid, string ma
110125
string filePath = Path.Combine(currDir, name);
111126
string projectPath = Path.Combine(root, name);
112127

113-
if (file.EndsWith(".framework") || file.EndsWith(".bundle") || file.EndsWith(".xcframework"))
128+
if (file.EndsWith(".framework") || file.EndsWith(".bundle"))
114129
{
115-
Debug.LogFormat("add framework/bundle/xcframework to build:{0}->{1}", filePath, projectPath);
130+
Debug.LogFormat("add framework/bundle to build:{0}->{1}", filePath, projectPath);
116131
string fileGuid = proj.AddFile(filePath, projectPath, PBXSourceTree.Source);
117132
proj.AddFileToBuild(targetGuid, fileGuid);
118133
if (file.EndsWith(".bundle"))
@@ -125,6 +140,13 @@ private static void AddFolderBuild(PBXProject proj, string targetGuid, string ma
125140
}
126141
AutoAddSearchPath(proj, xcodePath, targetGuid, filePath);
127142
}
143+
else if (file.EndsWith(".xcframework"))
144+
{
145+
Debug.LogFormat("add xcframework to build:{0}->{1}", filePath, projectPath);
146+
string fileGuid = proj.AddFile(filePath, projectPath, PBXSourceTree.Source);
147+
proj.AddFileToBuild(targetGuid, fileGuid);
148+
AutoAddSearchPath(proj, xcodePath, targetGuid, filePath);
149+
}
128150
else if (file.EndsWith(".a"))
129151
{
130152
Debug.LogFormat("add static library to build:{0}->{1}", filePath, projectPath);

0 commit comments

Comments
 (0)