Skip to content

Commit 7912d8a

Browse files
committed
Workaround build phase for lack of Metal support on the simulator.
1 parent cb59252 commit 7912d8a

File tree

3 files changed

+33
-101
lines changed

3 files changed

+33
-101
lines changed

cocos2d-tests.xcodeproj/project.pbxproj

Lines changed: 25 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
75556A181856370A00ED1B0F /* CCPhysicsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 755569E51856361100ED1B0F /* CCPhysicsTests.m */; };
1717
75556A191856370A00ED1B0F /* CCSchedulerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 755569E61856361100ED1B0F /* CCSchedulerTests.m */; };
1818
75556A1B1856374700ED1B0F /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 755569EA1856361100ED1B0F /* InfoPlist.strings */; };
19-
7575B5FC1856535200CA09C8 /* libcocos2d.a in Frameworks */ = {isa = PBXBuildFile; fileRef = B7E2622D17E7D3D8007067F0 /* libcocos2d.a */; };
2019
7587BDB3185A0A6900EEEFDE /* TextureTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7587BDB2185A0A6900EEEFDE /* TextureTest.m */; };
2120
7587BDB7185A64AD00EEEFDE /* ColorTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 7587BDB6185A64AD00EEEFDE /* ColorTest.m */; };
2221
758A690F1843E18700D1A8D2 /* ParallaxTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 758A690E1843E18700D1A8D2 /* ParallaxTest.m */; };
@@ -67,13 +66,11 @@
6766
B7EE69811818760700B983FE /* CCSprite9SliceTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B7EE69801818760700B983FE /* CCSprite9SliceTest.m */; };
6867
B7EE69CF1819D82300B983FE /* CCLayoutTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B7EE69CE1819D82300B983FE /* CCLayoutTest.m */; };
6968
B7EE6A28181B075E00B983FE /* CCSliderTest.m in Sources */ = {isa = PBXBuildFile; fileRef = B7EE6A27181B075E00B983FE /* CCSliderTest.m */; };
70-
D23CD73119CB881200C7EB14 /* CCShaders.metal in Resources */ = {isa = PBXBuildFile; fileRef = D3C1281C199D43E0005D2119 /* CCShaders.metal */; };
7169
D24FAEED198014C80043E27D /* GLKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D34CD3C118ABEE9C00D8E537 /* GLKit.framework */; };
7270
D28A2E181954F68200ADC03D /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E171954F68200ADC03D /* UIKit.framework */; };
7371
D28A2E1F1954F7E900ADC03D /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D28A2E1E1954F7E900ADC03D /* OpenGLES.framework */; };
7472
D2B4894C1917EE6700C3443A /* CCEffectsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = D2B4894B1917EE6700C3443A /* CCEffectsTest.m */; };
7573
D2D59897198747DE00BDAF25 /* Music in Resources */ = {isa = PBXBuildFile; fileRef = D2D59896198747DE00BDAF25 /* Music */; };
76-
D3269DE819CC985900406282 /* TestShaders.metal in Sources */ = {isa = PBXBuildFile; fileRef = D3269DE719CC985900406282 /* TestShaders.metal */; };
7774
D3269DEA19CCC11800406282 /* CCRendererSharedTypes.h in Resources */ = {isa = PBXBuildFile; fileRef = D3269DE919CCC11800406282 /* CCRendererSharedTypes.h */; };
7875
D32FDE8619B645CA0078CC16 /* CCTextureTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D32FDE8519B645CA0078CC16 /* CCTextureTests.m */; };
7976
D3395F1A187F83E600F22C74 /* CCMemoryTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D3395F19187F83E600F22C74 /* CCMemoryTests.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; };
@@ -194,6 +191,7 @@
194191
D3DACC7C19E74BD100629E97 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = D3763D9519E7356C006C050D /* InfoPlist.strings */; };
195192
D3DACC7D19E74BD500629E97 /* icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = D3763D9819E7356C006C050D /* icon.icns */; };
196193
D3DACC7E19E74BD800629E97 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = D3763D9919E7356C006C050D /* Info.plist */; };
194+
D3E1842B19E861FC00A08B01 /* MetalShaders in Resources */ = {isa = PBXBuildFile; fileRef = D3E1842A19E861FC00A08B01 /* MetalShaders */; };
197195
D4AFE9131977100000261299 /* A Damn Mess.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D4AFE8D81977100000261299 /* A Damn Mess.ttf */; };
198196
D4AFE9141977100000261299 /* Abberancy.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D4AFE8D91977100000261299 /* Abberancy.ttf */; };
199197
D4AFE9151977100000261299 /* ThisFontIsAbdFont.ttf in Resources */ = {isa = PBXBuildFile; fileRef = D4AFE8DA1977100000261299 /* ThisFontIsAbdFont.ttf */; };
@@ -265,41 +263,13 @@
265263
/* End PBXBuildFile section */
266264

267265
/* Begin PBXContainerItemProxy section */
268-
57E144B51974C1E90065F142 /* PBXContainerItemProxy */ = {
269-
isa = PBXContainerItemProxy;
270-
containerPortal = B7E2622317E7D3D8007067F0 /* cocos2d-ios.xcodeproj */;
271-
proxyType = 2;
272-
remoteGlobalIDString = 5BF3267A195F8D8800D9A51A;
273-
remoteInfo = cocos2dJava;
274-
};
275266
75556A10185636F100ED1B0F /* PBXContainerItemProxy */ = {
276267
isa = PBXContainerItemProxy;
277268
containerPortal = B7E2604017E7D278007067F0 /* Project object */;
278269
proxyType = 1;
279270
remoteGlobalIDString = B7E2604717E7D278007067F0;
280271
remoteInfo = "cocos2d-ui-tests-ios";
281272
};
282-
B7E2622C17E7D3D8007067F0 /* PBXContainerItemProxy */ = {
283-
isa = PBXContainerItemProxy;
284-
containerPortal = B7E2622317E7D3D8007067F0 /* cocos2d-ios.xcodeproj */;
285-
proxyType = 2;
286-
remoteGlobalIDString = 5018F24D0DFDEAC400C013A5;
287-
remoteInfo = cocos2d;
288-
};
289-
B7E2623217E7D578007067F0 /* PBXContainerItemProxy */ = {
290-
isa = PBXContainerItemProxy;
291-
containerPortal = B7E2622317E7D3D8007067F0 /* cocos2d-ios.xcodeproj */;
292-
proxyType = 1;
293-
remoteGlobalIDString = 5018F24C0DFDEAC400C013A5;
294-
remoteInfo = cocos2d;
295-
};
296-
D2FEB797194F6CC800FC0574 /* PBXContainerItemProxy */ = {
297-
isa = PBXContainerItemProxy;
298-
containerPortal = B7E2622317E7D3D8007067F0 /* cocos2d-ios.xcodeproj */;
299-
proxyType = 2;
300-
remoteGlobalIDString = D2FEB74F194F6C9E00FC0574;
301-
remoteInfo = cocos2dAndroid;
302-
};
303273
D3763BB819E72F85006C050D /* PBXContainerItemProxy */ = {
304274
isa = PBXContainerItemProxy;
305275
containerPortal = D3763BB019E72F85006C050D /* cocos2d.xcodeproj */;
@@ -335,13 +305,6 @@
335305
remoteGlobalIDString = 5018F24C0DFDEAC400C013A5;
336306
remoteInfo = "cocos2d-ios";
337307
};
338-
D3763BDA19E73188006C050D /* PBXContainerItemProxy */ = {
339-
isa = PBXContainerItemProxy;
340-
containerPortal = B7E2622317E7D3D8007067F0 /* cocos2d-ios.xcodeproj */;
341-
proxyType = 1;
342-
remoteGlobalIDString = 5018F24C0DFDEAC400C013A5;
343-
remoteInfo = cocos2d;
344-
};
345308
D3763C5C19E731BA006C050D /* PBXContainerItemProxy */ = {
346309
isa = PBXContainerItemProxy;
347310
containerPortal = D3763BB019E72F85006C050D /* cocos2d.xcodeproj */;
@@ -413,7 +376,6 @@
413376
B7E2621B17E7D370007067F0 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Prefix.pch; path = "cocos2d-ui-tests/ios/Prefix.pch"; sourceTree = SOURCE_ROOT; };
414377
B7E2621F17E7D3B2007067F0 /* MainMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MainMenu.h; path = "cocos2d-ui-tests/MainMenu.h"; sourceTree = SOURCE_ROOT; };
415378
B7E2622017E7D3B2007067F0 /* MainMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MainMenu.m; path = "cocos2d-ui-tests/MainMenu.m"; sourceTree = SOURCE_ROOT; };
416-
B7E2622317E7D3D8007067F0 /* cocos2d-ios.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = "cocos2d-ios.xcodeproj"; sourceTree = SOURCE_ROOT; };
417379
B7EE697818186D5200B983FE /* CCTextFieldTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CCTextFieldTest.m; path = "cocos2d-ui-tests/tests/CCTextFieldTest.m"; sourceTree = SOURCE_ROOT; };
418380
B7EE69801818760700B983FE /* CCSprite9SliceTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CCSprite9SliceTest.m; path = "cocos2d-ui-tests/tests/CCSprite9SliceTest.m"; sourceTree = SOURCE_ROOT; };
419381
B7EE69CE1819D82300B983FE /* CCLayoutTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CCLayoutTest.m; path = "cocos2d-ui-tests/tests/CCLayoutTest.m"; sourceTree = SOURCE_ROOT; };
@@ -427,7 +389,6 @@
427389
D2D0E6951950B16300E9103F /* libGLESv3.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libGLESv3.so; path = "../../../Library/Application Support/Developer/Shared/Xcode/Platforms/Android.platform/Developer/SDKs/ApportableSDK1.0.sdk/usr/lib/armeabi/libGLESv3.so"; sourceTree = "<group>"; };
428390
D2D0E6991950B16800E9103F /* libEGL.so */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libEGL.so; path = "../../../Library/Application Support/Developer/Shared/Xcode/Platforms/Android.platform/Developer/SDKs/ApportableSDK1.0.sdk/usr/lib/armeabi/libEGL.so"; sourceTree = "<group>"; };
429391
D2D59896198747DE00BDAF25 /* Music */ = {isa = PBXFileReference; lastKnownFileType = folder; name = Music; path = Resources/Music; sourceTree = SOURCE_ROOT; };
430-
D3269DE719CC985900406282 /* TestShaders.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; name = TestShaders.metal; path = "cocos2d-ui-tests/tests/TestShaders.metal"; sourceTree = SOURCE_ROOT; };
431392
D3269DE919CCC11800406282 /* CCRendererSharedTypes.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = CCRendererSharedTypes.h; path = cocos2d/CCRendererSharedTypes.h; sourceTree = "<group>"; };
432393
D32FDE8519B645CA0078CC16 /* CCTextureTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCTextureTests.m; sourceTree = "<group>"; };
433394
D3395F19187F83E600F22C74 /* CCMemoryTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCMemoryTests.m; sourceTree = "<group>"; };
@@ -451,6 +412,7 @@
451412
D3C1281C199D43E0005D2119 /* CCShaders.metal */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.metal; name = CCShaders.metal; path = cocos2d/Platforms/iOS/CCShaders.metal; sourceTree = SOURCE_ROOT; };
452413
D3C9C866188078B900C58900 /* CCSchedulerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CCSchedulerTest.m; path = "cocos2d-ui-tests/tests/CCSchedulerTest.m"; sourceTree = SOURCE_ROOT; };
453414
D3D6CF5E18BD5F0500A51531 /* CCRendererTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CCRendererTest.m; path = "cocos2d-ui-tests/tests/CCRendererTest.m"; sourceTree = SOURCE_ROOT; };
415+
D3E1842A19E861FC00A08B01 /* MetalShaders */ = {isa = PBXFileReference; lastKnownFileType = folder; name = MetalShaders; path = "cocos2d-ui-tests/MetalShaders"; sourceTree = SOURCE_ROOT; };
454416
D4AFE8D81977100000261299 /* A Damn Mess.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "A Damn Mess.ttf"; sourceTree = "<group>"; };
455417
D4AFE8D91977100000261299 /* Abberancy.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = Abberancy.ttf; sourceTree = "<group>"; };
456418
D4AFE8DA1977100000261299 /* ThisFontIsAbdFont.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = ThisFontIsAbdFont.ttf; sourceTree = "<group>"; };
@@ -526,7 +488,6 @@
526488
isa = PBXFrameworksBuildPhase;
527489
buildActionMask = 2147483647;
528490
files = (
529-
7575B5FC1856535200CA09C8 /* libcocos2d.a in Frameworks */,
530491
75556A04185636F100ED1B0F /* XCTest.framework in Frameworks */,
531492
75556A05185636F100ED1B0F /* Foundation.framework in Frameworks */,
532493
);
@@ -647,7 +608,6 @@
647608
A6167B92189A7D4D0044D391 /* VertexZTest.m */,
648609
A664A4EE18A3D9B8006184B8 /* PositioningTest.m */,
649610
839B149E19CC1E440000E5E2 /* CCPackageTest.m */,
650-
D3269DE719CC985900406282 /* TestShaders.metal */,
651611
);
652612
name = Tests;
653613
path = "cocos2d-ui-tests/tests";
@@ -711,7 +671,7 @@
711671
B7E2621D17E7D38D007067F0 /* AppDelegate */,
712672
B7E2621E17E7D398007067F0 /* Testbed */,
713673
B71B087F17EA5B500082EBC0 /* Tests */,
714-
B7E2622217E7D3CA007067F0 /* libs */,
674+
D3E1842A19E861FC00A08B01 /* MetalShaders */,
715675
B7E261EC17E7D27A007067F0 /* Platform/iOS */,
716676
D3763D2D19E73311006C050D /* Platform/Mac */,
717677
);
@@ -768,24 +728,6 @@
768728
name = Testbed;
769729
sourceTree = "<group>";
770730
};
771-
B7E2622217E7D3CA007067F0 /* libs */ = {
772-
isa = PBXGroup;
773-
children = (
774-
B7E2622317E7D3D8007067F0 /* cocos2d-ios.xcodeproj */,
775-
);
776-
name = libs;
777-
sourceTree = "<group>";
778-
};
779-
B7E2622417E7D3D8007067F0 /* Products */ = {
780-
isa = PBXGroup;
781-
children = (
782-
B7E2622D17E7D3D8007067F0 /* libcocos2d.a */,
783-
D2FEB798194F6CC800FC0574 /* libcocos2dAndroid.a */,
784-
57E144B61974C1E90065F142 /* cocos2dJava.jar */,
785-
);
786-
name = Products;
787-
sourceTree = "<group>";
788-
};
789731
D3763BB119E72F85006C050D /* Products */ = {
790732
isa = PBXGroup;
791733
children = (
@@ -952,13 +894,13 @@
952894
buildPhases = (
953895
B7E2604417E7D278007067F0 /* Sources */,
954896
B7E2604517E7D278007067F0 /* Frameworks */,
897+
D3E1842919E8572700A08B01 /* Compile Metal Shaders */,
955898
B7E2604617E7D278007067F0 /* Resources */,
956899
);
957900
buildRules = (
958901
);
959902
dependencies = (
960903
D3763BD119E72FA8006C050D /* PBXTargetDependency */,
961-
B7E2623317E7D578007067F0 /* PBXTargetDependency */,
962904
);
963905
name = "cocos2d-tests-ios";
964906
productName = "cocos2d-ui-tests-ios";
@@ -977,7 +919,6 @@
977919
);
978920
dependencies = (
979921
D3763C5D19E731BA006C050D /* PBXTargetDependency */,
980-
D3763BD919E73188006C050D /* PBXTargetDependency */,
981922
);
982923
name = "cocos2d-tests-mac";
983924
productName = "cocos2d-ui-tests-ios";
@@ -1012,10 +953,6 @@
1012953
productRefGroup = B7E2604917E7D278007067F0 /* Products */;
1013954
projectDirPath = "";
1014955
projectReferences = (
1015-
{
1016-
ProductGroup = B7E2622417E7D3D8007067F0 /* Products */;
1017-
ProjectRef = B7E2622317E7D3D8007067F0 /* cocos2d-ios.xcodeproj */;
1018-
},
1019956
{
1020957
ProductGroup = D3763BB119E72F85006C050D /* Products */;
1021958
ProjectRef = D3763BB019E72F85006C050D /* cocos2d.xcodeproj */;
@@ -1031,27 +968,6 @@
1031968
/* End PBXProject section */
1032969

1033970
/* Begin PBXReferenceProxy section */
1034-
57E144B61974C1E90065F142 /* cocos2dJava.jar */ = {
1035-
isa = PBXReferenceProxy;
1036-
fileType = archive.jar;
1037-
path = cocos2dJava.jar;
1038-
remoteRef = 57E144B51974C1E90065F142 /* PBXContainerItemProxy */;
1039-
sourceTree = BUILT_PRODUCTS_DIR;
1040-
};
1041-
B7E2622D17E7D3D8007067F0 /* libcocos2d.a */ = {
1042-
isa = PBXReferenceProxy;
1043-
fileType = archive.ar;
1044-
path = libcocos2d.a;
1045-
remoteRef = B7E2622C17E7D3D8007067F0 /* PBXContainerItemProxy */;
1046-
sourceTree = BUILT_PRODUCTS_DIR;
1047-
};
1048-
D2FEB798194F6CC800FC0574 /* libcocos2dAndroid.a */ = {
1049-
isa = PBXReferenceProxy;
1050-
fileType = archive.ar;
1051-
path = libcocos2dAndroid.a;
1052-
remoteRef = D2FEB797194F6CC800FC0574 /* PBXContainerItemProxy */;
1053-
sourceTree = BUILT_PRODUCTS_DIR;
1054-
};
1055971
D3763BB919E72F85006C050D /* libcocos2d.a */ = {
1056972
isa = PBXReferenceProxy;
1057973
fileType = archive.ar;
@@ -1128,7 +1044,6 @@
11281044
D4AFE9371977100000261299 /* konqa32-hd.png in Resources */,
11291045
D4AFE9161977100000261299 /* arial-unicode-26.fnt in Resources */,
11301046
B7E2621417E7D34D007067F0 /* Icon-Small.png in Resources */,
1131-
D23CD73119CB881200C7EB14 /* CCShaders.metal in Resources */,
11321047
D4AFE9361977100000261299 /* konqa32-hd.fnt in Resources */,
11331048
D4AFE93C1977100000261299 /* larabie-16.plist in Resources */,
11341049
D4AFE93A1977100000261299 /* larabie-16-hd.plist in Resources */,
@@ -1151,6 +1066,7 @@
11511066
D4AFE9181977100000261299 /* arial-unicode-26.png in Resources */,
11521067
B7E2621517E7D34D007067F0 /* [email protected] in Resources */,
11531068
D4AFE9481977100000261299 /* Scissor Cuts.ttf in Resources */,
1069+
D3E1842B19E861FC00A08B01 /* MetalShaders in Resources */,
11541070
D4AFE91C1977100000261299 /* bitmapFontTest.png in Resources */,
11551071
D4AFE9251977100000261299 /* boundsTestFont.png in Resources */,
11561072
D4AFE94A1977100000261299 /* tuffy_bold_italic-charmap.plist in Resources */,
@@ -1256,6 +1172,26 @@
12561172
};
12571173
/* End PBXResourcesBuildPhase section */
12581174

1175+
/* Begin PBXShellScriptBuildPhase section */
1176+
D3E1842919E8572700A08B01 /* Compile Metal Shaders */ = {
1177+
isa = PBXShellScriptBuildPhase;
1178+
buildActionMask = 2147483647;
1179+
files = (
1180+
);
1181+
inputPaths = (
1182+
"$(SRCROOT)/cocos2d-ui-tests/MetalShaders/*.metal",
1183+
"$(SRCROOT)/cocos2d/Platforms/iOS/CCShaders.metal",
1184+
);
1185+
name = "Compile Metal Shaders";
1186+
outputPaths = (
1187+
"${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/default.metallib",
1188+
);
1189+
runOnlyForDeploymentPostprocessing = 0;
1190+
shellPath = /usr/bin/ruby;
1191+
shellScript = "SDK = ENV[\"PLATFORM_NAME\"]\nOBJECT_FILE_DIR = ENV[\"OBJECT_FILE_DIR\"]\nSRCROOT = ENV[\"SRCROOT\"]\nBUILT_PRODUCTS_DIR = ENV[\"BUILT_PRODUCTS_DIR\"]\nPRODUCT_NAME = ENV[\"PRODUCT_NAME\"]\n\n# User variables\n# Directory with your custom .metal files in it.\nSHADER_DIR = \"#{SRCROOT}/cocos2d-ui-tests/MetalShaders\"\n# Location of the cocos2d library directory.\nCOCOS2D_DIR = \"#{SRCROOT}/cocos2d\"\n\nMETAL_ARGS = [\n\t\"-arch air64\",\n\t\"-emit-llvm\",\n\t\"-c\",\n\t\"-gline-tables-only\",\n\t\"-ffast-math\",\n\t\"-std=ios-metal1.0\",\n %{-I \"#{COCOS2D_DIR}\"},\n].join(\" \")\n\ndef system(cmd)\n\tputs cmd\n Kernel.system cmd\nend\n\nPRODUCTS = \"#{OBJECT_FILE_DIR}/CCMetalShaders\"\nARCHIVE = \"#{PRODUCTS}/default.metal-ar\"\n\ndef compile_shader(src)\n\tdst = \"#{PRODUCTS}/#{File.basename(src, \".metal\")}.air\"\n\t\n\t# Compile the shader.\n\tsystem %{xcrun -sdk #{SDK} metal #{METAL_ARGS} \"#{src}\" -o \"#{dst}\"}\n\t\n\t# Archive the shader.\n\tsystem %{xcrun -sdk #{SDK} ar r \"#{ARCHIVE}\" \"#{dst}\"}\nend\n\nif SDK == \"iphoneos\"\n\t# Cannot use default.metallib to avoid clashing with Xcode build magic.\n\t# This is part of a workaround due to the iOS simulator not supporting Metal and may go away in the future.\n\tmetal_lib = \"#{BUILT_PRODUCTS_DIR}/#{PRODUCT_NAME}.app/CCShaders.metallib\"\n \n\t# Delete the old products dir and metal lib.\n\tsystem %{rm -rf \"#{PRODUCTS}\"}\n system %{rm -f \"#{metal_lib}\"}\n system %{mkdir -p \"#{PRODUCTS}\"}\n \n # Compile the builtin shaders.\n compile_shader(%{#{COCOS2D_DIR}/Platforms/iOS/CCShaders.metal})\n \n\t# Compile/archive all the shaders in the shader directory.\n Dir.glob(\"#{SHADER_DIR}/*.metal\").each{|src| compile_shader(src)}\n \n\t# Link all shaders into default lib.\n\tsystem %{xcrun -sdk #{SDK} metallib -o \"#{metal_lib}\" \"#{ARCHIVE}\"}\nend\n";
1192+
};
1193+
/* End PBXShellScriptBuildPhase section */
1194+
12591195
/* Begin PBXSourcesBuildPhase section */
12601196
755569FE185636F100ED1B0F /* Sources */ = {
12611197
isa = PBXSourcesBuildPhase;
@@ -1286,7 +1222,6 @@
12861222
isa = PBXSourcesBuildPhase;
12871223
buildActionMask = 2147483647;
12881224
files = (
1289-
D3269DE819CC985900406282 /* TestShaders.metal in Sources */,
12901225
B71B087C17EA5B490082EBC0 /* TestBase.m in Sources */,
12911226
D3870C6018B440150033D885 /* SpritePerformanceTest.m in Sources */,
12921227
B71B088217EA5B6A0082EBC0 /* CCScrollViewTest.m in Sources */,
@@ -1364,21 +1299,11 @@
13641299
target = B7E2604717E7D278007067F0 /* cocos2d-tests-ios */;
13651300
targetProxy = 75556A10185636F100ED1B0F /* PBXContainerItemProxy */;
13661301
};
1367-
B7E2623317E7D578007067F0 /* PBXTargetDependency */ = {
1368-
isa = PBXTargetDependency;
1369-
name = cocos2d;
1370-
targetProxy = B7E2623217E7D578007067F0 /* PBXContainerItemProxy */;
1371-
};
13721302
D3763BD119E72FA8006C050D /* PBXTargetDependency */ = {
13731303
isa = PBXTargetDependency;
13741304
name = "cocos2d-ios";
13751305
targetProxy = D3763BD019E72FA8006C050D /* PBXContainerItemProxy */;
13761306
};
1377-
D3763BD919E73188006C050D /* PBXTargetDependency */ = {
1378-
isa = PBXTargetDependency;
1379-
name = cocos2d;
1380-
targetProxy = D3763BDA19E73188006C050D /* PBXContainerItemProxy */;
1381-
};
13821307
D3763C5D19E731BA006C050D /* PBXTargetDependency */ = {
13831308
isa = PBXTargetDependency;
13841309
name = "cocos2d-mac";

cocos2d/Platforms/iOS/CCMetalSupport.m

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ -(instancetype)init
3838
{
3939
if((self = [super init])){
4040
_device = MTLCreateSystemDefaultDevice();
41-
_library = [_device newDefaultLibrary];
41+
42+
// Cannot use default.metallib to avoid clashing with Xcode build magic.
43+
// This is part of a workaround due to the iOS simulator not supporting Metal and may go away in the future.
44+
NSURL *url = [[NSBundle mainBundle] URLForResource:@"CCShaders.metallib" withExtension:nil];
45+
46+
NSError *error = nil;
47+
_library = [_device newLibraryWithFile:[url path] error:&error];
48+
NSAssert(!error, @"Cannot load default CCShaders.metallib: %@", error);
4249

4350
_commandQueue = [_device newCommandQueue];
4451
_currentCommandBuffer = [_commandQueue commandBuffer];

0 commit comments

Comments
 (0)