Skip to content

Commit 5c59342

Browse files
mhuusko5paulb777
authored andcommitted
macOS (#38)
* Example/Core: create macOS app/tests target * Example/Core: Core_Example/Tests -> Core_Example/Tests_iOS * Example/Core: macOS building/tests passing * Example/Database: separate iOS/macOS targets * BuildFrameworks: macOS * .travis.yml, test.sh: AllUnitTests -> AllUnitTests_iOS * test.sh: add AllUnitTests_macOS * Example/Storage: Example/Tests->_iOS * Example/Storage: macOS * test.sh: try to prevent double error 65 * test.sh: build before test * Example/Auth|Messaging: -> _iOS * Example/Auth: macOS build * Example/Auth: macOS passing * Example/Firebase: pod de/re-integrate; fix static DerivedData references; copy phase for OCMock * Example/Firebase: manually copied OCMock, Products Dir vs. Frameworks * Example/Firebase: copied OCMock, prevent header removal * Example/Storage: integration tests sdk fix * Example/Auth: macOS exclude FIRAuthAppCredentialManager; cleanup * Firebase/Core: remove nullability annotation * Firebase/Core|Database: correct TARGET_X usage for correctness and anticipation of OS_WATCH|TV branches * build.swift: style fix * Firebase/Core: FIRLogger: fix macOS intermittent va_list error
1 parent 6f700dd commit 5c59342

File tree

139 files changed

+9961
-1497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+9961
-1497
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ language: objective-c
33
cache:
44
- bundler
55
- cocoapods
6-
podfile: Example/Podfile
76

87
rvm: 2.3.1
98
before_install:
@@ -12,6 +11,6 @@ before_install:
1211
- gem install xcpretty
1312
- pod install --project-directory=Example --repo-update
1413

15-
script:
14+
script:
1615
- ./test.sh
1716
- pod lib lint FirebaseDev.podspec

BuildFrameworks/FrameworkMaker.xcodeproj/project.pbxproj

Lines changed: 178 additions & 20 deletions
Large diffs are not rendered by default.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0830"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "05A46BD61CC9B2BE007BDB33"
18+
BuildableName = "FrameworkMaker_iOS.app"
19+
BlueprintName = "FrameworkMaker_iOS"
20+
ReferencedContainer = "container:FrameworkMaker.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
<MacroExpansion>
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "05A46BD61CC9B2BE007BDB33"
36+
BuildableName = "FrameworkMaker_iOS.app"
37+
BlueprintName = "FrameworkMaker_iOS"
38+
ReferencedContainer = "container:FrameworkMaker.xcodeproj">
39+
</BuildableReference>
40+
</MacroExpansion>
41+
<AdditionalOptions>
42+
</AdditionalOptions>
43+
</TestAction>
44+
<LaunchAction
45+
buildConfiguration = "Debug"
46+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
47+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
48+
launchStyle = "0"
49+
useCustomWorkingDirectory = "NO"
50+
ignoresPersistentStateOnLaunch = "NO"
51+
debugDocumentVersioning = "YES"
52+
debugServiceExtension = "internal"
53+
allowLocationSimulation = "YES">
54+
<BuildableProductRunnable
55+
runnableDebuggingMode = "0">
56+
<BuildableReference
57+
BuildableIdentifier = "primary"
58+
BlueprintIdentifier = "05A46BD61CC9B2BE007BDB33"
59+
BuildableName = "FrameworkMaker_iOS.app"
60+
BlueprintName = "FrameworkMaker_iOS"
61+
ReferencedContainer = "container:FrameworkMaker.xcodeproj">
62+
</BuildableReference>
63+
</BuildableProductRunnable>
64+
<AdditionalOptions>
65+
</AdditionalOptions>
66+
</LaunchAction>
67+
<ProfileAction
68+
buildConfiguration = "Release"
69+
shouldUseLaunchSchemeArgsEnv = "YES"
70+
savedToolIdentifier = ""
71+
useCustomWorkingDirectory = "NO"
72+
debugDocumentVersioning = "YES">
73+
<BuildableProductRunnable
74+
runnableDebuggingMode = "0">
75+
<BuildableReference
76+
BuildableIdentifier = "primary"
77+
BlueprintIdentifier = "05A46BD61CC9B2BE007BDB33"
78+
BuildableName = "FrameworkMaker_iOS.app"
79+
BlueprintName = "FrameworkMaker_iOS"
80+
ReferencedContainer = "container:FrameworkMaker.xcodeproj">
81+
</BuildableReference>
82+
</BuildableProductRunnable>
83+
</ProfileAction>
84+
<AnalyzeAction
85+
buildConfiguration = "Debug">
86+
</AnalyzeAction>
87+
<ArchiveAction
88+
buildConfiguration = "Release"
89+
revealArchiveInOrganizer = "YES">
90+
</ArchiveAction>
91+
</Scheme>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "0830"
4+
version = "1.3">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES">
8+
<BuildActionEntries>
9+
<BuildActionEntry
10+
buildForTesting = "YES"
11+
buildForRunning = "YES"
12+
buildForProfiling = "YES"
13+
buildForArchiving = "YES"
14+
buildForAnalyzing = "YES">
15+
<BuildableReference
16+
BuildableIdentifier = "primary"
17+
BlueprintIdentifier = "D013F9FE1ED9EB9900FD68A9"
18+
BuildableName = "FrameworkMaker_macOS.app"
19+
BlueprintName = "FrameworkMaker_macOS"
20+
ReferencedContainer = "container:FrameworkMaker.xcodeproj">
21+
</BuildableReference>
22+
</BuildActionEntry>
23+
</BuildActionEntries>
24+
</BuildAction>
25+
<TestAction
26+
buildConfiguration = "Debug"
27+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29+
shouldUseLaunchSchemeArgsEnv = "YES">
30+
<Testables>
31+
</Testables>
32+
<MacroExpansion>
33+
<BuildableReference
34+
BuildableIdentifier = "primary"
35+
BlueprintIdentifier = "D013F9FE1ED9EB9900FD68A9"
36+
BuildableName = "FrameworkMaker_macOS.app"
37+
BlueprintName = "FrameworkMaker_macOS"
38+
ReferencedContainer = "container:FrameworkMaker.xcodeproj">
39+
</BuildableReference>
40+
</MacroExpansion>
41+
<AdditionalOptions>
42+
</AdditionalOptions>
43+
</TestAction>
44+
<LaunchAction
45+
buildConfiguration = "Debug"
46+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
47+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
48+
launchStyle = "0"
49+
useCustomWorkingDirectory = "NO"
50+
ignoresPersistentStateOnLaunch = "NO"
51+
debugDocumentVersioning = "YES"
52+
debugServiceExtension = "internal"
53+
allowLocationSimulation = "YES">
54+
<BuildableProductRunnable
55+
runnableDebuggingMode = "0">
56+
<BuildableReference
57+
BuildableIdentifier = "primary"
58+
BlueprintIdentifier = "D013F9FE1ED9EB9900FD68A9"
59+
BuildableName = "FrameworkMaker_macOS.app"
60+
BlueprintName = "FrameworkMaker_macOS"
61+
ReferencedContainer = "container:FrameworkMaker.xcodeproj">
62+
</BuildableReference>
63+
</BuildableProductRunnable>
64+
<AdditionalOptions>
65+
</AdditionalOptions>
66+
</LaunchAction>
67+
<ProfileAction
68+
buildConfiguration = "Release"
69+
shouldUseLaunchSchemeArgsEnv = "YES"
70+
savedToolIdentifier = ""
71+
useCustomWorkingDirectory = "NO"
72+
debugDocumentVersioning = "YES">
73+
<BuildableProductRunnable
74+
runnableDebuggingMode = "0">
75+
<BuildableReference
76+
BuildableIdentifier = "primary"
77+
BlueprintIdentifier = "D013F9FE1ED9EB9900FD68A9"
78+
BuildableName = "FrameworkMaker_macOS.app"
79+
BlueprintName = "FrameworkMaker_macOS"
80+
ReferencedContainer = "container:FrameworkMaker.xcodeproj">
81+
</BuildableReference>
82+
</BuildableProductRunnable>
83+
</ProfileAction>
84+
<AnalyzeAction
85+
buildConfiguration = "Debug">
86+
</AnalyzeAction>
87+
<ArchiveAction
88+
buildConfiguration = "Release"
89+
revealArchiveInOrganizer = "YES">
90+
</ArchiveAction>
91+
</Scheme>

BuildFrameworks/Podfile

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
1-
platform :ios, '7.0'
2-
31
project 'FrameworkMaker.xcodeproj'
42

5-
target 'FrameworkMaker' do
3+
target 'FrameworkMaker_iOS' do
4+
platform :ios, '7.0'
5+
66
pod 'FirebaseAuth', :path => '../Firebase/Auth'
77
pod 'FirebaseCore', :path => '../Firebase/Core'
88
pod 'FirebaseDatabase', :path => '../Firebase/Database'
99
pod 'FirebaseMessaging', :path => '../Firebase/Messaging'
1010
pod 'FirebaseStorage', :path => '../Firebase/Storage'
1111
end
1212

13+
target 'FrameworkMaker_macOS' do
14+
platform :osx, '10.10'
15+
16+
pod 'FirebaseAuth', :path => '../Firebase/Auth'
17+
pod 'FirebaseCore', :path => '../Firebase/Core'
18+
pod 'FirebaseDatabase', :path => '../Firebase/Database'
19+
pod 'FirebaseStorage', :path => '../Firebase/Storage'
20+
end

BuildFrameworks/build.swift

Lines changed: 46 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,20 @@ func colorPrint(color: Colors, text: String) {
3333
print(color.rawValue + text + "\u{001B}[0;0m")
3434
}
3535

36-
let allFrameworks = ["FirebaseAuth",
37-
"FirebaseCore",
38-
"FirebaseDatabase",
39-
"FirebaseMessaging",
40-
"FirebaseStorage"]
36+
enum Platform: String {
37+
case iOS
38+
case macOS
39+
case tvOS
40+
case watchOS
41+
}
42+
43+
let allFrameworks: [String: [Platform]] = [
44+
"FirebaseAuth": [.iOS, .macOS],
45+
"FirebaseCore": [.iOS, .macOS],
46+
"FirebaseDatabase": [.iOS, .macOS],
47+
"FirebaseMessaging": [.iOS],
48+
"FirebaseStorage": [.iOS, .macOS]
49+
]
4150

4251
let currentDirectoryURL = URL(fileURLWithPath: FileManager.default.currentDirectoryPath)
4352
let url = URL(fileURLWithPath: CommandLine.arguments[0], relativeTo: currentDirectoryURL)
@@ -63,7 +72,7 @@ func processOptions() -> [String] {
6372
colorPrint(color:Colors.red, text:"-all must be a solo option")
6473
usage()
6574
}
66-
doFrameworks = allFrameworks
75+
doFrameworks = Array(allFrameworks.keys)
6776
break whileLoop
6877
case "-f":
6978
optIndex += 1
@@ -72,7 +81,7 @@ func processOptions() -> [String] {
7281
usage()
7382
}
7483
let framework = CommandLine.arguments[optIndex]
75-
guard allFrameworks.contains(framework) else {
84+
guard allFrameworks.keys.contains(framework) else {
7685
colorPrint(color:Colors.red, text:"\(framework) is not a valid framework")
7786
usage()
7887
}
@@ -110,17 +119,28 @@ func syncExec(command: String, args: [String] = []) {
110119
}
111120
}
112121

113-
func buildThin(framework: String, arch: String, sdk: String, parentDir: String) -> [String] {
122+
func buildThin(framework: String, multiplatform: Bool, arch: String, multisdk: Bool, sdk: String, parentDir: String) -> [String] {
123+
let schemeSuffix: String
124+
if !multiplatform {
125+
schemeSuffix = ""
126+
} else if sdk.hasPrefix("mac") {
127+
schemeSuffix = "-OSX"
128+
} else if sdk.hasPrefix("iphone") {
129+
schemeSuffix = "-iOS"
130+
} else {
131+
fatalError("TODO: tvOS/watchOS")
132+
}
133+
114134
let buildDir = parentDir + "/" + arch
115135
let standardOptions = [ "build",
116136
"-configuration", "release",
117137
"-workspace", "FrameworkMaker.xcworkspace",
118-
"-scheme", framework,
138+
"-scheme", framework + schemeSuffix,
119139
"GCC_GENERATE_DEBUGGING_SYMBOLS=No"]
120140
let bitcode = (sdk == "iphoneos") ? ["OTHER_CFLAGS=\"" + "-fembed-bitcode\""] : []
121141
let args = standardOptions + ["ARCHS=" + arch, "BUILD_DIR=" + buildDir, "-sdk", sdk] + bitcode
122142
syncExec(command:"/usr/bin/xcodebuild", args:args)
123-
return [buildDir + "/Release-" + sdk + "/" + framework + "/lib" + framework + ".a"]
143+
return [buildDir + "/Release" + (multisdk ? "-\(sdk)" : "") + "/" + framework + schemeSuffix + "/lib" + framework + schemeSuffix + ".a"]
124144
}
125145

126146
func createFile(file: String, content: String) {
@@ -144,15 +164,21 @@ func makeModuleMap(framework: String, dir: String) {
144164
createFile(file:moduleFile, content:content)
145165
}
146166

147-
func buildFramework(withName framework: String, outputDir: String) {
167+
func buildFramework(withName framework: String, multiplatform: Bool, platform: Platform, outputDir: String) {
148168
let buildDir = tempDir()
149169
var thinArchives = [String]()
150-
thinArchives += buildThin(framework:framework, arch:"arm64", sdk:"iphoneos", parentDir:buildDir)
151-
thinArchives += buildThin(framework:framework, arch:"armv7", sdk:"iphoneos", parentDir:buildDir)
152-
thinArchives += buildThin(framework:framework, arch:"i386", sdk:"iphonesimulator", parentDir:buildDir)
153-
thinArchives += buildThin(framework:framework, arch:"x86_64", sdk:"iphonesimulator", parentDir:buildDir)
170+
switch platform {
171+
case .iOS:
172+
thinArchives += buildThin(framework:framework, multiplatform: multiplatform, arch:"arm64", multisdk: true, sdk:"iphoneos", parentDir:buildDir)
173+
thinArchives += buildThin(framework:framework, multiplatform: multiplatform, arch:"armv7", multisdk: true, sdk:"iphoneos", parentDir:buildDir)
174+
thinArchives += buildThin(framework:framework, multiplatform: multiplatform, arch:"i386", multisdk: true, sdk:"iphonesimulator", parentDir:buildDir)
175+
thinArchives += buildThin(framework:framework, multiplatform: multiplatform, arch:"x86_64", multisdk: true, sdk:"iphonesimulator", parentDir:buildDir)
176+
case .macOS:
177+
thinArchives += buildThin(framework:framework, multiplatform: multiplatform, arch:"x86_64", multisdk: false, sdk:"macosx", parentDir:buildDir)
178+
default: fatalError("TODO: tvOS/watchOS")
179+
}
154180

155-
let frameworkDir = outputDir + "/" + framework + ".framework"
181+
let frameworkDir = outputDir + "/" + framework + "_" + platform.rawValue + ".framework"
156182
syncExec(command:"/bin/mkdir", args:["-p", frameworkDir])
157183
let fatArchive = frameworkDir + "/" + framework
158184
syncExec(command:"/usr/bin/lipo", args:["-create", "-output", fatArchive] + thinArchives)
@@ -171,7 +197,10 @@ let outputDir = tempDir()
171197
syncExec(command:"/usr/local/bin/pod", args:["update"])
172198

173199
for f in frameworks {
174-
buildFramework(withName:f, outputDir:outputDir)
200+
let platforms = allFrameworks[f]!
201+
for p in platforms {
202+
buildFramework(withName:f, multiplatform:platforms.count > 1, platform:p, outputDir:outputDir)
203+
}
175204
}
176205

177206
print()
File renamed without changes.

BuildFrameworks/macOS-Info.plist

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleDevelopmentRegion</key>
6+
<string>en</string>
7+
<key>CFBundleExecutable</key>
8+
<string>$(EXECUTABLE_NAME)</string>
9+
<key>CFBundleIconFile</key>
10+
<string></string>
11+
<key>CFBundleIdentifier</key>
12+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
13+
<key>CFBundleInfoDictionaryVersion</key>
14+
<string>6.0</string>
15+
<key>CFBundleName</key>
16+
<string>$(PRODUCT_NAME)</string>
17+
<key>CFBundlePackageType</key>
18+
<string>APPL</string>
19+
<key>CFBundleShortVersionString</key>
20+
<string>1.0</string>
21+
<key>CFBundleVersion</key>
22+
<string>1.0</string>
23+
<key>LSMinimumSystemVersion</key>
24+
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
25+
<key>NSHumanReadableCopyright</key>
26+
<string>Copyright © 2017 Google, Inc. All rights reserved.</string>
27+
<key>NSMainStoryboardFile</key>
28+
<string>Main</string>
29+
<key>NSPrincipalClass</key>
30+
<string>NSApplication</string>
31+
</dict>
32+
</plist>

0 commit comments

Comments
 (0)