Skip to content

Commit 63b5f55

Browse files
author
Eric Miller
committed
Add unity exclusion file
1 parent 28192ed commit 63b5f55

File tree

4 files changed

+79
-14
lines changed

4 files changed

+79
-14
lines changed

Sources/UBKit/Files/Xcode/SpecFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ extension File {
4444
- \(projectName)
4545
- Vendor
4646
prebuildScripts:
47-
- script: rsync -rc --exclude-from=DemoApp/Unity/rsync_exclude --delete $UNITY_IOS_EXPORT_PATH/Classes/ DemoApp/Unity/Classes/\\nrsync -rc --exclude-from=DemoApp/Unity/rsync_exclude --delete $UNITY_IOS_EXPORT_PATH/Libraries/ DemoApp/Unity/Libraries/
47+
- script: rsync -rc --exclude-from=rsync_unity_exclusion --delete $UNITY_IOS_EXPORT_PATH/Classes/ Vendor/UBK/Classes/\\nrsync -rc --exclude-from=rsync_unity_exclusion --delete $UNITY_IOS_EXPORT_PATH/Libraries/ Vendor/UBK/Libraries/
4848
name: UnityBuildKit Prebuild
4949
postbuildScripts:
5050
- script: rm -rf "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Data"\\ncp -Rf "$UNITY_IOS_EXPORT_PATH/Data" "$TARGET_BUILD_DIR/$PRODUCT_NAME.app/Data"
@@ -64,7 +64,7 @@ extension File {
6464
OTHER_CFLAGS: $(inherited) -DINIT_SCRIPTING_BACKEND=1 -fno-strict-overflow -DRUNTIME_IL2CPP=1
6565
CLANG_CXX_LANGUAGE_STANDARD: c++11
6666
CLANG_CXX_LIBRARY: libc++
67-
SWIFT_OBJC_BRIDGING_HEADER: UnityBridge.h
67+
SWIFT_OBJC_BRIDGING_HEADER: UnityBuildKit/UnityBridge/UnityBridge.h
6868
CLANG_ENABLE_MODULES: NO
6969
CLANG_WARN_BOOL_CONVERSION: NO
7070
CLANG_WARN_CONSTANT_CONVERSION: NO
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
//
2+
// UnityExclusionFile.swift
3+
// UBKit
4+
//
5+
// Copyright (c) 2017 Handsome
6+
//
7+
// Permission is hereby granted, free of charge, to any person obtaining a copy
8+
// of this software and associated documentation files (the "Software"), to deal
9+
// in the Software without restriction, including without limitation the rights
10+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
// copies of the Software, and to permit persons to whom the Software is
12+
// furnished to do so, subject to the following conditions:
13+
//
14+
// The above copyright notice and this permission notice shall be included in all
15+
// copies or substantial portions of the Software.
16+
//
17+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
// SOFTWARE.
24+
25+
import Foundation
26+
27+
extension File {
28+
29+
class func unityExclusionFile() -> Data? {
30+
let file = """
31+
main.mm
32+
UnityAppController.h
33+
UnityAppController.mm
34+
MetalHelper.mm
35+
""".data(using: .utf8)
36+
return file
37+
}
38+
}

Sources/UBKit/Workers/XcodeProject.swift

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,23 @@ class XcodeProject {
5555
return iOSFolderResult
5656
}
5757

58-
print("Generating iOS spec file")
58+
// print("Generating iOS spec file")
5959
let specFileResult = createSpecFile()
6060
guard specFileResult == .success else {
6161
return specFileResult
6262
}
6363

64+
let unityExclusionFileResult = createUnityExclusionFile()
65+
guard unityExclusionFileResult == .success else {
66+
return unityExclusionFileResult
67+
}
68+
6469
let projectFolderResult = createProjectFolder()
6570
guard projectFolderResult == .success else {
6671
return projectFolderResult
6772
}
6873

69-
print("Generating iOS source files")
74+
// print("Generating iOS source files")
7075
let sourceFileResult = createSourceFiles()
7176
guard sourceFileResult == .success else {
7277
return sourceFileResult
@@ -77,18 +82,18 @@ class XcodeProject {
7782
return assetCatalogResult
7883
}
7984

80-
let unityFolderResult = createUnityVendorFolder()
81-
guard unityFolderResult == .success else {
82-
return unityFolderResult
83-
}
84-
85-
print("Generating Unity bridging files")
85+
// print("Generating Unity bridging files")
8686
let unityFilesResult = createUnityBridgeFiles()
8787
guard unityFilesResult == .success else {
8888
return unityFilesResult
8989
}
9090

91-
print("Generating iOS project")
91+
let unityFolderResult = createUnityVendorFolder()
92+
guard unityFolderResult == .success else {
93+
return unityFolderResult
94+
}
95+
96+
// print("Generating iOS project")
9297
let projectGenerationResult = generateXcodeProject()
9398
guard projectGenerationResult == .success else {
9499
return projectGenerationResult
@@ -123,12 +128,30 @@ private extension XcodeProject {
123128
bundleIdentifier: bundleIdentifier,
124129
unityVersion: unityVersion
125130
)
126-
let success = fileManager.createFile(
131+
132+
guard fileManager.createFile(
127133
atPath: workingPath.appending(specFileName),
128134
contents: contents,
129-
attributes: nil)
135+
attributes: nil) else {
136+
return .failure(UBKitError.unableToCreateFile("Spec file"))
137+
}
138+
139+
return .success
140+
}
141+
142+
func createUnityExclusionFile() -> Result {
143+
guard UBKit.validatePath(workingPath, isDirectory: true) else {
144+
return .failure(UBKitError.invalidFolder(workingPath))
145+
}
130146

131-
return success ? .success : .failure(UBKitError.unableToCreateFile("Spec File"))
147+
guard fileManager.createFile(
148+
atPath: workingPath.appending("rsync_unity_exclusion"),
149+
contents: File.unityExclusionFile(),
150+
attributes: nil) else {
151+
return .failure(UBKitError.unableToCreateFile("Unity exclusion file"))
152+
}
153+
154+
return .success
132155
}
133156

134157
func createProjectFolder() -> Result {

UnityBuildKit.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
D43456441FA3AD5B00CE9717 /* config.swift in Sources */ = {isa = PBXBuildFile; fileRef = D43456431FA3AD5B00CE9717 /* config.swift */; };
1111
D48370ED1FA9137E00A05A8B /* UnityProjectScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48370EB1FA912B200A05A8B /* UnityProjectScript.swift */; };
12+
D48371001FA9F5A500A05A8B /* UnityExclusionFile.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48370FF1FA9F5A500A05A8B /* UnityExclusionFile.swift */; };
1213
OBJ_197 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_6 /* Package.swift */; };
1314
OBJ_203 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_67 /* Package.swift */; };
1415
OBJ_209 /* Package.swift in Sources */ = {isa = PBXBuildFile; fileRef = OBJ_116 /* Package.swift */; };
@@ -471,6 +472,7 @@
471472
"AEXML::AEXML::Product" /* AEXML.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = AEXML.framework; sourceTree = BUILT_PRODUCTS_DIR; };
472473
D43456431FA3AD5B00CE9717 /* config.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = config.swift; sourceTree = "<group>"; };
473474
D48370EB1FA912B200A05A8B /* UnityProjectScript.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnityProjectScript.swift; sourceTree = "<group>"; };
475+
D48370FF1FA9F5A500A05A8B /* UnityExclusionFile.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnityExclusionFile.swift; sourceTree = "<group>"; };
474476
"JSONUtilities::JSONUtilities::Product" /* JSONUtilities.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = JSONUtilities.framework; sourceTree = BUILT_PRODUCTS_DIR; };
475477
OBJ_10 /* File.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = File.swift; sourceTree = "<group>"; };
476478
OBJ_100 /* PBXSourcesBuildPhase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PBXSourcesBuildPhase.swift; sourceTree = "<group>"; };
@@ -901,6 +903,7 @@
901903
OBJ_22 /* MainStoryboardFile.swift */,
902904
OBJ_23 /* SpecFile.swift */,
903905
OBJ_24 /* ViewControllerFile.swift */,
906+
D48370FF1FA9F5A500A05A8B /* UnityExclusionFile.swift */,
904907
);
905908
path = Xcode;
906909
sourceTree = "<group>";
@@ -1620,6 +1623,7 @@
16201623
files = (
16211624
OBJ_281 /* File.swift in Sources */,
16221625
OBJ_282 /* UnityEditorBuildScript.swift in Sources */,
1626+
D48371001FA9F5A500A05A8B /* UnityExclusionFile.swift in Sources */,
16231627
OBJ_283 /* BridgeHeaderFile.swift in Sources */,
16241628
OBJ_284 /* MessageBridge.swift in Sources */,
16251629
OBJ_285 /* UnityUtilsFile.swift in Sources */,

0 commit comments

Comments
 (0)