Skip to content

Commit 1c406ee

Browse files
author
Clément Le Provost
committed
Fix Cocoapods support on OS X
Cocoapods apparently doesn’t allow subspecs of a given pod to have different deployment platforms. (At least, it doesn’t work with the current version 1.0 of Cocoapods.) Since the offline core is not available on OS X, we have to resort to publishing two different pods: - AlgoliaSearch-Client-Swift, corresponding to the Online subspec, supporting iOS and OS X - AlgoliaSearch-Offline-Swift, corresponding to the Offline subspec, with a dependency on AlgoliaSearchOfflineCore, supporting only iOS Refs #68.
1 parent 5a1d47b commit 1c406ee

File tree

3 files changed

+33
-34
lines changed

3 files changed

+33
-34
lines changed

AlgoliaSearch-Client-Swift.podspec

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,10 @@ Pod::Spec.new do |s|
99
s.source = { :git => 'https://github.com/algolia/algoliasearch-client-swift.git', :tag => s.version }
1010

1111
s.ios.deployment_target = '8.0'
12+
s.osx.deployment_target = '10.10'
1213

13-
# By default, do not require the offline Core.
14-
s.default_subspec = 'Online'
15-
16-
# Online-only API client.
17-
s.subspec 'Online' do |online|
18-
online.ios.deployment_target = '8.0'
19-
online.osx.deployment_target = '10.10'
20-
# No additional dependency.
21-
# WARNING: Cocoapods complains when a subspec is empty, so we must define something additional here to keep
22-
# it satisfied.
23-
online.source_files = [
24-
'Source/*.swift',
25-
'Source/Helpers/*.swift',
26-
]
27-
end
28-
29-
# Offline-enabled API client.
30-
# NOTE: Disabled until release.
31-
s.subspec 'Offline' do |offline|
32-
offline.dependency 'AlgoliaSearchOfflineCore-iOS', '0.1'
33-
# Activate Core-dependent code.
34-
# WARNING: Specifying the preprocessor macro is not enough; it must be added to Swift flags as well.
35-
offline.pod_target_xcconfig = {
36-
'GCC_PREPROCESSOR_DEFINITIONS' => 'ALGOLIA_SDK=1',
37-
'OTHER_SWIFT_FLAGS' => '-DALGOLIA_SDK'
38-
}
39-
offline.source_files = [
40-
'Source/*.swift',
41-
'Source/Helpers/*.swift',
42-
'Source/Offline/*.swift'
43-
]
44-
end
14+
s.source_files = [
15+
'Source/*.swift',
16+
'Source/Helpers/*.swift',
17+
]
4518
end
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Pod::Spec.new do |s|
2+
s.name = 'AlgoliaSearch-Offline-Swift'
3+
s.module_name = 'AlgoliaSearch'
4+
s.version = '3.2'
5+
s.license = 'MIT'
6+
s.summary = 'Algolia Search API Client for iOS & OS X written in Swift.'
7+
s.homepage = 'https://github.com/algolia/algoliasearch-client-swift'
8+
s.author = { 'Algolia' => '[email protected]' }
9+
s.source = { :git => 'https://github.com/algolia/algoliasearch-client-swift.git', :tag => s.version }
10+
11+
s.ios.deployment_target = '8.0'
12+
13+
s.dependency 'AlgoliaSearchOfflineCore-iOS', '0.1'
14+
15+
# Activate Core-dependent code.
16+
# WARNING: Specifying the preprocessor macro is not enough; it must be added to Swift flags as well.
17+
s.pod_target_xcconfig = {
18+
'GCC_PREPROCESSOR_DEFINITIONS' => 'ALGOLIA_SDK=1',
19+
'OTHER_SWIFT_FLAGS' => '-DALGOLIA_SDK'
20+
}
21+
s.source_files = [
22+
'Source/*.swift',
23+
'Source/Helpers/*.swift',
24+
'Source/Offline/*.swift'
25+
]
26+
end

doc/offline-mode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ Offline features are brought by Algolia's **Offline SDK**, which is actually com
2929

3030
1. Obtain a **license key** from [Algolia](https://www.algolia.com/).
3131

32-
2. In your Podfile, explicitly reference the "Offline" Cocoapods [subspec](https://guides.cocoapods.org/syntax/podspec.html#subspec):
32+
2. In your Podfile, reference the offline pod:
3333

3434
```ruby
35-
pod 'AlgoliaSearch-Client-Swift/Offline', '~> ${WHATEVER_IS_THE_LATEST_VERSION}'
35+
pod 'AlgoliaSearch-Offline-Swift', '~> ${WHATEVER_IS_THE_LATEST_VERSION}'
3636
```
3737

3838
*NOTE: Because of its intrinsic limitations, Carthage is **not** supported for the offline mode.*

0 commit comments

Comments
 (0)