Compare commits
218 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1356a8056f | |||
| 0ddb37bea3 | |||
| 537cad5923 | |||
| 0c4ce2213b | |||
| a91dacb29c | |||
| 895a6f2583 | |||
| 73f71a99b2 | |||
| 41664914f4 | |||
| 53bc97ba63 | |||
| c321189b66 | |||
| 317d67ca90 | |||
| cbcef835f7 | |||
| 47a1870de1 | |||
| da2197c909 | |||
| 3ee8b04118 | |||
| 29c1a3805f | |||
| 4dc11a6e2d | |||
| 7a4d9c554c | |||
| cf4bb0352a | |||
| 8c6a822eca | |||
| 4c6718efb3 | |||
| 1306f12804 | |||
| 764cb98a59 | |||
| 130d71ce3c | |||
| 490c2a4d56 | |||
| 6e98f270bf | |||
| b3d090c3fd | |||
| 4e5cf238c9 | |||
| f4f660d81d | |||
| 211b2fce97 | |||
| 3aa79d1c69 | |||
| 4d085d1329 | |||
| 84845c9b17 | |||
| f4c38f281e | |||
| 99315e32eb | |||
| b48fe9840a | |||
| 6a6fbf906b | |||
| 7e5a0c8ada | |||
| 1f7ce50035 | |||
| 6656116e12 | |||
| 3700f687a2 | |||
| 92499c9561 | |||
| 7c5ea83dc4 | |||
| 4793232d8c | |||
| 2c09b4d6d1 | |||
| 34e920a348 | |||
| 3357630deb | |||
| f23492ee40 | |||
| c817980dd8 | |||
| 328d1b98a5 | |||
| 9f77677014 | |||
| b13a38cf9e | |||
| edb0d3e576 | |||
| bd8a503085 | |||
| 6af8f18a63 | |||
| bcf2329312 | |||
| b01b7fb055 | |||
| 0515e7358d | |||
| 463f9a37a3 | |||
| 6c802d2c39 | |||
| 967a2342b4 | |||
| d7b3db1476 | |||
| f65949bafc | |||
| ba420c27a1 | |||
| ef66212ba3 | |||
| 1d71eb08ca | |||
| 689ff2ed29 | |||
| 126c5d3191 | |||
| 3b4dab4c97 | |||
| 7de69e1fa0 | |||
| a44d11b72f | |||
| 7352769a47 | |||
| 5be2995ef1 | |||
| 306a52f9d5 | |||
| 764024700f | |||
| ee6c9b6115 | |||
| da5cc8f1a7 | |||
| b7b586cba1 | |||
| b50691205a | |||
| d3d1f3cbf9 | |||
| 8d4c71fe5a | |||
| 591c1bfefc | |||
| 786b56b5ea | |||
| 4938023a60 | |||
| 0db1d2433d | |||
| fbb1bcc94f | |||
| f41d28382d | |||
| 7a242a7656 | |||
| 1c7e8419c7 | |||
| 03cf8f7b32 | |||
| a36efc1c5e | |||
| 19d1d38d63 | |||
| 2bae6bce60 | |||
| 66bca3d5b6 | |||
| 4dcdabc8ae | |||
| d8859fb44a | |||
| fef5eb10ac | |||
| fc337f0fe3 | |||
| d3759baff6 | |||
| bd45b97400 | |||
| 4479b58ace | |||
| 47043a213e | |||
| cc399031e7 | |||
| d50ca57d49 | |||
| 6f5ab994a0 | |||
| 33601418f3 | |||
| 691762242f | |||
| 345b6e164a | |||
| 4b0554b539 | |||
| d786eb17dd | |||
| d4d275cda6 | |||
| cdf9f43c9b | |||
| f8a4b40281 | |||
| 3803a72548 | |||
| 8f3fad759e | |||
| c6bf18181f | |||
| d6908e1feb | |||
| 288673ecb3 | |||
| 14c13d7f35 | |||
| 11a9c7fb70 | |||
| c670a220d5 | |||
| 049737dd2f | |||
| 79adaed6d3 | |||
| c7f9c82f81 | |||
| ad9c095041 | |||
| 409f0f1990 | |||
| 685809e6ec | |||
| dcea032624 | |||
| ace73a2672 | |||
| ff6645d012 | |||
| e3448d9148 | |||
| b14c4aeb10 | |||
| 0adc671bd1 | |||
| 1d7533a516 | |||
| 6ad4b82ec0 | |||
| 6bc96bc8af | |||
| 8b9879a9a2 | |||
| 406e47206a | |||
| 69e8eef0f1 | |||
| 78e789cbce | |||
| ebbe9a1513 | |||
| bc0511261f | |||
| 6a0fa295cb | |||
| 73d8990afa | |||
| d7d8f28a36 | |||
| e97883efb0 | |||
| 342fdf9c92 | |||
| feb5064b93 | |||
| 9778236416 | |||
| 184e1f4543 | |||
| b50046c071 | |||
| 8be1139114 | |||
| afc8e49b18 | |||
| 333fa96b62 | |||
| d611ea240e | |||
| ee16baacfc | |||
| b4221e25a1 | |||
| 0edd3747e8 | |||
| 0c93e868f0 | |||
| ada995590f | |||
| c0e5df3443 | |||
| 37d42281c1 | |||
| 6c56e12eeb | |||
| 948b3cd780 | |||
| adde50a3d0 | |||
| 450a2f8a72 | |||
| 59719a0c37 | |||
| f6afdfd08e | |||
| abf2202eeb | |||
| 938108f2ab | |||
| 9d619d6a25 | |||
| 58efc586db | |||
| 3a2aecbe48 | |||
| 2708f7e434 | |||
| 378432e376 | |||
| 62b99edb59 | |||
| 4166afa387 | |||
| b15fc47935 | |||
| 5623ff9d13 | |||
| 79ef7e72f5 | |||
| aacf2adbd3 | |||
| bc516a3cc3 | |||
| 66ef3f7697 | |||
| 794dec0d95 | |||
| 3f0d66bbd9 | |||
| 24e5c002ed | |||
| 3317a9d994 | |||
| 53c770c7fc | |||
| 04a6230dd8 | |||
| 5adb520a69 | |||
| 69da1b0e1f | |||
| 4e101cab4d | |||
| a985ccb407 | |||
| 42ea4b155b | |||
| 3ccbff4780 | |||
| 72663deec7 | |||
| b9bf2da0d4 | |||
| 89acac24c5 | |||
| 2ea5e17a51 | |||
| f1c7c52f14 | |||
| ae04c11ae8 | |||
| b5fca0a306 | |||
| 04aa2e190e | |||
| e97e3974d2 | |||
| 6faf08096a | |||
| 23924ce4a4 | |||
| 85807fea9c | |||
| ecac5ce29f | |||
| fbd4cb8321 | |||
| 9e528da256 | |||
| ec3d979391 | |||
| 25ef719be0 | |||
| a37a8f2dbb | |||
| 1de582a2a5 | |||
| 7952c0850a | |||
| 156347d5c2 | |||
| dbc8900270 | |||
| 6162c26963 |
@@ -32,3 +32,7 @@ Carthage
|
||||
# `pod install` in .travis.yml
|
||||
#
|
||||
# Pods/
|
||||
|
||||
# SPM
|
||||
.build/
|
||||
Packages
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
language: objective-c
|
||||
osx_image: xcode7
|
||||
osx_image: xcode7.3
|
||||
|
||||
# cache: cocoapods
|
||||
# podfile: Example/Podfile
|
||||
# before_install:
|
||||
# - gem install cocoapods # Since Travis is not always on latest version
|
||||
# - pod install --project-directory=Example
|
||||
|
||||
install:
|
||||
- gem install xcpretty --no-rdoc --no-ri --no-document --quiet
|
||||
- curl -OlL "https://github.com/Carthage/Carthage/releases/download/0.11/Carthage.pkg" && sudo installer -pkg "Carthage.pkg" -target / && rm "Carthage.pkg"
|
||||
|
||||
script:
|
||||
- set -o pipefail && xcodebuild test -workspace Example/Dip.xcworkspace -scheme DipSampleApp -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' ONLY_ACTIVE_ARCH=NO | xcpretty -c
|
||||
- set -o pipefail && xcodebuild test -workspace Dip.xcworkspace -scheme Dip-iOS -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' ONLY_ACTIVE_ARCH=NO | xcpretty -c
|
||||
- set -o pipefail && xcodebuild test -workspace Dip.xcworkspace -scheme Dip-OSX -sdk macosx -destination 'platform=OS X,arch=x86_64' ONLY_ACTIVE_ARCH=NO | xcpretty -c
|
||||
- set -o pipefail && xcodebuild test -workspace Dip.xcworkspace -scheme Dip-tvOS -sdk appletvsimulator -destination 'platform=tvOS Simulator,name=Apple TV 1080p,OS=latest' ONLY_ACTIVE_ARCH=NO | xcpretty -c
|
||||
- set -o pipefail && xcodebuild -workspace Dip.xcworkspace -scheme Dip-watchOS -sdk watchsimulator -destination 'platform=watchOS Simulator,name=Apple Watch - 38mm,OS=latest' ONLY_ACTIVE_ARCH=NO | xcpretty - c
|
||||
- set -o pipefail && xcodebuild test -workspace Dip.xcworkspace -scheme DipSampleApp -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6,OS=latest' ONLY_ACTIVE_ARCH=NO | xcpretty -c
|
||||
- pod lib lint --quick
|
||||
- carthage build --no-skip-current
|
||||
|
||||
@@ -1,5 +1,130 @@
|
||||
# CHANGELOG
|
||||
|
||||
## 4.4.0
|
||||
|
||||
* Added `.EagerSingleton` scope for objectes requiring early instantiation and `bootstrap()` method on `DepenencyContainer`.
|
||||
[#65](https://github.com/AliSoftware/Dip/pull/65), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Reverted order of `Resolvable` callbacks.
|
||||
[#67](https://github.com/AliSoftware/Dip/pull/67), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
|
||||
## 4.3.1
|
||||
|
||||
* Fix Swift 2.2 compile errors in tests.
|
||||
[#62](https://github.com/AliSoftware/Dip/pull/62), [@mwoollard](https://github.com/mwoollard)
|
||||
|
||||
## 4.3.0
|
||||
|
||||
* Added `DependencyTagConvertible` protocol for better typed tags.
|
||||
[#50](https://github.com/AliSoftware/Dip/pull/50), [@gavrix](https://github.com/gavrix)
|
||||
* Auto-wiring. `DependencyContainer` resolves constructor arguments automatically.
|
||||
[#55](https://github.com/AliSoftware/Dip/pull/55), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Added `Resolvable` protocol to get a callback when dependencies graph is complete.
|
||||
[#57](https://github.com/AliSoftware/Dip/pull/57), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Removed `DipError.ResolutionFailed` error for better consistency.
|
||||
[#58](https://github.com/AliSoftware/Dip/pull/58), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
|
||||
|
||||
## 4.2.0
|
||||
|
||||
* Added support for Swift Package Manager.
|
||||
[#41](https://github.com/AliSoftware/Dip/pull/41), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Added Linux support.
|
||||
[#42](https://github.com/AliSoftware/Dip/pull/42), [#46](https://github.com/AliSoftware/Dip/pull/46), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Fixed the issue that could cause singleton instances to be reused between different containers.
|
||||
[#43](https://github.com/AliSoftware/Dip/pull/43), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Added public `AutoInjectedPropertyBox` protocol for user-defined auto-injected property wrappers.
|
||||
[#49](https://github.com/AliSoftware/Dip/pull/49), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
|
||||
|
||||
## 4.1.0
|
||||
|
||||
#### New features
|
||||
|
||||
* Added auto-injection feature.
|
||||
[#13](https://github.com/AliSoftware/Dip/pull/13), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Factories and `resolveDependencies` blocks of `DefinitionOf` are now allowed to `throw`. Improved errors handling.
|
||||
[#32](https://github.com/AliSoftware/Dip/pull/32), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Thread safety reimplemented with support for recursive methods calls.
|
||||
[#31](https://github.com/AliSoftware/Dip/pull/31), [@mwoollard](https://github.com/mwoollard)
|
||||
|
||||
|
||||
## 4.0.0
|
||||
|
||||
#### New Features
|
||||
|
||||
* Added support for circular dependencies:
|
||||
* Added `ObjectGraph` scope to reuse resolved instances
|
||||
* Added `resolveDependencies` method on `DefinitionOf` class to resolve dependencies of resolved instance.
|
||||
[#11](https://github.com/AliSoftware/Dip/pull/11), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Added methods to register/remove individual definitions.
|
||||
[#11](https://github.com/AliSoftware/Dip/pull/11), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* All `resolve` methods now can throw error if type can not be resolved.
|
||||
[#15](https://github.com/AliSoftware/Dip/issues/15), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* `DependencyContainer` is marked as `final`.
|
||||
* Added support for OSX, tvOS and watchOS2.
|
||||
[#26](https://github.com/AliSoftware/Dip/pull/26), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
|
||||
|
||||
#### Breaking Changes
|
||||
|
||||
* Removed container thread-safety to enable recursion calls to `resolve`.
|
||||
**Access to container from multiple threads should be handled by clients** from now on.
|
||||
* All `resolve` methods now can throw.
|
||||
|
||||
### Note on migration from 3.x to 4.0.0:
|
||||
* Errors
|
||||
|
||||
In 4.0.0 each `resolve` method can throw `DefinitionNotFound(DefinitionKey)` error, so you need to call it using `try!` or `try?`, or catch the error if it's appropriate for your case. See [#15](https://github.com/AliSoftware/Dip/issues/15) for rationale of this change.
|
||||
|
||||
* Thread safety
|
||||
|
||||
In 4.0.0 `DependencyContainer` drops any guarantee of thread safety. From now on code that uses Dip must ensure that it's methods are called from a single thread. For example if you have registered type as a singleton and later two threads try to resolve it at the same time you can have two different instances of type instead of one as expected. This change was required to enable recursive calls of `resolve` method to resolve circular dependencies.
|
||||
|
||||
* Removed methods
|
||||
|
||||
Methods deprecated in 3.1.0 are now removed.
|
||||
|
||||
|
||||
## 3.1.0
|
||||
|
||||
#### New
|
||||
|
||||
* Added name for the first runtime argument in `resolve(tag:withArguments: … )` methods to make more clear separation between tag and factory runtime arguments.
|
||||
|
||||
#### Depreciations
|
||||
|
||||
* `resolve(tag:_: … )` methods are deprecated in favor of those new `resolve(tag:withArguments: … )` methods.
|
||||
* Deprecated `register(tag:instance:)` method in favor of `register(.Singleton) { … }`.
|
||||
|
||||
## 3.0.0
|
||||
|
||||
* Added support for factories with up to six runtime arguments.
|
||||
[#8](https://github.com/AliSoftware/Dip/pull/8), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
* Parameter `tag` is now named in all register/resolve methods.
|
||||
* Playground added to project.
|
||||
[#10](https://github.com/AliSoftware/Dip/pull/10), [@ilyapuchka](https://github.com/ilyapuchka)
|
||||
|
||||
### Note on migration from 2.0.0 to 3.0.0:
|
||||
|
||||
If you used tags to register and resolve your components you have to add `tag` name for tag parameter. Don't forget to add it both in `register` and `resolve` methods. If you forget to add it in `resolve` call then tag value will be treated as first runtime argument for a factory, but there is no such factory registerd, so resolve will fail.
|
||||
|
||||
**Example**:
|
||||
|
||||
This code:
|
||||
|
||||
```swift
|
||||
container.register("some tag") { SomeClass() as SomeProtocol }
|
||||
container.resolve("some tag") as SomeProtocol
|
||||
```
|
||||
|
||||
becomes this:
|
||||
|
||||
```swift
|
||||
container.register(tag: "some tag") { SomeClass() as SomeProtocol }
|
||||
container.resolve(tag: "some tag") as SomeProtocol
|
||||
```
|
||||
|
||||
|
||||
## 2.0.0
|
||||
|
||||
* Moved from generic _tag_ parameter on container to `Tag` enum with `String` and `Int` cases
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Pod::Spec.new do |s|
|
||||
s.name = "Dip"
|
||||
s.version = "2.0.0"
|
||||
s.version = "4.4.0"
|
||||
s.summary = "A simple Dependency Resolver: Dependency Injection using Protocol resolution."
|
||||
|
||||
s.description = <<-DESC
|
||||
@@ -19,12 +19,16 @@ Pod::Spec.new do |s|
|
||||
|
||||
s.homepage = "https://github.com/AliSoftware/Dip"
|
||||
s.license = 'MIT'
|
||||
s.author = { "Olivier Halligon" => "olivier@halligon.net" }
|
||||
s.authors = { "Olivier Halligon" => "olivier@halligon.net", "Ilya Puchka" => "ilya@puchka.me" }
|
||||
s.source = { :git => "https://github.com/AliSoftware/Dip.git", :tag => s.version.to_s }
|
||||
s.social_media_url = 'https://twitter.com/aligatr'
|
||||
|
||||
s.platform = :ios, '8.0'
|
||||
s.ios.deployment_target = '8.0'
|
||||
s.osx.deployment_target = '10.9'
|
||||
s.tvos.deployment_target = '9.0'
|
||||
s.watchos.deployment_target = '2.0'
|
||||
|
||||
s.requires_arc = true
|
||||
|
||||
s.source_files = 'Sources/**/*'
|
||||
s.source_files = 'Sources/**/*.swift'
|
||||
end
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:DipPlayground.playground">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Dip/Dip.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:SampleApp/DipSampleApp.xcodeproj">
|
||||
</FileRef>
|
||||
<Group
|
||||
location = "container:"
|
||||
name = "Podspec Metadata">
|
||||
<FileRef
|
||||
location = "group:Dip.podspec">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:README.md">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:LICENSE">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:CHANGELOG.md">
|
||||
</FileRef>
|
||||
</Group>
|
||||
</Workspace>
|
||||
@@ -1,6 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:../DipPlayground.playground">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "self:">
|
||||
</FileRef>
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0710"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3571C161543002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-OSX"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3601C161543002241C1"
|
||||
BuildableName = "Dip-OSXTests.xctest"
|
||||
BlueprintName = "Dip-OSXTests"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3571C161543002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-OSX"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3571C161543002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-OSX"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3571C161543002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-OSX"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,100 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0710"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3771C1615EC002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-iOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
codeCoverageEnabled = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3801C1615EC002241C1"
|
||||
BuildableName = "Dip-iOSTests.xctest"
|
||||
BlueprintName = "Dip-iOSTests"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3771C1615EC002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-iOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3771C1615EC002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-iOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3771C1615EC002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-iOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0710"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3A51C1618AF002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-tvOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
<TestableReference
|
||||
skipped = "NO">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3AE1C1618AF002241C1"
|
||||
BuildableName = "Dip-tvOSTests.xctest"
|
||||
BlueprintName = "Dip-tvOSTests"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3A51C1618AF002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-tvOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
useCustomWorkingDirectory = "NO"
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3A51C1618AF002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-tvOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B3A51C1618AF002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-tvOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
</AnalyzeAction>
|
||||
<ArchiveAction
|
||||
buildConfiguration = "Release"
|
||||
revealArchiveInOrganizer = "YES">
|
||||
</ArchiveAction>
|
||||
</Scheme>
|
||||
@@ -1,36 +1,39 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Scheme
|
||||
LastUpgradeVersion = "0700"
|
||||
LastUpgradeVersion = "0710"
|
||||
version = "1.3">
|
||||
<BuildAction
|
||||
parallelizeBuildables = "YES"
|
||||
buildImplicitDependencies = "YES">
|
||||
<BuildActionEntries>
|
||||
<BuildActionEntry
|
||||
buildForAnalyzing = "YES"
|
||||
buildForTesting = "YES"
|
||||
buildForRunning = "YES"
|
||||
buildForProfiling = "YES"
|
||||
buildForArchiving = "YES">
|
||||
buildForArchiving = "YES"
|
||||
buildForAnalyzing = "YES">
|
||||
<BuildableReference
|
||||
BuildableIdentifier = 'primary'
|
||||
BlueprintIdentifier = '0CFBD42E9A9E0A9CBD1C8DD7'
|
||||
BlueprintName = 'Dip'
|
||||
ReferencedContainer = 'container:Pods.xcodeproj'
|
||||
BuildableName = 'Dip.framework'>
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B4031C162862002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-watchOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
</BuildAction>
|
||||
<TestAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
buildConfiguration = "Debug">
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
<Testables>
|
||||
</Testables>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
@@ -38,17 +41,34 @@
|
||||
ignoresPersistentStateOnLaunch = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
debugServiceExtension = "internal"
|
||||
buildConfiguration = "Debug"
|
||||
allowLocationSimulation = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B4031C162862002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-watchOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
</AdditionalOptions>
|
||||
</LaunchAction>
|
||||
<ProfileAction
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES"
|
||||
savedToolIdentifier = ""
|
||||
useCustomWorkingDirectory = "NO"
|
||||
debugDocumentVersioning = "YES"
|
||||
buildConfiguration = "Release"
|
||||
shouldUseLaunchSchemeArgsEnv = "YES">
|
||||
debugDocumentVersioning = "YES">
|
||||
<MacroExpansion>
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "0903B4031C162862002241C1"
|
||||
BuildableName = "Dip.framework"
|
||||
BlueprintName = "Dip-watchOS"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
</ProfileAction>
|
||||
<AnalyzeAction
|
||||
buildConfiguration = "Debug">
|
||||
@@ -0,0 +1,35 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
//! Project version number for Dip.
|
||||
FOUNDATION_EXPORT double DipVersionNumber;
|
||||
|
||||
//! Project version string for Dip.
|
||||
FOUNDATION_EXPORT const unsigned char DipVersionString[];
|
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <Dip/PublicHeader.h>
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>$(PRODUCT_NAME)</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -0,0 +1,9 @@
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "DipTests",
|
||||
dependencies: [
|
||||
.Package(url: "../../../Dip", majorVersion: 4, minor: 2),
|
||||
]
|
||||
)
|
||||
|
||||
@@ -0,0 +1,286 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Dip
|
||||
|
||||
private protocol Server: class {
|
||||
weak var client: Client? {get}
|
||||
var anotherClient: Client? {get set}
|
||||
var optionalProperty: AnyObject? {get}
|
||||
}
|
||||
|
||||
private protocol Client: class {
|
||||
var server: Server? {get}
|
||||
var anotherServer: Server? {get set}
|
||||
var optionalProperty: AnyObject? {get}
|
||||
}
|
||||
|
||||
private class ServerImp: Server {
|
||||
|
||||
var _client = InjectedWeak<Client>() { _ in
|
||||
AutoInjectionTests.clientDidInjectCalled = true
|
||||
}
|
||||
var client: Client? {
|
||||
return _client.value
|
||||
}
|
||||
|
||||
weak var anotherClient: Client?
|
||||
|
||||
weak var _optionalProperty = InjectedWeak<AnyObject>(required: false)
|
||||
var optionalProperty: AnyObject? { return _optionalProperty?.value }
|
||||
}
|
||||
|
||||
private class ClientImp: Client {
|
||||
|
||||
var _server = Injected<Server>() { _ in
|
||||
AutoInjectionTests.serverDidInjectCalled = true
|
||||
}
|
||||
var server: Server? {
|
||||
return _server.value
|
||||
}
|
||||
|
||||
var anotherServer: Server?
|
||||
|
||||
var _optionalProperty = Injected<AnyObject>(required: false)
|
||||
var optionalProperty: AnyObject? { return _optionalProperty.value }
|
||||
|
||||
var taggedServer = Injected<Server>(tag: "tagged")
|
||||
}
|
||||
|
||||
private class Obj1 {
|
||||
let obj2 = InjectedWeak<Obj2>()
|
||||
let obj3 = Injected<Obj3>()
|
||||
}
|
||||
|
||||
private class Obj2 {
|
||||
let obj1 = Injected<Obj1>()
|
||||
}
|
||||
|
||||
private class Obj3 {
|
||||
|
||||
weak var obj1: Obj1?
|
||||
|
||||
init(obj: Obj1) {
|
||||
self.obj1 = obj
|
||||
}
|
||||
}
|
||||
|
||||
class AutoInjectionTests: XCTestCase {
|
||||
|
||||
static var serverDidInjectCalled: Bool = false
|
||||
static var clientDidInjectCalled: Bool = false
|
||||
|
||||
let container = DependencyContainer()
|
||||
|
||||
#if os(Linux)
|
||||
var allTests: [(String, () throws -> Void)] {
|
||||
return [
|
||||
("testThatItResolvesAutoInjectedDependencies", testThatItResolvesAutoInjectedDependencies),
|
||||
("testThatItThrowsErrorIfFailsToAutoInjectDependency", testThatItThrowsErrorIfFailsToAutoInjectDependency),
|
||||
("testThatItResolvesAutoInjectedSingletons", testThatItResolvesAutoInjectedSingletons),
|
||||
("testThatItCallsResolveDependencyBlockWhenAutoInjecting", testThatItCallsResolveDependencyBlockWhenAutoInjecting),
|
||||
("testThatItReusesResolvedAutoInjectedInstances", testThatItReusesResolvedAutoInjectedInstances),
|
||||
("testThatItReusesAutoInjectedInstancesOnNextResolveOrAutoInjection", testThatItReusesAutoInjectedInstancesOnNextResolveOrAutoInjection),
|
||||
("testThatThereIsNoRetainCycleBetweenAutoInjectedCircularDependencies", testThatThereIsNoRetainCycleBetweenAutoInjectedCircularDependencies),
|
||||
("testThatItCallsDidInjectOnAutoInjectedProperty", testThatItCallsDidInjectOnAutoInjectedProperty),
|
||||
("testThatNoErrorThrownWhenOptionalPropertiesAreNotAutoInjected", testThatNoErrorThrownWhenOptionalPropertiesAreNotAutoInjected),
|
||||
("testThatItResolvesTaggedAutoInjectedProperties", testThatItResolvesTaggedAutoInjectedProperties)
|
||||
]
|
||||
}
|
||||
|
||||
func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#else
|
||||
override func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#endif
|
||||
|
||||
func testThatItResolvesAutoInjectedDependencies() {
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
|
||||
let client = try! container.resolve() as Client
|
||||
let server = client.server
|
||||
XCTAssertTrue(client === server?.client)
|
||||
}
|
||||
|
||||
func testThatItThrowsErrorIfFailsToAutoInjectDependency() {
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
|
||||
AssertThrows(expression: try container.resolve() as Client)
|
||||
}
|
||||
|
||||
func testThatItResolvesAutoInjectedSingletons() {
|
||||
//given
|
||||
container.register(.Singleton) { ServerImp() as Server }
|
||||
container.register(.Singleton) { ClientImp() as Client }
|
||||
|
||||
//when
|
||||
let sharedClient = try! container.resolve() as Client
|
||||
let sharedServer = try! container.resolve() as Server
|
||||
|
||||
let client = try! container.resolve() as Client
|
||||
let server = client.server
|
||||
|
||||
//then
|
||||
XCTAssertTrue(client === sharedClient)
|
||||
XCTAssertTrue(client === server?.client)
|
||||
XCTAssertTrue(server === sharedServer)
|
||||
}
|
||||
|
||||
func testThatItCallsResolveDependencyBlockWhenAutoInjecting() {
|
||||
var serverBlockWasCalled = false
|
||||
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
.resolveDependencies { (container, server) -> () in
|
||||
serverBlockWasCalled = true
|
||||
}
|
||||
|
||||
var clientBlockWasCalled = false
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
.resolveDependencies { (container, client) -> () in
|
||||
clientBlockWasCalled = true
|
||||
}
|
||||
|
||||
//when
|
||||
try! container.resolve() as Client
|
||||
XCTAssertTrue(serverBlockWasCalled)
|
||||
|
||||
try! container.resolve() as Server
|
||||
XCTAssertTrue(clientBlockWasCalled)
|
||||
}
|
||||
|
||||
func testThatItReusesResolvedAutoInjectedInstances() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
.resolveDependencies { (container, server) -> () in
|
||||
server.anotherClient = try! container.resolve() as Client
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
.resolveDependencies { (container, client) -> () in
|
||||
client.anotherServer = try! container.resolve() as Server
|
||||
}
|
||||
|
||||
//when
|
||||
let client = try! container.resolve() as Client
|
||||
|
||||
//then
|
||||
let server = client.server
|
||||
let anotherServer = client.anotherServer
|
||||
|
||||
XCTAssertTrue(server === anotherServer)
|
||||
|
||||
let oneClient = server!.client
|
||||
let anotherClient = server!.anotherClient
|
||||
|
||||
XCTAssertTrue(oneClient === anotherClient)
|
||||
XCTAssertTrue(client === anotherClient)
|
||||
}
|
||||
|
||||
func testThatItReusesAutoInjectedInstancesOnNextResolveOrAutoInjection() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { Obj1() }
|
||||
container.register(.ObjectGraph) { Obj2() }
|
||||
container.register(.ObjectGraph) { Obj3(obj: try self.container.resolve()) }
|
||||
|
||||
//when
|
||||
let obj2 = try! container.resolve() as Obj2
|
||||
|
||||
//then
|
||||
XCTAssertTrue(obj2 === obj2.obj1.value!.obj2.value!,
|
||||
"Auto-injected instance should be reused on next auto-injection")
|
||||
|
||||
XCTAssertTrue(obj2.obj1.value! === obj2.obj1.value!.obj3.value!.obj1,
|
||||
"Auto-injected instance should be reused on next resolve")
|
||||
}
|
||||
|
||||
func testThatThereIsNoRetainCycleBetweenAutoInjectedCircularDependencies() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
|
||||
//when
|
||||
var client: Client? = try! container.resolve() as Client
|
||||
|
||||
//then
|
||||
weak var weakServer: Server? = client?.server
|
||||
weak var weakClient = client
|
||||
|
||||
XCTAssertNotNil(weakClient)
|
||||
XCTAssertNotNil(weakServer)
|
||||
|
||||
client = nil
|
||||
|
||||
XCTAssertNil(weakClient)
|
||||
XCTAssertNil(weakServer)
|
||||
}
|
||||
|
||||
func testThatItCallsDidInjectOnAutoInjectedProperty() {
|
||||
AutoInjectionTests.clientDidInjectCalled = false
|
||||
AutoInjectionTests.serverDidInjectCalled = false
|
||||
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
|
||||
//when
|
||||
try! container.resolve() as Client
|
||||
|
||||
//then
|
||||
XCTAssertTrue(AutoInjectionTests.clientDidInjectCalled)
|
||||
XCTAssertTrue(AutoInjectionTests.serverDidInjectCalled)
|
||||
}
|
||||
|
||||
func testThatNoErrorThrownWhenOptionalPropertiesAreNotAutoInjected() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
|
||||
AssertNoThrow(expression: try container.resolve() as Client, "Container should not throw error if failed to resolve optional auto-injected properties.")
|
||||
}
|
||||
|
||||
func testThatItResolvesTaggedAutoInjectedProperties() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
container.register(tag: "tagged", .ObjectGraph) { ServerImp() as Server }
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
|
||||
//when
|
||||
let client = try! container.resolve() as Client
|
||||
|
||||
//then
|
||||
let taggedServer = (client as! ClientImp).taggedServer.value!
|
||||
let server = client.server!
|
||||
|
||||
//server and tagged server should be resolved as different instances
|
||||
XCTAssertTrue(server !== taggedServer)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,299 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Dip
|
||||
|
||||
private protocol Service: class { }
|
||||
private class ServiceImp1: Service { }
|
||||
private class ServiceImp2: Service { }
|
||||
|
||||
private protocol AutoWiredClient: class {
|
||||
var service1: Service! { get set }
|
||||
var service2: Service! { get set }
|
||||
}
|
||||
|
||||
private class AutoWiredClientImp: AutoWiredClient {
|
||||
var service1: Service!
|
||||
var service2: Service!
|
||||
|
||||
init(service1: Service, service2: ServiceImp2) {
|
||||
self.service1 = service1
|
||||
self.service2 = service2
|
||||
}
|
||||
init() {}
|
||||
}
|
||||
|
||||
class AutoWiringTests: XCTestCase {
|
||||
|
||||
let container = DependencyContainer()
|
||||
|
||||
#if os(Linux)
|
||||
var allTests: [(String, () throws -> Void)] {
|
||||
return [
|
||||
("testThatItCanResolveWithAutoWiring", testThatItCanResolveWithAutoWiring),
|
||||
("testThatItUsesAutoWireFactoryWithMostNumberOfArguments", testThatItUsesAutoWireFactoryWithMostNumberOfArguments),
|
||||
("testThatItThrowsAmbiguityErrorWhenUsingAutoWire", testThatItThrowsAmbiguityErrorWhenUsingAutoWire),
|
||||
("testThatItFirstTriesToUseTaggedFactoriesWhenUsingAutoWire", testThatItFirstTriesToUseTaggedFactoriesWhenUsingAutoWire),
|
||||
("testThatItFallbackToNotTaggedFactoryWhenUsingAutoWire", testThatItFallbackToNotTaggedFactoryWhenUsingAutoWire),
|
||||
("testThatItDoesNotTryToUseAutoWiringWhenCallingResolveWithArguments", testThatItDoesNotTryToUseAutoWiringWhenCallingResolveWithArguments),
|
||||
("testThatItDoesNotUseAutoWiringWhenFailedToResolveLowLevelDependency", testThatItDoesNotUseAutoWiringWhenFailedToResolveLowLevelDependency),
|
||||
("testThatItReusesInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgain", testThatItReusesInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgain),
|
||||
("testThatItReusesInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgainWithTheSameTagged", testThatItReusesInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgainWithTheSameTagged),
|
||||
("testThatItDoesNotReuseInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgainWithNoTag", testThatItDoesNotReuseInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgainWithNoTag)
|
||||
]
|
||||
}
|
||||
|
||||
func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#else
|
||||
override func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#endif
|
||||
|
||||
func testThatItCanResolveWithAutoWiring() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }
|
||||
|
||||
//when
|
||||
let client = try! container.resolve() as AutoWiredClient
|
||||
|
||||
//then
|
||||
let service1 = client.service1
|
||||
XCTAssertTrue(service1 is ServiceImp1)
|
||||
let service2 = client.service2
|
||||
XCTAssertTrue(service2 is ServiceImp2)
|
||||
}
|
||||
|
||||
func testThatItUsesAutoWireFactoryWithMostNumberOfArguments() {
|
||||
//given
|
||||
|
||||
//1 arg
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: try self.container.resolve()) as AutoWiredClient }
|
||||
//1 arg
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: try self.container.resolve(), service2: $0) as AutoWiredClient }
|
||||
|
||||
//2 args
|
||||
var factoryWithMostNumberOfArgumentsCalled = false
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }
|
||||
.resolveDependencies { _ in
|
||||
factoryWithMostNumberOfArgumentsCalled = true
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
//when
|
||||
let _ = try! container.resolve() as AutoWiredClient
|
||||
|
||||
//then
|
||||
XCTAssertTrue(factoryWithMostNumberOfArgumentsCalled)
|
||||
}
|
||||
|
||||
func testThatItThrowsAmbiguityErrorWhenUsingAutoWire() {
|
||||
//given
|
||||
|
||||
//1 arg
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: try self.container.resolve()) as AutoWiredClient }
|
||||
//1 arg
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: try self.container.resolve(), service2: $0) as AutoWiredClient }
|
||||
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
//when
|
||||
AssertThrows(expression: try container.resolve() as AutoWiredClient) { error -> Bool in
|
||||
switch error {
|
||||
case DipError.AmbiguousDefinitions: return true
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testThatItFirstTriesToUseTaggedFactoriesWhenUsingAutoWire() {
|
||||
//given
|
||||
|
||||
//1 arg
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: try self.container.resolve()) as AutoWiredClient }
|
||||
//1 arg
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: try self.container.resolve(), service2: $0) as AutoWiredClient }
|
||||
|
||||
//2 args
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }
|
||||
|
||||
//1 arg tagged
|
||||
var taggedFactoryWithMostNumberOfArgumentsCalled = false
|
||||
container.register(tag: "tag", .ObjectGraph) { AutoWiredClientImp(service1: $0, service2: try self.container.resolve()) as AutoWiredClient }
|
||||
|
||||
//2 arg tagged
|
||||
container.register(tag: "tag", .ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }.resolveDependencies { _ in
|
||||
taggedFactoryWithMostNumberOfArgumentsCalled = true
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
//when
|
||||
let _ = try! container.resolve(tag: "tag") as AutoWiredClient
|
||||
|
||||
//then
|
||||
XCTAssertTrue(taggedFactoryWithMostNumberOfArgumentsCalled)
|
||||
}
|
||||
|
||||
func testThatItFallbackToNotTaggedFactoryWhenUsingAutoWire() {
|
||||
//given
|
||||
|
||||
//1 arg
|
||||
var notTaggedFactoryWithMostNumberOfArgumentsCalled = false
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: try self.container.resolve()) as AutoWiredClient }.resolveDependencies {_ in
|
||||
notTaggedFactoryWithMostNumberOfArgumentsCalled = true
|
||||
}
|
||||
|
||||
//1 arg tagged
|
||||
container.register(tag: "tag", .ObjectGraph) { AutoWiredClientImp(service1: $0, service2: try self.container.resolve()) as AutoWiredClient }
|
||||
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
//when
|
||||
let _ = try! container.resolve(tag: "other tag") as AutoWiredClient
|
||||
|
||||
//then
|
||||
XCTAssertTrue(notTaggedFactoryWithMostNumberOfArgumentsCalled)
|
||||
}
|
||||
|
||||
func testThatItDoesNotTryToUseAutoWiringWhenCallingResolveWithArguments() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
//when
|
||||
let service = try! container.resolve() as Service
|
||||
AssertThrows(expression: try container.resolve(withArguments: service) as AutoWiredClient,
|
||||
"Container should not use auto-wiring when resolving with runtime arguments")
|
||||
}
|
||||
|
||||
func testThatItDoesNotUseAutoWiringWhenFailedToResolveLowLevelDependency() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp() as AutoWiredClient }
|
||||
.resolveDependencies { container, resolved in
|
||||
resolved.service1 = try container.resolve() as Service
|
||||
resolved.service2 = try container.resolve() as ServiceImp2
|
||||
|
||||
//simulate that something goes wrong on the way
|
||||
throw DipError.DefinitionNotFound(key: DefinitionKey(protocolType: ServiceImp1.self, factoryType: Any.self))
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }
|
||||
.resolveDependencies { container, resolved in
|
||||
//auto-wiring should be performed only when definition for type to resolve is not found
|
||||
//but not for any other type along the way in the graph
|
||||
XCTFail("Auto-wiring should not be performed if instance was actually resolved.")
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
//then
|
||||
AssertThrows(expression: try container.resolve() as AutoWiredClient,
|
||||
"Container should not use auto-wiring when definition for resolved type is registered.")
|
||||
}
|
||||
|
||||
func testThatItReusesInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgain() {
|
||||
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
var anotherInstance: AutoWiredClient?
|
||||
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }
|
||||
.resolveDependencies { container, _ in
|
||||
if anotherInstance == nil {
|
||||
anotherInstance = try! container.resolve() as AutoWiredClient
|
||||
}
|
||||
}
|
||||
|
||||
//when
|
||||
let resolved = try! container.resolve() as AutoWiredClient
|
||||
|
||||
//then
|
||||
//when doing another auto-wiring during resolve we should reuse instance
|
||||
XCTAssertTrue((resolved as! AutoWiredClientImp) === (anotherInstance as! AutoWiredClientImp))
|
||||
}
|
||||
|
||||
func testThatItReusesInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgainWithTheSameTagged() {
|
||||
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
var anotherInstance: AutoWiredClient?
|
||||
|
||||
container.register(tag: "tag", .ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }
|
||||
.resolveDependencies { container, _ in
|
||||
if anotherInstance == nil {
|
||||
anotherInstance = try! container.resolve(tag: "tag") as AutoWiredClient
|
||||
}
|
||||
}
|
||||
|
||||
//when
|
||||
let resolved = try! container.resolve(tag: "tag") as AutoWiredClient
|
||||
|
||||
//then
|
||||
//when doing another auto-wiring during resolve we should reuse instance
|
||||
XCTAssertTrue((resolved as! AutoWiredClientImp) === (anotherInstance as! AutoWiredClientImp))
|
||||
}
|
||||
|
||||
func testThatItDoesNotReuseInstancesResolvedWithAutoWiringWhenUsingAutoWiringAgainWithNoTag() {
|
||||
|
||||
//given
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
container.register(.ObjectGraph) { ServiceImp2() }
|
||||
|
||||
var anotherInstance: AutoWiredClient?
|
||||
|
||||
container.register(.ObjectGraph) { AutoWiredClientImp(service1: $0, service2: $1) as AutoWiredClient }
|
||||
.resolveDependencies { container, _ in
|
||||
if anotherInstance == nil {
|
||||
anotherInstance = try! container.resolve() as AutoWiredClient
|
||||
}
|
||||
}
|
||||
|
||||
//when
|
||||
let resolved = try! container.resolve(tag: "tag") as AutoWiredClient
|
||||
|
||||
//then
|
||||
//when doing another auto-wiring during resolve we should reuse instance
|
||||
XCTAssertTrue((resolved as! AutoWiredClientImp) !== (anotherInstance as! AutoWiredClientImp))
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,279 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Dip
|
||||
|
||||
private protocol Service: class {}
|
||||
private class ServiceImp1: Service {}
|
||||
private class ServiceImp2: Service {}
|
||||
|
||||
private class Server {
|
||||
weak var client: Client?
|
||||
|
||||
init() {}
|
||||
}
|
||||
|
||||
private class Client {
|
||||
var server: Server
|
||||
|
||||
init(server: Server) {
|
||||
self.server = server
|
||||
}
|
||||
}
|
||||
|
||||
class ComponentScopeTests: XCTestCase {
|
||||
|
||||
let container = DependencyContainer()
|
||||
|
||||
#if os(Linux)
|
||||
var allTests: [(String, () throws -> Void)] {
|
||||
return [
|
||||
("testThatPrototypeIsDefaultScope", testThatPrototypeIsDefaultScope),
|
||||
("testThatScopeCanBeChanged", testThatScopeCanBeChanged),
|
||||
("testThatItResolvesTypeAsNewInstanceForPrototypeScope", testThatItResolvesTypeAsNewInstanceForPrototypeScope),
|
||||
("testThatItReusesInstanceForSingletonScope", testThatItReusesInstanceForSingletonScope),
|
||||
("testThatSingletonIsNotReusedAcrossContainers", testThatSingletonIsNotReusedAcrossContainers),
|
||||
("testThatSingletonIsReleasedWhenDefinitionIsRemoved", testThatSingletonIsReleasedWhenDefinitionIsRemoved),
|
||||
("testThatSingletonIsReleasedWhenDefinitionIsOverridden", testThatSingletonIsReleasedWhenDefinitionIsOverridden),
|
||||
("testThatSingletonIsReleasedWhenContainerIsReset", testThatSingletonIsReleasedWhenContainerIsReset),
|
||||
("testThatItReusesInstanceInObjectGraphScopeDuringResolve", testThatItReusesInstanceInObjectGraphScopeDuringResolve),
|
||||
("testThatItDoesNotReuseInstanceInObjectGraphScopeInNextResolve", testThatItDoesNotReuseInstanceInObjectGraphScopeInNextResolve),
|
||||
("testThatItDoesNotReuseInstanceInObjectGraphScopeResolvedForNilTag", testThatItDoesNotReuseInstanceInObjectGraphScopeResolvedForNilTag)
|
||||
]
|
||||
}
|
||||
|
||||
func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#else
|
||||
override func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#endif
|
||||
|
||||
func testThatPrototypeIsDefaultScope() {
|
||||
let def = container.register { ServiceImp1() as Service }
|
||||
XCTAssertEqual(def.scope, ComponentScope.Prototype)
|
||||
}
|
||||
|
||||
func testThatScopeCanBeChanged() {
|
||||
let def = container.register(.Singleton) { ServiceImp1() as Service }
|
||||
XCTAssertEqual(def.scope, ComponentScope.Singleton)
|
||||
}
|
||||
|
||||
func testThatItResolvesTypeAsNewInstanceForPrototypeScope() {
|
||||
//given
|
||||
container.register { ServiceImp1() as Service }
|
||||
|
||||
//when
|
||||
let service1 = try! container.resolve() as Service
|
||||
let service2 = try! container.resolve() as Service
|
||||
|
||||
//then
|
||||
XCTAssertFalse(service1 === service2)
|
||||
}
|
||||
|
||||
func testThatItReusesInstanceForSingletonScope() {
|
||||
func test(scope: ComponentScope) {
|
||||
//given
|
||||
container.register(scope) { ServiceImp1() as Service }
|
||||
|
||||
//when
|
||||
let service1 = try! container.resolve() as Service
|
||||
let service2 = try! container.resolve() as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1 === service2)
|
||||
}
|
||||
|
||||
test(.Singleton)
|
||||
test(.EagerSingleton)
|
||||
}
|
||||
|
||||
func testThatSingletonIsNotReusedAcrossContainers() {
|
||||
func test(scope: ComponentScope) {
|
||||
//given
|
||||
let def = container.register(.Singleton) { ServiceImp1() as Service }
|
||||
let secondContainer = DependencyContainer()
|
||||
secondContainer.register(def, forTag: nil)
|
||||
|
||||
//when
|
||||
let service1 = try! container.resolve() as Service
|
||||
let service2 = try! secondContainer.resolve() as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1 !== service2, "Singleton instances should not be reused across containers")
|
||||
}
|
||||
|
||||
test(.Singleton)
|
||||
test(.EagerSingleton)
|
||||
}
|
||||
|
||||
func testThatSingletonIsReleasedWhenDefinitionIsRemoved() {
|
||||
func test(scope: ComponentScope) {
|
||||
//given
|
||||
let def = container.register(.Singleton) { ServiceImp1() as Service }
|
||||
let service1 = try! container.resolve() as Service
|
||||
|
||||
//when
|
||||
container.remove(def, forTag: nil)
|
||||
container.register(def, forTag: nil)
|
||||
|
||||
//then
|
||||
let service2 = try! container.resolve() as Service
|
||||
XCTAssertTrue(service1 !== service2, "Singleton instances should be released when definition is removed from the container")
|
||||
}
|
||||
|
||||
test(.Singleton)
|
||||
test(.EagerSingleton)
|
||||
}
|
||||
|
||||
func testThatSingletonIsReleasedWhenDefinitionIsOverridden() {
|
||||
func test(scope: ComponentScope) {
|
||||
//given
|
||||
let def = container.register(.Singleton) { ServiceImp1() as Service }
|
||||
let service1 = try! container.resolve() as Service
|
||||
|
||||
//when
|
||||
container.register(def, forTag: nil)
|
||||
|
||||
//then
|
||||
let service2 = try! container.resolve() as Service
|
||||
XCTAssertTrue(service1 !== service2, "Singleton instances should be released when definition is overridden")
|
||||
}
|
||||
|
||||
test(.Singleton)
|
||||
test(.EagerSingleton)
|
||||
}
|
||||
|
||||
func testThatSingletonIsReleasedWhenContainerIsReset() {
|
||||
func test(scope: ComponentScope) {
|
||||
//given
|
||||
let def = container.register(.Singleton) { ServiceImp1() as Service }
|
||||
let service1 = try! container.resolve() as Service
|
||||
|
||||
//when
|
||||
container.reset()
|
||||
container.register(def, forTag: nil)
|
||||
|
||||
//then
|
||||
let service2 = try! container.resolve() as Service
|
||||
XCTAssertTrue(service1 !== service2, "Singleton instances should be released when container is reset")
|
||||
}
|
||||
|
||||
test(.Singleton)
|
||||
test(.EagerSingleton)
|
||||
}
|
||||
|
||||
func testThatItReusesInstanceInObjectGraphScopeDuringResolve() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { Client(server: try self.container.resolve()) as Client }
|
||||
|
||||
container.register(.ObjectGraph) { Server() as Server }
|
||||
.resolveDependencies { container, server in
|
||||
server.client = try container.resolve() as Client
|
||||
}
|
||||
|
||||
//when
|
||||
let client = try! container.resolve() as Client
|
||||
|
||||
//then
|
||||
let server = client.server
|
||||
XCTAssertTrue(server.client === client)
|
||||
}
|
||||
|
||||
func testThatItDoesNotReuseInstanceInObjectGraphScopeInNextResolve() {
|
||||
//given
|
||||
container.register(.ObjectGraph) { Client(server: try self.container.resolve()) as Client }
|
||||
container.register(.ObjectGraph) { Server() as Server }
|
||||
.resolveDependencies { container, server in
|
||||
server.client = try container.resolve() as Client
|
||||
}
|
||||
|
||||
//when
|
||||
let client = try! container.resolve() as Client
|
||||
let server = client.server
|
||||
|
||||
let anotherClient = try! container.resolve() as Client
|
||||
let anotherServer = anotherClient.server
|
||||
|
||||
//then
|
||||
XCTAssertFalse(server === anotherServer)
|
||||
XCTAssertFalse(client === anotherClient)
|
||||
}
|
||||
|
||||
func testThatItDoesNotReuseInstanceInObjectGraphScopeResolvedForNilTag() {
|
||||
//given
|
||||
var service2: Service?
|
||||
container.register(.ObjectGraph) { ServiceImp1() as Service }
|
||||
.resolveDependencies { (c, _) in
|
||||
service2 = try c.resolve(tag: "service") as Service
|
||||
|
||||
//then
|
||||
|
||||
//when service1 is resolved using this definition due to fallback to nil tag
|
||||
//we don't want every next resolve of service reuse it
|
||||
XCTAssertTrue(service2 is ServiceImp2)
|
||||
}
|
||||
container.register(tag: "service", .ObjectGraph) { ServiceImp2() as Service}
|
||||
|
||||
//when
|
||||
let service1 = try! container.resolve(tag: "tag") as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1 is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatOnlyEagerSingletonIsCreatedWhenContainerIsBootsrapped() {
|
||||
//given
|
||||
var eagerSingletonResolved = false
|
||||
|
||||
container.register(tag: "eager", .EagerSingleton) { ServiceImp1() as Service }
|
||||
.resolveDependencies { container, service in eagerSingletonResolved = true }
|
||||
|
||||
container.register(tag: "singleton", .Singleton) { ServiceImp1() as Service }
|
||||
.resolveDependencies { container, service in XCTFail() }
|
||||
|
||||
container.register(tag: "prototype", .Prototype) { ServiceImp1() as Service }
|
||||
.resolveDependencies { container, service in XCTFail() }
|
||||
|
||||
container.register(tag: "graph", .ObjectGraph) { ServiceImp1() as Service }
|
||||
.resolveDependencies { container, service in XCTFail() }
|
||||
|
||||
//when
|
||||
try! container.bootstrap()
|
||||
XCTAssertTrue(eagerSingletonResolved)
|
||||
}
|
||||
|
||||
func testThatContainerCanBeBootstrappedAgainAfterReset() {
|
||||
try! container.bootstrap()
|
||||
XCTAssertTrue(container.bootstrapped)
|
||||
|
||||
container.reset()
|
||||
XCTAssertFalse(container.bootstrapped)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Dip
|
||||
|
||||
private protocol Service {}
|
||||
private class ServiceImp: Service {}
|
||||
|
||||
class DefinitionTests: XCTestCase {
|
||||
|
||||
private typealias F1 = () -> Service
|
||||
private typealias F2 = (String) -> Service
|
||||
|
||||
let tag1 = DependencyContainer.Tag.String("tag1")
|
||||
let tag2 = DependencyContainer.Tag.String("tag2")
|
||||
|
||||
#if os(Linux)
|
||||
var allTests: [(String, () throws -> Void)] {
|
||||
return [
|
||||
("testThatDefinitionKeyIsEqualBy_Type_Factory_Tag", testThatDefinitionKeyIsEqualBy_Type_Factory_Tag),
|
||||
("testThatDefinitionKeysWithDifferentTypesAreNotEqual", testThatDefinitionKeysWithDifferentTypesAreNotEqual),
|
||||
("testThatDefinitionKeysWithDifferentFactoriesAreNotEqual", testThatDefinitionKeysWithDifferentFactoriesAreNotEqual),
|
||||
("testThatDefinitionKeysWithDifferentTagsAreNotEqual", testThatDefinitionKeysWithDifferentTagsAreNotEqual),
|
||||
("testThatResolveDependenciesCallsResolveDependenciesBlock", testThatResolveDependenciesCallsResolveDependenciesBlock),
|
||||
("testThatResolveDependenciesBlockIsNotCalledWhenPassedWrongInstance", testThatResolveDependenciesBlockIsNotCalledWhenPassedWrongInstance)
|
||||
]
|
||||
}
|
||||
#endif
|
||||
|
||||
func testThatDefinitionKeyIsEqualBy_Type_Factory_Tag() {
|
||||
let equalKey1 = DefinitionKey(protocolType: Service.self, factoryType: F1.self, associatedTag: tag1)
|
||||
let equalKey2 = DefinitionKey(protocolType: Service.self, factoryType: F1.self, associatedTag: tag1)
|
||||
|
||||
XCTAssertEqual(equalKey1, equalKey2)
|
||||
XCTAssertEqual(equalKey1.hashValue, equalKey2.hashValue)
|
||||
}
|
||||
|
||||
func testThatDefinitionKeysWithDifferentTypesAreNotEqual() {
|
||||
let keyWithDifferentType1 = DefinitionKey(protocolType: Service.self, factoryType: F1.self, associatedTag: nil)
|
||||
let keyWithDifferentType2 = DefinitionKey(protocolType: AnyObject.self, factoryType: F1.self, associatedTag: nil)
|
||||
|
||||
XCTAssertNotEqual(keyWithDifferentType1, keyWithDifferentType2)
|
||||
XCTAssertNotEqual(keyWithDifferentType1.hashValue, keyWithDifferentType2.hashValue)
|
||||
}
|
||||
|
||||
func testThatDefinitionKeysWithDifferentFactoriesAreNotEqual() {
|
||||
let keyWithDifferentFactory1 = DefinitionKey(protocolType: Service.self, factoryType: F1.self, associatedTag: nil)
|
||||
let keyWithDifferentFactory2 = DefinitionKey(protocolType: Service.self, factoryType: F2.self, associatedTag: nil)
|
||||
|
||||
XCTAssertNotEqual(keyWithDifferentFactory1, keyWithDifferentFactory2)
|
||||
XCTAssertNotEqual(keyWithDifferentFactory1.hashValue, keyWithDifferentFactory2.hashValue)
|
||||
}
|
||||
|
||||
func testThatDefinitionKeysWithDifferentTagsAreNotEqual() {
|
||||
let keyWithDifferentTag1 = DefinitionKey(protocolType: Service.self, factoryType: F1.self, associatedTag: tag1)
|
||||
let keyWithDifferentTag2 = DefinitionKey(protocolType: Service.self, factoryType: F1.self, associatedTag: tag2)
|
||||
|
||||
XCTAssertNotEqual(keyWithDifferentTag1, keyWithDifferentTag2)
|
||||
XCTAssertNotEqual(keyWithDifferentTag1.hashValue, keyWithDifferentTag2.hashValue)
|
||||
}
|
||||
|
||||
func testThatResolveDependenciesCallsResolveDependenciesBlock() {
|
||||
var blockCalled = false
|
||||
|
||||
//given
|
||||
let def = DefinitionOf<Service, () -> Service>(scope: .Prototype) { ServiceImp() as Service }.resolveDependencies { container, service in
|
||||
blockCalled = true
|
||||
}
|
||||
|
||||
//when
|
||||
try! def.resolveDependenciesOf(ServiceImp(), withContainer: DependencyContainer())
|
||||
|
||||
//then
|
||||
XCTAssertTrue(blockCalled)
|
||||
}
|
||||
|
||||
func testThatResolveDependenciesBlockIsNotCalledWhenPassedWrongInstance() {
|
||||
var blockCalled = false
|
||||
|
||||
//given
|
||||
let def = DefinitionOf<Service, () -> Service>(scope: .Prototype) { ServiceImp() as Service }.resolveDependencies { container, service in
|
||||
blockCalled = true
|
||||
}
|
||||
|
||||
//when
|
||||
try! def.resolveDependenciesOf(String(), withContainer: DependencyContainer())
|
||||
|
||||
//then
|
||||
XCTAssertFalse(blockCalled)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,361 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Dip
|
||||
|
||||
private protocol Service: class { }
|
||||
private class ServiceImp1: Service { }
|
||||
private class ServiceImp2: Service { }
|
||||
|
||||
private protocol Server: class {
|
||||
weak var client: Client? { get }
|
||||
}
|
||||
private protocol Client: class {
|
||||
var server: Server? { get }
|
||||
}
|
||||
|
||||
class DipTests: XCTestCase {
|
||||
|
||||
let container = DependencyContainer()
|
||||
|
||||
#if os(Linux)
|
||||
var allTests: [(String, () throws -> Void)] {
|
||||
return [
|
||||
("testThatItResolvesInstanceRegisteredWithoutTag", testThatItResolvesInstanceRegisteredWithoutTag),
|
||||
("testThatItResolvesInstanceRegisteredWithTag", testThatItResolvesInstanceRegisteredWithTag),
|
||||
("testThatItResolvesDifferentInstancesRegisteredForDifferentTags", testThatItResolvesDifferentInstancesRegisteredForDifferentTags),
|
||||
("testThatNewRegistrationOverridesPreviousRegistration", testThatNewRegistrationOverridesPreviousRegistration),
|
||||
("testThatItCallsResolveDependenciesOnDefinition", testThatItCallsResolveDependenciesOnDefinition),
|
||||
("testThatItThrowsErrorIfCanNotFindDefinitionForType", testThatItThrowsErrorIfCanNotFindDefinitionForType),
|
||||
("testThatItThrowsErrorIfCanNotFindDefinitionForTag", testThatItThrowsErrorIfCanNotFindDefinitionForTag),
|
||||
("testThatItThrowsErrorIfCanNotFindDefinitionForFactoryWithArguments", testThatItThrowsErrorIfCanNotFindDefinitionForFactoryWithArguments),
|
||||
("testThatItThrowsErrorIfConstructorThrows", testThatItThrowsErrorIfConstructorThrows),
|
||||
("testThatItThrowsErrorIfFailsToResolveDependency", testThatItThrowsErrorIfFailsToResolveDependency),
|
||||
("testThatItCallsDidResolveDependenciesOnResolvableIntance", testThatItCallsDidResolveDependenciesOnResolvableIntance),
|
||||
("testThatItCallsDidResolveDependenciesInReverseOrder", testThatItCallsDidResolveDependenciesInReverseOrder),
|
||||
("testThatItResolvesCircularDependencies", testThatItResolvesCircularDependencies)
|
||||
]
|
||||
}
|
||||
|
||||
func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#else
|
||||
override func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#endif
|
||||
|
||||
func testThatItResolvesInstanceRegisteredWithoutTag() {
|
||||
//given
|
||||
container.register { ServiceImp1() as Service }
|
||||
|
||||
//when
|
||||
let serviceInstance = try! container.resolve() as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(serviceInstance is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatItResolvesInstanceRegisteredWithTag() {
|
||||
//given
|
||||
container.register(tag: "service") { ServiceImp1() as Service }
|
||||
|
||||
//when
|
||||
let serviceInstance = try! container.resolve(tag: "service") as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(serviceInstance is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatItResolvesDifferentInstancesRegisteredForDifferentTags() {
|
||||
//given
|
||||
container.register(tag: "service1") { ServiceImp1() as Service }
|
||||
container.register(tag: "service2") { ServiceImp2() as Service }
|
||||
|
||||
//when
|
||||
let service1Instance = try! container.resolve(tag: "service1") as Service
|
||||
let service2Instance = try! container.resolve(tag: "service2") as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1Instance is ServiceImp1)
|
||||
XCTAssertTrue(service2Instance is ServiceImp2)
|
||||
}
|
||||
|
||||
func testThatNewRegistrationOverridesPreviousRegistration() {
|
||||
//given
|
||||
container.register { ServiceImp1() as Service }
|
||||
let service1 = try! container.resolve() as Service
|
||||
|
||||
//when
|
||||
container.register { ServiceImp2() as Service }
|
||||
let service2 = try! container.resolve() as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1 is ServiceImp1)
|
||||
XCTAssertTrue(service2 is ServiceImp2)
|
||||
}
|
||||
|
||||
func testThatItCallsResolveDependenciesOnDefinition() {
|
||||
//given
|
||||
var resolveDependenciesCalled = false
|
||||
container.register { ServiceImp1() as Service }.resolveDependencies { (c, s) in
|
||||
resolveDependenciesCalled = true
|
||||
}
|
||||
|
||||
//when
|
||||
try! container.resolve() as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(resolveDependenciesCalled)
|
||||
}
|
||||
|
||||
func testThatItThrowsErrorIfCanNotFindDefinitionForType() {
|
||||
//given
|
||||
container.register { ServiceImp1() as ServiceImp1 }
|
||||
|
||||
//when
|
||||
AssertThrows(expression: try container.resolve() as Service) { error in
|
||||
guard case let DipError.DefinitionNotFound(key) = error else { return false }
|
||||
|
||||
//then
|
||||
typealias F = () throws -> Service
|
||||
let expectedKey = DefinitionKey(protocolType: Service.self, factoryType: F.self, associatedTag: nil)
|
||||
XCTAssertEqual(key, expectedKey)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func testThatItThrowsErrorIfCanNotFindDefinitionForTag() {
|
||||
//given
|
||||
container.register(tag: "some tag") { ServiceImp1() as Service }
|
||||
|
||||
//when
|
||||
AssertThrows(expression: try container.resolve(tag: "other tag") as Service) { error in
|
||||
guard case let DipError.DefinitionNotFound(key) = error else { return false }
|
||||
|
||||
//then
|
||||
typealias F = () throws -> Service
|
||||
let expectedKey = DefinitionKey(protocolType: Service.self, factoryType: F.self, associatedTag: "other tag")
|
||||
XCTAssertEqual(key, expectedKey)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func testThatItThrowsErrorIfCanNotFindDefinitionForFactoryWithArguments() {
|
||||
//given
|
||||
container.register { ServiceImp1() as Service }
|
||||
|
||||
//when
|
||||
AssertThrows(expression: try container.resolve(withArguments: "some string") as Service) { error in
|
||||
guard case let DipError.DefinitionNotFound(key) = error else { return false }
|
||||
|
||||
//then
|
||||
typealias F = (String) throws -> Service
|
||||
let expectedKey = DefinitionKey(protocolType: Service.self, factoryType: F.self, associatedTag: nil)
|
||||
XCTAssertEqual(key, expectedKey)
|
||||
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func testThatItThrowsErrorIfConstructorThrows() {
|
||||
//given
|
||||
let failedKey = DefinitionKey(protocolType: Any.self, factoryType: Any.self)
|
||||
let expectedError = DipError.DefinitionNotFound(key: failedKey)
|
||||
container.register { () throws -> Service in throw expectedError }
|
||||
|
||||
//when
|
||||
AssertThrows(expression: try container.resolve() as Service) { error in
|
||||
switch error {
|
||||
case let DipError.DefinitionNotFound(key) where key == failedKey: return true
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testThatItThrowsErrorIfFailsToResolveDependency() {
|
||||
//given
|
||||
let failedKey = DefinitionKey(protocolType: Any.self, factoryType: Any.self)
|
||||
let expectedError = DipError.DefinitionNotFound(key: failedKey)
|
||||
container.register { ServiceImp1() as Service }
|
||||
.resolveDependencies { container, service in
|
||||
//simulate throwing error when resolving dependency
|
||||
throw expectedError
|
||||
}
|
||||
|
||||
//when
|
||||
AssertThrows(expression: try container.resolve() as Service) { error in
|
||||
switch error {
|
||||
case let DipError.DefinitionNotFound(key) where key == failedKey: return true
|
||||
default: return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func testThatItCallsDidResolveDependenciesOnResolvableIntance() {
|
||||
|
||||
class ResolvableService: Service, Resolvable {
|
||||
var didResolveDependenciesCalled = false
|
||||
|
||||
func didResolveDependencies() {
|
||||
XCTAssertFalse(didResolveDependenciesCalled, "didResolveDependencies should be called only once per instance")
|
||||
didResolveDependenciesCalled = true
|
||||
}
|
||||
}
|
||||
|
||||
container.register { ResolvableService() as Service }
|
||||
.resolveDependencies { _, service in
|
||||
XCTAssertFalse((service as! ResolvableService).didResolveDependenciesCalled, "didResolveDependencies should not be called yet")
|
||||
return
|
||||
}
|
||||
|
||||
container.register(tag: "graph", .ObjectGraph) { ResolvableService() as Service }
|
||||
.resolveDependencies { _, service in
|
||||
XCTAssertFalse((service as! ResolvableService).didResolveDependenciesCalled)
|
||||
return
|
||||
}
|
||||
|
||||
container.register(tag: "singleton", .Singleton) { ResolvableService() as Service }
|
||||
.resolveDependencies { _, service in
|
||||
XCTAssertFalse((service as! ResolvableService).didResolveDependenciesCalled)
|
||||
return
|
||||
}
|
||||
|
||||
let service = try! container.resolve() as Service
|
||||
XCTAssertTrue((service as! ResolvableService).didResolveDependenciesCalled)
|
||||
|
||||
let graphService = try! container.resolve(tag: "graph") as Service
|
||||
XCTAssertTrue((graphService as! ResolvableService).didResolveDependenciesCalled)
|
||||
|
||||
let singletonService = try! container.resolve(tag: "singleton") as Service
|
||||
let _ = try! container.resolve(tag: "singleton") as Service
|
||||
XCTAssertTrue((singletonService as! ResolvableService).didResolveDependenciesCalled)
|
||||
}
|
||||
|
||||
func testThatItCallsDidResolveDependenciesInReverseOrder() {
|
||||
|
||||
class ResolvableService: Service, Resolvable {
|
||||
static var resolved: [Service] = []
|
||||
|
||||
func didResolveDependencies() {
|
||||
ResolvableService.resolved.append(self)
|
||||
}
|
||||
}
|
||||
|
||||
var resolveDependenciesCalled = false
|
||||
var service2: Service!
|
||||
container.register { ResolvableService() as Service }
|
||||
.resolveDependencies { _, service in
|
||||
if !resolveDependenciesCalled {
|
||||
resolveDependenciesCalled = true
|
||||
service2 = try! self.container.resolve() as Service
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
let service1 = try! container.resolve() as Service
|
||||
|
||||
XCTAssertTrue(ResolvableService.resolved.first === service2)
|
||||
XCTAssertTrue(ResolvableService.resolved.last === service1)
|
||||
}
|
||||
|
||||
func testThatItResolvesCircularDependencies() {
|
||||
|
||||
class ResolvableServer: Server, Resolvable {
|
||||
weak var client: Client?
|
||||
weak var secondClient: Client?
|
||||
|
||||
init(client: Client) {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
var didResolveDependenciesCalled = false
|
||||
|
||||
func didResolveDependencies() {
|
||||
XCTAssertFalse(didResolveDependenciesCalled, "didResolveDependencies should be called only once per instance")
|
||||
didResolveDependenciesCalled = true
|
||||
|
||||
XCTAssertNotNil(self.client)
|
||||
XCTAssertNotNil(self.secondClient)
|
||||
XCTAssertNotNil(self.client?.server)
|
||||
XCTAssertNotNil(self.secondClient)
|
||||
XCTAssertNotNil(self.secondClient?.server)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class ResolvableClient: Client, Resolvable {
|
||||
var server: Server?
|
||||
var secondServer: Server?
|
||||
|
||||
init() {}
|
||||
|
||||
var didResolveDependenciesCalled = false
|
||||
|
||||
func didResolveDependencies() {
|
||||
XCTAssertFalse(didResolveDependenciesCalled, "didResolveDependencies should be called only once per instance")
|
||||
didResolveDependenciesCalled = true
|
||||
|
||||
XCTAssertNotNil(self.server)
|
||||
XCTAssertNotNil(self.secondServer)
|
||||
XCTAssertNotNil(self.server?.client)
|
||||
XCTAssertNotNil(self.secondServer?.client)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { try ResolvableServer(client: self.container.resolve()) as Server }
|
||||
.resolveDependencies { (container: DependencyContainer, server: Server) in
|
||||
let server = server as! ResolvableServer
|
||||
server.secondClient = try container.resolve() as Client
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ResolvableClient() as Client }
|
||||
.resolveDependencies { (container: DependencyContainer, client: Client) in
|
||||
let client = client as! ResolvableClient
|
||||
client.server = try container.resolve() as Server
|
||||
client.secondServer = try container.resolve() as Server
|
||||
}
|
||||
|
||||
let client = (try! container.resolve() as Client) as! ResolvableClient
|
||||
let server = client.server as! ResolvableServer
|
||||
let secondServer = client.secondServer as! ResolvableServer
|
||||
let secondClient = server.secondClient as! ResolvableClient
|
||||
|
||||
XCTAssertTrue(client === server.client)
|
||||
XCTAssertTrue(client === server.secondClient)
|
||||
XCTAssertTrue(client === secondServer.client)
|
||||
XCTAssertTrue(client === secondServer.secondClient)
|
||||
XCTAssertTrue(client === secondClient)
|
||||
XCTAssertTrue(server === secondServer)
|
||||
|
||||
XCTAssertTrue(client.didResolveDependenciesCalled)
|
||||
XCTAssertTrue(server.didResolveDependenciesCalled)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Dip
|
||||
|
||||
private protocol Service {
|
||||
var name: String { get }
|
||||
}
|
||||
|
||||
private class ServiceImp: Service {
|
||||
|
||||
let name: String
|
||||
|
||||
init(name: String, baseURL: String, port: Int) {
|
||||
self.name = name
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class ServiceImp1: Service {
|
||||
let name: String = "ServiceImp1"
|
||||
}
|
||||
|
||||
private class ServiceImp2: Service {
|
||||
let name: String = "ServiceImp2"
|
||||
}
|
||||
|
||||
class RuntimeArgumentsTests: XCTestCase {
|
||||
|
||||
let container = DependencyContainer()
|
||||
|
||||
#if os(Linux)
|
||||
var allTests: [(String, () throws -> Void)] {
|
||||
return [
|
||||
("testThatItResolvesInstanceWithOneArgument", testThatItResolvesInstanceWithOneArgument),
|
||||
("testThatItResolvesInstanceWithTwoArguments", testThatItResolvesInstanceWithTwoArguments),
|
||||
("testThatItResolvesInstanceWithThreeArguments", testThatItResolvesInstanceWithThreeArguments),
|
||||
("testThatItResolvesInstanceWithFourArguments", testThatItResolvesInstanceWithFourArguments),
|
||||
("testThatItResolvesInstanceWithFiveArguments", testThatItResolvesInstanceWithFiveArguments),
|
||||
("testThatItResolvesInstanceWithSixArguments", testThatItResolvesInstanceWithSixArguments),
|
||||
("testThatItRegistersDifferentFactoriesForDifferentNumberOfArguments", testThatItRegistersDifferentFactoriesForDifferentNumberOfArguments),
|
||||
("testThatItRegistersDifferentFactoriesForDifferentTypesOfArguments", testThatItRegistersDifferentFactoriesForDifferentTypesOfArguments),
|
||||
("testThatItRegistersDifferentFactoriesForDifferentOrderOfArguments", testThatItRegistersDifferentFactoriesForDifferentOrderOfArguments),
|
||||
("testThatNewRegistrationWithSameArgumentsOverridesPreviousRegistration", testThatNewRegistrationWithSameArgumentsOverridesPreviousRegistration),
|
||||
("testThatDifferentFactoriesRegisteredIfArgumentIsOptional", testThatDifferentFactoriesRegisteredIfArgumentIsOptional)
|
||||
]
|
||||
}
|
||||
|
||||
func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#else
|
||||
override func setUp() {
|
||||
container.reset()
|
||||
}
|
||||
#endif
|
||||
|
||||
func testThatItResolvesInstanceWithOneArgument() {
|
||||
//given
|
||||
let arg1 = 1
|
||||
container.register(factory: { (a1: Int) -> Service in
|
||||
XCTAssertEqual(a1, arg1)
|
||||
return ServiceImp1()
|
||||
})
|
||||
|
||||
//when
|
||||
let service = try! container.resolve(withArguments: arg1) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatItResolvesInstanceWithTwoArguments() {
|
||||
//given
|
||||
let arg1 = 1, arg2 = 2
|
||||
container.register { (a1: Int, a2: Int) -> Service in
|
||||
XCTAssertEqual(a1, arg1)
|
||||
XCTAssertEqual(a2, arg2)
|
||||
return ServiceImp1()
|
||||
}
|
||||
|
||||
//when
|
||||
let service = try! container.resolve(withArguments: arg1, arg2) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatItResolvesInstanceWithThreeArguments() {
|
||||
let arg1 = 1, arg2 = 2, arg3 = 3
|
||||
container.register { (a1: Int, a2: Int, a3: Int) -> Service in
|
||||
XCTAssertEqual(a1, arg1)
|
||||
XCTAssertEqual(a2, arg2)
|
||||
XCTAssertEqual(a3, arg3)
|
||||
return ServiceImp1()
|
||||
}
|
||||
|
||||
//when
|
||||
let service = try! container.resolve(withArguments: arg1, arg2, arg3) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatItResolvesInstanceWithFourArguments() {
|
||||
let arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4
|
||||
container.register { (a1: Int, a2: Int, a3: Int, a4: Int) -> Service in
|
||||
XCTAssertEqual(a1, arg1)
|
||||
XCTAssertEqual(a2, arg2)
|
||||
XCTAssertEqual(a3, arg3)
|
||||
XCTAssertEqual(a4, arg4)
|
||||
return ServiceImp1()
|
||||
}
|
||||
|
||||
//when
|
||||
let service = try! container.resolve(withArguments: arg1, arg2, arg3, arg4) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatItResolvesInstanceWithFiveArguments() {
|
||||
let arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4, arg5 = 5
|
||||
container.register { (a1: Int, a2: Int, a3: Int, a4: Int, a5: Int) -> Service in
|
||||
XCTAssertEqual(a1, arg1)
|
||||
XCTAssertEqual(a2, arg2)
|
||||
XCTAssertEqual(a3, arg3)
|
||||
XCTAssertEqual(a4, arg4)
|
||||
XCTAssertEqual(a5, arg5)
|
||||
return ServiceImp1()
|
||||
}
|
||||
|
||||
//when
|
||||
let service = try! container.resolve(withArguments: arg1, arg2, arg3, arg4, arg5) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatItResolvesInstanceWithSixArguments() {
|
||||
let arg1 = 1, arg2 = 2, arg3 = 3, arg4 = 4, arg5 = 5, arg6 = 6
|
||||
container.register { (a1: Int, a2: Int, a3: Int, a4: Int, a5: Int, a6: Int) -> Service in
|
||||
XCTAssertEqual(a1, arg1)
|
||||
XCTAssertEqual(a2, arg2)
|
||||
XCTAssertEqual(a3, arg3)
|
||||
XCTAssertEqual(a4, arg4)
|
||||
XCTAssertEqual(a5, arg5)
|
||||
XCTAssertEqual(a6, arg6)
|
||||
return ServiceImp1()
|
||||
}
|
||||
|
||||
//when
|
||||
let service = try! container.resolve(withArguments: arg1, arg2, arg3, arg4, arg5, arg6) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service is ServiceImp1)
|
||||
}
|
||||
|
||||
func testThatItRegistersDifferentFactoriesForDifferentNumberOfArguments() {
|
||||
//given
|
||||
let arg1 = 1, arg2 = 2
|
||||
container.register { (a1: Int) in ServiceImp1() as Service }
|
||||
container.register { (a1: Int, a2: Int) in ServiceImp2() as Service }
|
||||
|
||||
//when
|
||||
let service1 = try! container.resolve(withArguments: arg1) as Service
|
||||
let service2 = try! container.resolve(withArguments: arg1, arg2) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1 is ServiceImp1)
|
||||
XCTAssertTrue(service2 is ServiceImp2)
|
||||
}
|
||||
|
||||
func testThatItRegistersDifferentFactoriesForDifferentTypesOfArguments() {
|
||||
//given
|
||||
let arg1 = 1, arg2 = "string"
|
||||
container.register(factory: { (a1: Int) in ServiceImp1() as Service })
|
||||
container.register(factory: { (a1: String) in ServiceImp2() as Service })
|
||||
|
||||
//when
|
||||
let service1 = try! container.resolve(withArguments: arg1) as Service
|
||||
let service2 = try! container.resolve(withArguments: arg2) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1 is ServiceImp1)
|
||||
XCTAssertTrue(service2 is ServiceImp2)
|
||||
}
|
||||
|
||||
func testThatItRegistersDifferentFactoriesForDifferentOrderOfArguments() {
|
||||
//given
|
||||
let arg1 = 1, arg2 = "string"
|
||||
container.register { (a1: Int, a2: String) in ServiceImp1() as Service }
|
||||
container.register { (a1: String, a2: Int) in ServiceImp2() as Service }
|
||||
|
||||
//when
|
||||
let service1 = try! container.resolve(withArguments: arg1, arg2) as Service
|
||||
let service2 = try! container.resolve(withArguments: arg2, arg1) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1 is ServiceImp1)
|
||||
XCTAssertTrue(service2 is ServiceImp2)
|
||||
}
|
||||
|
||||
func testThatNewRegistrationWithSameArgumentsOverridesPreviousRegistration() {
|
||||
//given
|
||||
let arg1 = 1, arg2 = 2
|
||||
container.register { (a1: Int, a2: Int) in ServiceImp1() as Service }
|
||||
let service1 = try! container.resolve(withArguments: arg1, arg2) as Service
|
||||
|
||||
//when
|
||||
container.register { (a1: Int, a2: Int) in ServiceImp2() as Service }
|
||||
let service2 = try! container.resolve(withArguments: arg1, arg2) as Service
|
||||
|
||||
//then
|
||||
XCTAssertTrue(service1 is ServiceImp1)
|
||||
XCTAssertTrue(service2 is ServiceImp2)
|
||||
}
|
||||
|
||||
func testThatDifferentFactoriesRegisteredIfArgumentIsOptional() {
|
||||
//given
|
||||
let name1 = "1", name2 = "2", name3 = "3"
|
||||
container.register { (port: Int, url: String) in ServiceImp(name: name1, baseURL: url, port: port) as Service }
|
||||
container.register { (port: Int, url: String?) in ServiceImp(name: name2, baseURL: url!, port: port) as Service }
|
||||
container.register { (port: Int, url: String!) in ServiceImp(name: name3, baseURL: url, port: port) as Service }
|
||||
|
||||
//when
|
||||
let service1 = try! container.resolve(withArguments: 80, "http://example.com") as Service
|
||||
let service2 = try! container.resolve(withArguments: 80, "http://example.com" as String?) as Service
|
||||
let service3 = try! container.resolve(withArguments: 80, "http://example.com" as String!) as Service
|
||||
|
||||
//then
|
||||
XCTAssertEqual(service1.name, name1)
|
||||
XCTAssertEqual(service2.name, name2)
|
||||
XCTAssertEqual(service3.name, name3)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
@testable import Dip
|
||||
|
||||
private protocol Server: class {
|
||||
var client: Client? { get set }
|
||||
}
|
||||
|
||||
private protocol Client: class {
|
||||
var server: Server { get }
|
||||
}
|
||||
|
||||
private class ClientImp: Client, Equatable {
|
||||
var server: Server
|
||||
init(server: Server) {
|
||||
self.server = server
|
||||
}
|
||||
}
|
||||
|
||||
private func ==<T: ClientImp>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs === rhs
|
||||
}
|
||||
|
||||
private class ServerImp: Server, Hashable {
|
||||
weak var client: Client?
|
||||
init() {}
|
||||
|
||||
var hashValue: Int {
|
||||
return unsafeAddressOf(self).hashValue
|
||||
}
|
||||
}
|
||||
|
||||
private func ==<T: ServerImp>(lhs: T, rhs: T) -> Bool {
|
||||
return lhs === rhs
|
||||
}
|
||||
|
||||
private var resolvedServers = Set<ServerImp>()
|
||||
private var resolvedClients = Array<ClientImp>()
|
||||
|
||||
private var container: DependencyContainer!
|
||||
|
||||
#if os(Linux)
|
||||
import Glibc
|
||||
private var lock: pthread_spinlock_t = 0
|
||||
|
||||
private let resolveClientSync: () -> Client? = {
|
||||
var clientPointer: UnsafeMutablePointer<Void> = nil
|
||||
clientPointer = dispatch_sync { _ in
|
||||
let resolved = try! container.resolve() as Client
|
||||
return UnsafeMutablePointer(Unmanaged.passUnretained(resolved as! ClientImp).toOpaque())
|
||||
}
|
||||
return Unmanaged<ClientImp>.fromOpaque(COpaquePointer(clientPointer)).takeUnretainedValue()
|
||||
}
|
||||
|
||||
#else
|
||||
let queue = NSOperationQueue()
|
||||
let lock = NSRecursiveLock()
|
||||
|
||||
private let resolveClientSync: () -> Client? = {
|
||||
var client: Client?
|
||||
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
|
||||
client = try! container.resolve() as Client
|
||||
}
|
||||
return client
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
let resolveServerAsync = {
|
||||
let service = try! container.resolve() as Server
|
||||
lock.lock()
|
||||
resolvedServers.insert(service as! ServerImp)
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
let resolveClientAsync = {
|
||||
let client = try! container.resolve() as Client
|
||||
lock.lock()
|
||||
resolvedClients.append(client as! ClientImp)
|
||||
lock.unlock()
|
||||
}
|
||||
|
||||
class ThreadSafetyTests: XCTestCase {
|
||||
|
||||
#if os(Linux)
|
||||
init() {
|
||||
pthread_spin_init(&lock, 0)
|
||||
}
|
||||
|
||||
var allTests: [(String, () throws -> Void)] {
|
||||
return [
|
||||
("testSingletonThreadSafety", testSingletonThreadSafety),
|
||||
("testFactoryThreadSafety", testFactoryThreadSafety),
|
||||
("testCircularReferenceThreadSafety", testCircularReferenceThreadSafety)
|
||||
]
|
||||
}
|
||||
|
||||
func setUp() {
|
||||
container = DependencyContainer()
|
||||
}
|
||||
|
||||
func tearDown() {
|
||||
resolvedServers.removeAll()
|
||||
resolvedClients.removeAll()
|
||||
}
|
||||
#else
|
||||
override func setUp() {
|
||||
container = DependencyContainer()
|
||||
}
|
||||
|
||||
override func tearDown() {
|
||||
resolvedServers.removeAll()
|
||||
resolvedClients.removeAll()
|
||||
}
|
||||
#endif
|
||||
|
||||
func testSingletonThreadSafety() {
|
||||
container.register(.Singleton) { ServerImp() as Server }
|
||||
|
||||
for _ in 0..<100 {
|
||||
#if os(Linux)
|
||||
dispatch_async({ _ in
|
||||
resolveServerAsync()
|
||||
return nil
|
||||
})
|
||||
#else
|
||||
queue.addOperationWithBlock(resolveServerAsync)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(Linux)
|
||||
sleep(1)
|
||||
#else
|
||||
queue.waitUntilAllOperationsAreFinished()
|
||||
#endif
|
||||
|
||||
XCTAssertEqual(resolvedServers.count, 1, "Should create only one instance")
|
||||
}
|
||||
|
||||
|
||||
func testFactoryThreadSafety() {
|
||||
container.register { ServerImp() as Server }
|
||||
|
||||
for _ in 0..<100 {
|
||||
#if os(Linux)
|
||||
dispatch_async({ _ in
|
||||
resolveServerAsync()
|
||||
return nil
|
||||
})
|
||||
#else
|
||||
queue.addOperationWithBlock(resolveServerAsync)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(Linux)
|
||||
sleep(1)
|
||||
#else
|
||||
queue.waitUntilAllOperationsAreFinished()
|
||||
#endif
|
||||
|
||||
XCTAssertEqual(resolvedServers.count, 100, "All instances should be different")
|
||||
}
|
||||
|
||||
|
||||
func testCircularReferenceThreadSafety() {
|
||||
container.register(.ObjectGraph) {
|
||||
ClientImp(server: try container.resolve()) as Client
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
.resolveDependencies { container, server in
|
||||
server.client = resolveClientSync()
|
||||
}
|
||||
|
||||
for _ in 0..<100 {
|
||||
#if os(Linux)
|
||||
dispatch_async({ _ in
|
||||
resolveClientAsync()
|
||||
return nil
|
||||
})
|
||||
#else
|
||||
queue.addOperationWithBlock(resolveClientAsync)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if os(Linux)
|
||||
sleep(1)
|
||||
#else
|
||||
queue.waitUntilAllOperationsAreFinished()
|
||||
#endif
|
||||
|
||||
XCTAssertEqual(resolvedClients.count, 100, "Instances should be not reused in different object graphs")
|
||||
for client in resolvedClients {
|
||||
let service = client.server as! ServerImp
|
||||
let serviceClient = service.client as! ClientImp
|
||||
XCTAssertEqual(serviceClient, client, "Instances should be reused when resolving single object graph")
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import XCTest
|
||||
|
||||
|
||||
func AssertThrows<T>(file: StaticString = #file, line: UInt = #line, @autoclosure expression: () throws -> T) {
|
||||
AssertThrows(file, line: line, expression: expression, "")
|
||||
}
|
||||
|
||||
func AssertThrows<T>(file: StaticString = #file, line: UInt = #line, @autoclosure expression: () throws -> T, _ message: String) {
|
||||
AssertThrows(expression: expression, checkError: { _ in true }, message)
|
||||
}
|
||||
|
||||
func AssertThrows<T>(file: StaticString = #file, line: UInt = #line, @autoclosure expression: () throws -> T, checkError: ErrorType -> Bool) {
|
||||
AssertThrows(file, line: line, expression: expression, checkError: checkError, "")
|
||||
}
|
||||
|
||||
func AssertThrows<T>(file: StaticString = #file, line: UInt = #line, @autoclosure expression: () throws -> T, checkError: ErrorType -> Bool, _ message: String) {
|
||||
do {
|
||||
try expression()
|
||||
XCTFail(message, file: file, line: line)
|
||||
}
|
||||
catch {
|
||||
XCTAssertTrue(checkError(error), "Thrown unexpected error: \(error)", file: file, line: line)
|
||||
}
|
||||
}
|
||||
|
||||
func AssertNoThrow<T>(file: StaticString = #file, line: UInt = #line, @autoclosure expression: () throws -> T) {
|
||||
AssertNoThrow(file, line: line, expression: expression, "")
|
||||
}
|
||||
|
||||
func AssertNoThrow<T>(file: StaticString = #file, line: UInt = #line, @autoclosure expression: () throws -> T, _ message: String) {
|
||||
do {
|
||||
try expression()
|
||||
}
|
||||
catch {
|
||||
XCTFail(message, file: file, line: line)
|
||||
}
|
||||
}
|
||||
|
||||
#if os(Linux)
|
||||
import Glibc
|
||||
typealias TMain = @convention(c) (UnsafeMutablePointer<Void>) -> UnsafeMutablePointer<Void>
|
||||
|
||||
func dispatch_async(block: TMain) {
|
||||
var pid: pthread_t = 0
|
||||
pthread_create(&pid, nil, block, nil)
|
||||
}
|
||||
|
||||
func dispatch_sync(block: TMain) -> UnsafeMutablePointer<Void> {
|
||||
var pid: pthread_t = 0
|
||||
var result: UnsafeMutablePointer<Void> = nil
|
||||
pthread_create(&pid, nil, block, nil)
|
||||
pthread_join(pid, &result)
|
||||
return result
|
||||
}
|
||||
|
||||
extension pthread_spinlock_t {
|
||||
mutating func lock() {
|
||||
pthread_spin_lock(&self)
|
||||
}
|
||||
mutating func unlock() {
|
||||
pthread_spin_unlock(&self)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
import XCTest
|
||||
|
||||
XCTMain([
|
||||
DipTests(),
|
||||
DefinitionTests(),
|
||||
RuntimeArgumentsTests(),
|
||||
ComponentScopeTests(),
|
||||
AutoInjectionTests(),
|
||||
ThreadSafetyTests(),
|
||||
AutoWiringTests()
|
||||
])
|
||||
@@ -0,0 +1,213 @@
|
||||
//: [Previous: Shared Instances](@previous)
|
||||
|
||||
import UIKit
|
||||
import Dip
|
||||
|
||||
let container = DependencyContainer()
|
||||
/*:
|
||||
|
||||
### Auto-Injection
|
||||
|
||||
On the previous page you saw how auto-wiring helps us get rid of boilerplate code when registering and resolving components with consturctor injection. Auto-injection solves the same problem for property injection.
|
||||
|
||||
Let's say you have following related components:
|
||||
*/
|
||||
|
||||
protocol Service: class {
|
||||
var logger: Logger? { get }
|
||||
var tracker: Tracker? { get }
|
||||
}
|
||||
|
||||
class ServiceImp: Service {
|
||||
var logger: Logger?
|
||||
var tracker: Tracker?
|
||||
}
|
||||
|
||||
/*:
|
||||
When you register them in a container you will end up with something like this:
|
||||
*/
|
||||
|
||||
container.register() { TrackerImp() as Tracker }
|
||||
container.register() { LoggerImp() as Logger }
|
||||
|
||||
container.register() { ServiceImp() as Service }
|
||||
.resolveDependencies { container, service in
|
||||
let service = service as! ServiceImp
|
||||
service.logger = try container.resolve() as Logger
|
||||
service.tracker = try container.resolve() as Tracker
|
||||
}
|
||||
|
||||
let service = try! container.resolve() as Service
|
||||
service.logger
|
||||
service.tracker
|
||||
|
||||
/*:
|
||||
Notice that the same boilerplate code that we saw in constructor injection now moved to `resolveDepedencies` block.
|
||||
With auto-injection your code transforms to this:
|
||||
*/
|
||||
|
||||
class AutoInjectedServiceImp: Service {
|
||||
private var injectedLogger = Injected<Logger>()
|
||||
var logger: Logger? { return injectedLogger.value }
|
||||
|
||||
private var injectedTracker = Injected<Tracker>()
|
||||
var tracker: Tracker? { return injectedTracker.value }
|
||||
}
|
||||
|
||||
container.register() { AutoInjectedServiceImp() as Service }
|
||||
|
||||
let autoInjectedService = try! container.resolve() as Service
|
||||
autoInjectedService.logger
|
||||
autoInjectedService.tracker
|
||||
|
||||
/*:
|
||||
As you can see we added two private properties to our implementation of `Service` - `injectedLogger` and `injectedTracker`. Their types are `Injeceted<Logger>` and `Injected<Tracker>` respectively. Note that we've not just defined them as properties of those types, but defined them with some initial value. `Injected<T>` is a simple _wrapper class_ that wraps value of generic type and provides read-write access to it with `value` property. This property is defined as optional, so that when we create instance of `Injected<T>` it will have `nil` in its value. There is also another wrapper - `InjectedWeak<T>` - which in contrast to `Injected<T>` holds a week reference to its wrapped object, thus requiring it to be a _reference type_ (or `AnyObject`), when `Injected<T>` can also wrap value types (or `Any`).
|
||||
|
||||
What is happening under the hood is that after concrete instance of resolved type is created (`Service` in that case), container will iterate through its properties using `Mirror`. For each of the properties wrapped with `Injected<T>` or `InjectedWeak<T>` it will search a definition that can be used to create an instance of wrapped type and use it to create and inject a concrete instance in a `value` property of a wrapper. The fact that wrappers are _classes_ or _reference types_ makes it possible at runtime to inject dependency in instance of resolved type.
|
||||
|
||||
The requirement for auto-injection is that types injected types should be registered in a container and should use factories with no runtime arguments.
|
||||
|
||||
Auto-injected properties can be marked with tag. Then container will search for definition tagged by the same tag to resolve this property.
|
||||
|
||||
You can provide closure that will be called when the dependency will be injected in the property. It is similar to `didSet` property observer.
|
||||
|
||||
Auto-injected properties are required by default. That means that if container fails to resolve any of auto-injected properties of the instance (or any of its dependencies) it will fail resolution of the object graph in whole.
|
||||
*/
|
||||
|
||||
class ServerWithRequiredClient {
|
||||
var client = Injected<Client>()
|
||||
}
|
||||
|
||||
container.register { ServerWithRequiredClient() }
|
||||
|
||||
do {
|
||||
let serverWithClient = try container.resolve() as ServerWithRequiredClient
|
||||
}
|
||||
catch {
|
||||
print(error)
|
||||
}
|
||||
|
||||
/*:
|
||||
You can make auto-injected property optional by passing `false` to `required` parameter of `Injected<T>`/`InjectedWeak<T>` constructor. For such properties container will ignore any errors when it resolves this property (or any of its dependencies).
|
||||
*/
|
||||
|
||||
class ServerWithOptionalClient {
|
||||
var optionalClient = Injected<Client>(required: false)
|
||||
}
|
||||
|
||||
container.register { ServerWithOptionalClient() }
|
||||
let serverWithNoClient = try! container.resolve() as ServerWithOptionalClient
|
||||
serverWithNoClient.optionalClient.value
|
||||
|
||||
/*:
|
||||
Another example of using auto-injection is circular dependencies. Let's say you have a `Server` and a `ServerClient` both referencing each other.
|
||||
*/
|
||||
|
||||
protocol Server: class {
|
||||
weak var client: ServerClient? { get }
|
||||
}
|
||||
|
||||
protocol ServerClient: class {
|
||||
var server: Server? { get }
|
||||
}
|
||||
|
||||
class ServerImp: Server {
|
||||
weak var client: ServerClient?
|
||||
}
|
||||
|
||||
class ServerClientImp: ServerClient {
|
||||
var server: Server?
|
||||
|
||||
init(server: Server) {
|
||||
self.server = server
|
||||
}
|
||||
}
|
||||
|
||||
/*:
|
||||
The standard way to register such components in `DependencyContainer` will lead to such code:
|
||||
*/
|
||||
|
||||
container.register(.ObjectGraph) {
|
||||
ServerClientImp(server: try container.resolve()) as ServerClient
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
.resolveDependencies { (container: DependencyContainer, server: Server) in
|
||||
(server as! ServerImp).client = try container.resolve() as ServerClient
|
||||
}
|
||||
|
||||
let client = try! container.resolve() as ServerClient
|
||||
client.server
|
||||
|
||||
/*:
|
||||
With auto-injection you will have the following code:
|
||||
*/
|
||||
|
||||
class InjectedServerImp: Server {
|
||||
private var injectedClient = InjectedWeak<ServerClient>()
|
||||
var client: ServerClient? { return injectedClient.value }
|
||||
}
|
||||
|
||||
class InjectedClientImp: ServerClient {
|
||||
private var injectedServer = Injected<Server>()
|
||||
var server: Server? { get { return injectedServer.value } }
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { InjectedServerImp() as Server }
|
||||
container.register(.ObjectGraph) { InjectedClientImp() as ServerClient }
|
||||
|
||||
let injectedClient = try! container.resolve() as ServerClient
|
||||
injectedClient.server
|
||||
injectedClient.server?.client === injectedClient //circular dependencies were resolved correctly
|
||||
|
||||
/*:
|
||||
You can see that component registration looks much simpler now. But on the other side it requires some boilerplate code in implementations, and also tightly coupls your code with Dip.
|
||||
|
||||
Here is an example with higher number of dependencies.
|
||||
*/
|
||||
container.register() { RouterImp() as Router }
|
||||
container.register() { DataProviderImp() as DataProvider }
|
||||
|
||||
class ViewController: UIViewController {
|
||||
var logger: Logger?
|
||||
var tracker: Tracker?
|
||||
var dataProvider: DataProvider?
|
||||
var router: Router?
|
||||
}
|
||||
|
||||
container.register { ViewController() }
|
||||
.resolveDependencies { container, controller in
|
||||
controller.logger = try container.resolve() as Logger
|
||||
controller.tracker = try container.resolve() as Tracker
|
||||
controller.dataProvider = try container.resolve() as DataProvider
|
||||
controller.router = try container.resolve() as Router
|
||||
}
|
||||
|
||||
let viewController = try! container.resolve() as ViewController
|
||||
viewController.router
|
||||
|
||||
/*:
|
||||
With auto-injection you can replace that with something like this:
|
||||
*/
|
||||
|
||||
class AutoInjectedViewController: UIViewController {
|
||||
let logger = Injected<Logger>()
|
||||
let tracker = Injected<Tracker>()
|
||||
let dataProvider = Injected<DataProvider>()
|
||||
let router = Injected<Router>()
|
||||
}
|
||||
|
||||
container.register { AutoInjectedViewController() }
|
||||
|
||||
let autoViewController = try! container.resolve() as AutoInjectedViewController
|
||||
autoViewController.router.value
|
||||
|
||||
/*:
|
||||
In such scenario when view controller is created by storyboard you will need to use property injection anyway, so the overhead of adding additional properties for auto-injection is smaller. Also all the boilerplate code of unwrapping injected properties (if you need that) can be moved to extension, cleaning implementation a bit.
|
||||
|
||||
> **Note**: For such cases concider using [DipUI](https://github.com/AliSoftware/Dip-UI). It is a small extension for Dip that allows you to do exactly what we need in this example - inject dependencies in instances created by storyboards. It does not require to use auto-injection feature but plays nice with it.
|
||||
|
||||
So as you can see there are certain advantages and disadvatages of using auto-injection. It makes your definitions simpler, especially if there are circular dependencies involved or the number of dependencies is high, removing boilerplate calls to `resolve` method in `resolveDependencies` block of your definitions. But it requires additional properties and some boilerplate code in your implementations, makes your implementatios tightly coupled with Dip. You can avoid tight coupoling by using your own boxing classes instead of `Injected<T>` and `InjectedWeak<T>` (see `AutoInjectedPropertyBox`).
|
||||
*/
|
||||
|
||||
//: [Next: Testing](@next)
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,117 @@
|
||||
//: [Previous: Shared Instances](@previous)
|
||||
|
||||
import Dip
|
||||
import UIKit
|
||||
|
||||
/*:
|
||||
|
||||
### Auto-wiring
|
||||
|
||||
Among three main DI patterns - _constructor_, _property_ and _method_ injection - construction injection should be your choise by default. Dip makes use of this pattern very simple.
|
||||
|
||||
Let's say you have some VIPER module with following components:
|
||||
*/
|
||||
protocol Service {}
|
||||
protocol Interactor {
|
||||
var service: Service { get }
|
||||
}
|
||||
protocol Router {}
|
||||
protocol ViewOutput {}
|
||||
protocol Presenter {
|
||||
var router: Router { get }
|
||||
var interactor: Interactor { get }
|
||||
var view: ViewOutput { get }
|
||||
}
|
||||
|
||||
class RouterImp: Router {}
|
||||
class View: UIView, ViewOutput {}
|
||||
class ServiceImp: Service {}
|
||||
|
||||
/*:
|
||||
VIPER module by its nature consists of a lot of components, wired up using protocols. Using construction injection you can end up with following constructors for presenter and interactor:
|
||||
*/
|
||||
|
||||
class InteractorImp: Interactor {
|
||||
var service: Service
|
||||
|
||||
init(service: Service) {
|
||||
self.service = service
|
||||
}
|
||||
}
|
||||
|
||||
class PresenterImp: Presenter {
|
||||
let router: Router
|
||||
let interactor: Interactor
|
||||
let view: ViewOutput
|
||||
|
||||
init(view: ViewOutput, interactor: Interactor, router: Router) {
|
||||
self.view = view
|
||||
self.interactor = interactor
|
||||
self.router = router
|
||||
}
|
||||
}
|
||||
|
||||
/*:
|
||||
If you register these components in a container you will end up with rather boilerplate code:
|
||||
*/
|
||||
|
||||
let container = DependencyContainer()
|
||||
container.register { ServiceImp() as Service }
|
||||
container.register { RouterImp() as Router }
|
||||
container.register { View() as ViewOutput }
|
||||
|
||||
container.register { try InteractorImp(service: container.resolve()) as Interactor }
|
||||
container.register {
|
||||
try PresenterImp(
|
||||
view: container.resolve(),
|
||||
interactor: container.resolve(),
|
||||
router: container.resolve()) as Presenter
|
||||
}
|
||||
|
||||
|
||||
var presenter = try! container.resolve() as Presenter
|
||||
presenter.interactor.service
|
||||
|
||||
/*:
|
||||
While definition for `Interactor` looks fine, `Presenter`'s definition is overloaded with the same `resolve` calls to container.
|
||||
|
||||
The other option you have is to register factory with runtime arguments:
|
||||
*/
|
||||
|
||||
container.register { InteractorImp(service: $0) as Interactor }
|
||||
container.register { PresenterImp(view: $0, interactor: $1, router: $2) as Presenter }
|
||||
|
||||
/*:
|
||||
But then to resolve presenter or interactor you will first need to resolve their dependencies and pass them as arguments to `resolve` method:
|
||||
*/
|
||||
|
||||
let service = try! container.resolve() as Service
|
||||
let interactor = try! container.resolve(withArguments: service) as Interactor
|
||||
let view = try! container.resolve() as ViewOutput
|
||||
let router = try! container.resolve() as Router
|
||||
presenter = try! container.resolve(withArguments: view, interactor, router) as Presenter
|
||||
presenter.interactor.service
|
||||
|
||||
/*:
|
||||
Again to much of boilerplate code. Also it's easy to make a mistake in the order of arguments.
|
||||
|
||||
Auto-wiring solves this problem by combining these two approaches - you register factories with runtime arguments, but resolve components with just a call to `resolve()`. Container will resolve all consturctor arguments for you.
|
||||
*/
|
||||
|
||||
container.register { InteractorImp(service: $0) as Interactor }
|
||||
container.register { PresenterImp(view: $0, interactor: $1, router: $2) as Presenter }
|
||||
|
||||
presenter = try! container.resolve() as Presenter
|
||||
presenter.interactor.service
|
||||
|
||||
/*:
|
||||
You don't need to call `resolve` in a factory and care about order of arguments any more.
|
||||
|
||||
The only requirement is that all constructor arguments should be registered in the container and there should be no several factories with the same _number_ of arguments registered for the same components.
|
||||
|
||||
In very rare case when you have several different factories with different set of runtime arguments registered for the same component, when you try to resolve it container will try to use these factories one by one until one of them succeeds starting with a factory with most numbers of arguments. If it finds two factories with the same number of arguments it will throw an error.
|
||||
|
||||
You can use auto-wiring with tags. The tag that you pass to `resolve` method will be used to resolve each of the constructor arguments.
|
||||
*/
|
||||
|
||||
//: [Next: Auto-injection](@next)
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,106 @@
|
||||
//: [Previous: Scopes](@previous)
|
||||
|
||||
import Dip
|
||||
|
||||
let container = DependencyContainer()
|
||||
|
||||
/*:
|
||||
### Circular Dependencies
|
||||
|
||||
Very often we encounter situations when we have circular dependencies between components. The most obvious example is delegation pattern. Dip can resolve such dependencies easily.
|
||||
|
||||
Let's say you have some network client and it's delegate defined like this:
|
||||
*/
|
||||
|
||||
protocol NetworkClientDelegate: class {
|
||||
var networkClient: NetworkClient { get }
|
||||
}
|
||||
|
||||
protocol NetworkClient: class {
|
||||
weak var delegate: NetworkClientDelegate? { get set }
|
||||
}
|
||||
|
||||
class NetworkClientImp: NetworkClient {
|
||||
weak var delegate: NetworkClientDelegate?
|
||||
init() {}
|
||||
}
|
||||
|
||||
class Interactor: NetworkClientDelegate {
|
||||
let networkClient: NetworkClient
|
||||
init(networkClient: NetworkClient) {
|
||||
self.networkClient = networkClient
|
||||
}
|
||||
}
|
||||
|
||||
/*:
|
||||
Note that:
|
||||
|
||||
- one of this classes uses _property injection_ (`NetworkClientImp`) — you'll give the `delegate` value via its property directly, _after_ initialization
|
||||
- and another uses _constructor injection_ (`Interactor`) — you'll need to give the `networkclient` value via the constructor, _during_ initialization.
|
||||
|
||||
It's very important that _at least one_ of them uses property injection, because if you try to use constructor injection for both of them then you will enter infinite loop when you will call `resolve`.
|
||||
|
||||
Now you can register those classes in container:
|
||||
*/
|
||||
|
||||
container.register(.ObjectGraph) {
|
||||
Interactor(networkClient: try container.resolve()) as NetworkClientDelegate
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { NetworkClientImp() as NetworkClient }
|
||||
.resolveDependencies { (container, client) -> () in
|
||||
client.delegate = try container.resolve() as NetworkClientDelegate
|
||||
}
|
||||
|
||||
/*:
|
||||
Here you can spot the difference in the way we register classes.
|
||||
|
||||
- `Interactor` class uses constructor injection, so to register it we use the block factory where we call `resolve` to obtain instance of `NetworkClient` and pass it to constructor.
|
||||
- `NetworkClientImp` uses property injection for it's delegate property. Again we use block factory to create instance, but to inject the delegate property we use the special `resolveDependencies` method. Block passed to this method will be called right _after_ the block factory. So you can use this block to perform additional setup or, like in this example, to resolve circular dependencies.
|
||||
|
||||
This way `DependencyContainer` breaks infinite recursion that would happen if we used constructor injection for both of our components.
|
||||
|
||||
*Note*: You can use container reference inside instance factory without using capture list, there will be [no retain cycle](https://github.com/AliSoftware/Dip/issues/23)
|
||||
|
||||
|
||||
Now when you resolve `NetworkClientDelegate` you will get an instance of `Interactor` that will have client with delegate referencing the same `Interactor` instance:
|
||||
*/
|
||||
|
||||
let interactor = try! container.resolve() as NetworkClientDelegate
|
||||
interactor.networkClient.delegate === interactor // true: they are the same instances
|
||||
|
||||
/*:
|
||||
**Warning**: Note that one of the properties (`delegate`) is defined as _weak_. That's crucial to avoid retain cycle. But now if you try to resolve `NetworkClient` first it's delegate will be released before `resolve` returns, bcause no one holds a reference to it except the container.
|
||||
*/
|
||||
|
||||
let networkClient = try! container.resolve() as NetworkClient
|
||||
networkClient.delegate // delegate was alread released =(
|
||||
|
||||
/*:
|
||||
Note also that we used `.ObjectGraph` scope to register implementations. This is also very important to preserve consistency of objects relationships.
|
||||
|
||||
If we would have used `.Prototype` scope for both components then container would not reuse instances and we would have an infinite loop:
|
||||
|
||||
- Each attempt to resolve `NetworkClientDelegate` will create new instance of `Interactor`.
|
||||
- It will resolve `NetworkClient` which will create new instance of `NetworkClientImp`.
|
||||
- It will try to resolve it's delegate property and that will create new instance of `Interactor`
|
||||
- … And so on and so on.
|
||||
|
||||
If we would have used `.Prototype` for one of the components it will lead to the same infinite loop or one of the relationships will be invalid:
|
||||
*/
|
||||
|
||||
container.reset()
|
||||
|
||||
container.register(.Prototype) {
|
||||
Interactor(networkClient: try container.resolve()) as NetworkClientDelegate
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { NetworkClientImp() as NetworkClient }
|
||||
.resolveDependencies { (container, client) -> () in
|
||||
client.delegate = try container.resolve() as NetworkClientDelegate
|
||||
}
|
||||
|
||||
let invalidInteractor = try! container.resolve() as NetworkClientDelegate
|
||||
invalidInteractor.networkClient.delegate // that is not valid
|
||||
|
||||
//: [Next: Shared Instances](@next)
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,35 @@
|
||||
//: [Previous: What is Dip?](@previous)
|
||||
|
||||
import Dip
|
||||
|
||||
/*:
|
||||
Dip has two base components: a _DependencyContainer_ and its _Definitions_.
|
||||
|
||||
- _DependencyContainer_ is used to register _Definitions_ and to resolve them.
|
||||
- _Definitions_ describe how component should be created by the _DependencyContainer_.
|
||||
|
||||
### Creating the container
|
||||
|
||||
You can create a container using a simple `init()`:
|
||||
*/
|
||||
|
||||
var container = DependencyContainer()
|
||||
//register components here
|
||||
|
||||
/*:
|
||||
or using a configuration block:
|
||||
*/
|
||||
|
||||
container = DependencyContainer { container in
|
||||
//register components here
|
||||
}
|
||||
|
||||
/*:
|
||||
Both syntaxes are equivalent. The one using the configuration block is simply a convenience way to scope your components registrations in a nice looking way.
|
||||
|
||||
### When/where to create container?
|
||||
|
||||
While there is an option to use container as a global variable we advise instead to create and configure container in your app delegate and pass it between your objects (see [Shared Instances](Shared%20Instances)).
|
||||
|
||||
*/
|
||||
//: [Next: Registering Components](@next)
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,58 @@
|
||||
//: [Previous: Creating a DependencyContainer](@previous)
|
||||
|
||||
import Dip
|
||||
|
||||
/*:
|
||||
|
||||
### Registering components
|
||||
|
||||
You register a definition in a container using the `register` method:
|
||||
*/
|
||||
let container = DependencyContainer()
|
||||
container.register { ServiceImp1() as Service }
|
||||
|
||||
/*:
|
||||
That code means that when you need a `Service`, you want to use instances of `ServiceImp1` class created with it's `init()` initializer.
|
||||
|
||||
You can also register factories that accept runtime arguments:
|
||||
*/
|
||||
|
||||
container.register { service in ClientImp1(service: service) as Client }
|
||||
|
||||
/*:
|
||||
Dip supports up to six runtime arguments, but you can use as many as you want. For more details see ["Runtime arguments"](Runtime%20arguments).
|
||||
|
||||
You can also use factory methods in definitions. This can be useful if you already have some factories but want to migrate to Dip.
|
||||
*/
|
||||
|
||||
let factory = ServiceFactory()
|
||||
// factory.someService is a method with signature `() -> Service`, Cmd-Click to see definition
|
||||
container.register(factory: factory.someService)
|
||||
|
||||
/*:
|
||||
Optionally you can associate definitions with Integer or String tags. This way you can register different implementations for the same protocol.
|
||||
You can use `DependencyContainer.Tag` enum, String or Integer literals, or instances of types that conform to `DependencyTagConvertible` protocol.
|
||||
*/
|
||||
|
||||
container.register(tag: "tag") { ServiceImp1() as Service }
|
||||
container.register(tag: .Int(0)) { ServiceImp1() as Service }
|
||||
|
||||
enum MyCustomTag: String, DependencyTagConvertible {
|
||||
case SomeTag
|
||||
}
|
||||
|
||||
container.register(tag: MyCustomTag.SomeTag) { ServiceImp1() as Service }
|
||||
|
||||
/*:
|
||||
We recommand you to use constants for the tags, to make the intent clear and avoid magic numbers and typos.
|
||||
|
||||
You can remove all registered definitions or register and remove them one by one:
|
||||
*/
|
||||
|
||||
let serviceDefinition = container.register { ServiceImp1() as Service }
|
||||
container
|
||||
container.remove(serviceDefinition)
|
||||
|
||||
container.reset()
|
||||
|
||||
//: [Next: Resolving Components](@next)
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,47 @@
|
||||
//: [Previous: Registering Components](@previous)
|
||||
|
||||
import Dip
|
||||
let container = DependencyContainer { container in
|
||||
container.register { ServiceImp1() as Service }
|
||||
}
|
||||
|
||||
/*:
|
||||
|
||||
### Resolving components
|
||||
|
||||
You resolve previously registered definition using `resolve` method:
|
||||
*/
|
||||
|
||||
var service = try! container.resolve() as Service
|
||||
|
||||
/*:
|
||||
That code says that you want your `container` to give you an instance that was registered as implementation of `Service` protocol.
|
||||
|
||||
It's important to specify the same type that you used for registration. You can use either `as` syntax, or specify type of you variable when you define it:
|
||||
*/
|
||||
|
||||
let otherService: Service = try! container.resolve()
|
||||
|
||||
/*:
|
||||
Both ways will let the `container` detect the type that you want to resolve as. We prefer the `as` syntax because it reads more naturally in Swift.
|
||||
|
||||
If you used a tag to register your component, you can use the same tag to resolve it. If there is no definition with such tag, the `container` will try to find a definition for the same type with no tag (`nil` tag), and resolve it instead, allowing you to provide default components in such cases.
|
||||
*/
|
||||
|
||||
container.register(tag: "production") { ServiceImp1() as Service }
|
||||
container.register(tag: "test") { ServiceImp2() as Service }
|
||||
|
||||
// Will give you a ServiceImp1 instance
|
||||
let productionService = try! container.resolve(tag: "production") as Service
|
||||
// Will give you a ServiceImp2 instance
|
||||
let testService = try! container.resolve(tag: "test") as Service
|
||||
// Will give you a ServiceImp1 because one was registered without a tag on line 4
|
||||
let defaultService = try! container.resolve() as Service
|
||||
|
||||
/*:
|
||||
You can use runtime arguments to resolve components. Dip supports up to six arguments. For more details see ["Runtime arguments"](Runtime%20arguments).
|
||||
*/
|
||||
container.register { service in ClientImp1(service: service) as Client }
|
||||
let client = try! container.resolve(withArguments: service) as Client
|
||||
|
||||
//: [Next: Runtime Arguments](@next)
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,51 @@
|
||||
//: [Previous: Resolving Components](@previous)
|
||||
|
||||
import Dip
|
||||
|
||||
let container = DependencyContainer()
|
||||
|
||||
/*:
|
||||
|
||||
### Runtime arguments
|
||||
|
||||
Dip lets you use runtime arguments to register and resolve your components.
|
||||
Note that __types__, __number__ and __order__ of arguments matters and you can register different factories with different set of runtime arguments for the same protocol. To resolve using one of this factory you will need to pass runtime arguments of the same types, number and in the same order to `resolve` as you used in `register` method.
|
||||
*/
|
||||
|
||||
container.register { (url: NSURL, port: Int) in ServiceImp4(name: "1", baseURL: url, port: port) as Service }
|
||||
container.register { (port: Int, url: NSURL) in ServiceImp4(name: "2", baseURL: url, port: port) as Service }
|
||||
container.register { (port: Int, url: NSURL?) in ServiceImp4(name: "3", baseURL: url!, port: port) as Service }
|
||||
container.register { (port: Int, url: NSURL!) in ServiceImp4(name: "4", baseURL: url, port: port) as Service }
|
||||
|
||||
let url: NSURL = NSURL(string: "http://example.com")!
|
||||
let service1 = try! container.resolve(withArguments: url, 80) as Service
|
||||
let service2 = try! container.resolve(withArguments: 80, url) as Service
|
||||
let service3 = try! container.resolve(withArguments: 80, NSURL(string: "http://example.com")) as Service
|
||||
let service4 = try! container.resolve(withArguments: 80, NSURL(string: "http://example.com")! as NSURL!) as Service
|
||||
|
||||
(service1 as! ServiceImp4).name
|
||||
(service2 as! ServiceImp4).name
|
||||
(service3 as! ServiceImp4).name
|
||||
(service4 as! ServiceImp4).name
|
||||
|
||||
/*:
|
||||
Note that all of the services were resolved using different factories.
|
||||
|
||||
_Dip_ supports up to six runtime arguments. If that is not enougth you can extend `DependencyContainer` to accept more arguments. For example, here is how you can extend it to serve seven arguments.
|
||||
*/
|
||||
|
||||
extension DependencyContainer {
|
||||
public func register<T, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(tag tag: Tag? = nil, _ scope: ComponentScope = .Prototype, factory: (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) throws -> T) -> DefinitionOf<T, (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) throws -> T> {
|
||||
return registerFactory(tag: tag, scope: scope, factory: factory)
|
||||
}
|
||||
|
||||
public func resolve<T, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7>(tag tag: Tag? = nil, _ arg1: Arg1, _ arg2: Arg2, _ arg3: Arg3, _ arg4: Arg4, _ arg5: Arg5, _ arg6: Arg6, _ arg7: Arg7) throws -> T {
|
||||
return try resolve(tag: tag) { (factory: (Arg1, Arg2, Arg3, Arg4, Arg5, Arg6, Arg7) throws -> T) in try factory(arg1, arg2, arg3, arg4, arg5, arg6, arg7) }
|
||||
}
|
||||
}
|
||||
|
||||
/*:
|
||||
However, if you find yourself thinking about adding more runtime arguments, stop and think about your design instead. Having too many dependencies could be a sign of some problem in your architecture, so we strongly suggest that you refrain from doing so; six runtime arguments is already a lot.
|
||||
*/
|
||||
|
||||
//: [Next: Scopes](@next)
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,66 @@
|
||||
//: [Previous: Runtime Arguments](@previous)
|
||||
|
||||
import Dip
|
||||
|
||||
let container = DependencyContainer()
|
||||
|
||||
/*:
|
||||
|
||||
### Scopes
|
||||
|
||||
Dip supports three different scopes of objects: _Prototype_, _ObjectGraph_ and _Singleton_.
|
||||
|
||||
* The `.Prototype` scope will make the `DependencyContainer` resolve your type as __a new instance every time__ you call `resolve`. This is the default scope.
|
||||
* The `.ObjectGraph` scope is like `.Prototype` scope, but it will make the `DependencyContainer` to reuse resolved instances during one (recursive) call to `resolve` method. When this call returns, all resolved instances will be discarded and next call to `resolve` will produce new instances. This scope should be used to resolve [circular dependencies](Circular%20dependencies).
|
||||
* The `.Singleton` scope will make the `DependencyContainer` retain the instance once resolved the first time, and reuse it in the next calls to `resolve` during the container lifetime.
|
||||
* The `.EagerSingleton` scope is the same as `.Singleton` scope but instances with this cope will be created when you call `bootstrap()` method on the container.
|
||||
|
||||
The `.Prototype` scope is the default. To set a scope you pass it as an argument to `register` method.
|
||||
*/
|
||||
|
||||
container.register { ServiceImp1() as Service }
|
||||
container.register(tag: "prototype", .Prototype) { ServiceImp1() as Service }
|
||||
container.register(tag: "object graph", .ObjectGraph) { ServiceImp2() as Service }
|
||||
container.register(tag: "shared instance", .Singleton) { ServiceImp3() as Service }
|
||||
|
||||
let service = try! container.resolve() as Service
|
||||
let anotherService = try! container.resolve() as Service
|
||||
// They are different instances as the scope defaults to .Prototype
|
||||
service as! ServiceImp1 === anotherService as! ServiceImp1 // false
|
||||
|
||||
let prototypeService = try! container.resolve(tag: "prototype") as Service
|
||||
let anotherPrototypeService = try! container.resolve(tag: "prototype") as Service
|
||||
// They are different instances:
|
||||
prototypeService as! ServiceImp1 === anotherPrototypeService as! ServiceImp1 // false
|
||||
|
||||
let graphService = try! container.resolve(tag: "object graph") as Service
|
||||
let anotherGraphService = try! container.resolve(tag: "object graph") as Service
|
||||
// still different instances — the ObjectGraph scope only keep instances during one (recursive) resolution call,
|
||||
// so the two calls on the two lines above are different calls and use different instances
|
||||
graphService as! ServiceImp2 === anotherGraphService as! ServiceImp2 // false
|
||||
|
||||
let sharedService = try! container.resolve(tag: "shared instance") as Service
|
||||
let sameSharedService = try! container.resolve(tag: "shared instance") as Service
|
||||
// same instances, the singleton scope keep and reuse instances during the lifetime of the container
|
||||
sharedService as! ServiceImp3 === sameSharedService as! ServiceImp3
|
||||
|
||||
/*:
|
||||
### Bootstrapping
|
||||
|
||||
You can use `bootstrap()` method to fix your container setup and initialise components registered with `EagerSingleton` scope.
|
||||
After bootstrapping if you try to add or remove any definition it will cause runtime exception. Call `boostrap` when you registered all the components, for example at the end of initialization block if you use `init(configBlock:)`.
|
||||
*/
|
||||
|
||||
var resolvedEagerSingleton = false
|
||||
let definition = container.register(tag: "eager shared instance", .EagerSingleton) { ServiceImp1() as Service }
|
||||
.resolveDependencies { _ in resolvedEagerSingleton = true }
|
||||
|
||||
try! container.bootstrap()
|
||||
resolvedEagerSingleton
|
||||
|
||||
let eagerSharedService = try! container.resolve(tag: "eager shared instance") as Service
|
||||
|
||||
container.remove(definition)
|
||||
|
||||
//: [Next: Circular Dependencies](@next)
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
//: [Previous: Circular Dependencies](@previous)
|
||||
|
||||
import Dip
|
||||
import UIKit
|
||||
|
||||
/*:
|
||||
### Shared Instances
|
||||
|
||||
The Singleton pattern is probably the most debatable and abused pattern in Cocoa development (and probably in programming in general). It's probably the first thing that you will hear from a candidate developer on interview when you ask about Cocoa patterns (the other one will be a delegate).
|
||||
|
||||
The problem with singleton is not that it's a worst pattern. The problem is that developers use it to solve problems that do not require it at all. Another problem is that it's very easy to be tempted by this pattern cause it's very easy to implement and use - import file and call `sharedInstance`. But that leads to all kinds of problems:
|
||||
|
||||
- First - singleton is a shared mutable state. And the worst thing is that it's a _mutable_ state.
|
||||
- Second - singleton tigthly couple components of your system.
|
||||
- Third - it limits your code flexibility.
|
||||
|
||||
Dip supports singletons, but it reduces cost of using them. Their singleton nature is managed by the _Container_ and defined only by the _Definitions_ that you register, not by concrete implementations of your classes.
|
||||
|
||||
- No need for calls to `sharedInstance` in your code anymore. Instead you get the instance from the _Container_ by resolving a protocol.
|
||||
- You can easyly change concrete implementations without the rest of your system even notice that something changed.
|
||||
- Also it's easy to test - you just register another object in your tests. Even if you still want to use a singleton in your system.
|
||||
|
||||
Those features you got when using Dip limits tight coupling in your code and gives you back your code flexibility.
|
||||
|
||||
Probably the most common example is using a singleton in the network layer or "API client".
|
||||
*/
|
||||
|
||||
class ApiClientSingleton {
|
||||
static let sharedInstance = ApiClientSingleton()
|
||||
private init() {}
|
||||
// Typically a method that makes a GET request on your API
|
||||
func get(path: String, completion:()->()) {}
|
||||
}
|
||||
|
||||
class MyViewControllerWithSingleton: UIViewController {
|
||||
override func viewDidAppear(amimated: Bool) {
|
||||
super.viewDidAppear(amimated)
|
||||
ApiClientSingleton.sharedInstance.get("/users") { /* refresh your UI */ }
|
||||
}
|
||||
}
|
||||
|
||||
/*:
|
||||
Sure, this is very easy to code indeed. And nothing bad so far.
|
||||
|
||||
But probably if you wrote a unit test or integration test for that code first, you would have noticed a problem earilier. How you test that code? And how you ensure that your tests are idenpendent of the API client's state from the previous test?
|
||||
Of cource you can work around all of the problems and the fact that `ApiClient` is a singleton, reset it's state somehow, or mock a class so that it will not return a singleton instance. But look - a moment before the singleton was your best friend and now you are fighting against it.
|
||||
|
||||
Think - why do you want API client to be a singleton in a first place? To queue or throttle requests? Then do your queue or throttler a singleton, not an API client. Or is there any other reason. Most likely API client itself does not have a requirement to have one and only one instance during the lifecycle of your application. Imagine that in the future we need two API Clients, because you now have to address two different servers & plaforms? Imposing that singleton restricts now your flexibility a lot.
|
||||
|
||||
Instead, inject API client in view controller with property injection or constructor injection.
|
||||
*/
|
||||
|
||||
protocol ApiClientProtocol {
|
||||
func get(path: String, completion:()->())
|
||||
}
|
||||
|
||||
class ApiClient: ApiClientProtocol {
|
||||
|
||||
private struct ApiScheduler {
|
||||
/* … */
|
||||
}
|
||||
|
||||
private let scheduler = ApiScheduler()
|
||||
|
||||
init(){}
|
||||
|
||||
func get(path: String, completion:()->()) {}
|
||||
}
|
||||
|
||||
class MyViewController: UIViewController {
|
||||
var apiClient: ApiClientProtocol!
|
||||
|
||||
override func viewDidAppear(amimated: Bool) {
|
||||
super.viewDidAppear(amimated)
|
||||
apiClient.get("path") {}
|
||||
}
|
||||
|
||||
convenience init(apiClient: ApiClientProtocol) {
|
||||
self.init()
|
||||
self.apiClient = apiClient
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
//inject with constructor
|
||||
let viewController = MyViewController(apiClient: ApiClient())
|
||||
//or with property
|
||||
viewController.apiClient = ApiClient()
|
||||
|
||||
/*:
|
||||
With Dip this code can look like this:
|
||||
*/
|
||||
|
||||
let container = DependencyContainer { container in
|
||||
container.register { ApiClient() as ApiClientProtocol }
|
||||
}
|
||||
|
||||
class DipViewController: UIViewController {
|
||||
var apiClient: ApiClientProtocol!
|
||||
|
||||
override func viewDidAppear(amimated: Bool) {
|
||||
super.viewDidAppear(amimated)
|
||||
apiClient.get("path") {}
|
||||
}
|
||||
|
||||
convenience init(dependencies: DependencyContainer) {
|
||||
self.init()
|
||||
self.apiClient = try! dependencies.resolve() as ApiClientProtocol
|
||||
}
|
||||
|
||||
init() {
|
||||
super.init(nibName: nil, bundle: nil)
|
||||
}
|
||||
|
||||
required init?(coder aDecoder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
var dipController = DipViewController(dependencies: container)
|
||||
|
||||
/*:
|
||||
Of cource `DependencyContainer` should not be a singleton too. Instead, inject it to objects that need to access it. And use a protocol for that. For example if your view controller needs to access API client, it does not need a reference to `DependencyContainer`, it only needs a reference to _something_ that can provide it an API client instance.
|
||||
*/
|
||||
|
||||
protocol ApiClientProvider {
|
||||
func apiClient() -> ApiClientProtocol
|
||||
}
|
||||
|
||||
extension DependencyContainer: ApiClientProvider {
|
||||
func apiClient() -> ApiClientProtocol {
|
||||
return try! self.resolve() as ApiClientProtocol
|
||||
}
|
||||
}
|
||||
|
||||
extension DipViewController {
|
||||
convenience init(apiClientProvider: ApiClientProvider) {
|
||||
self.init()
|
||||
self.apiClient = apiClientProvider.apiClient()
|
||||
}
|
||||
}
|
||||
|
||||
dipController = DipViewController(apiClientProvider: container)
|
||||
|
||||
/*:
|
||||
This way you also does not depend directly on Dip. Instead you provide a boundary between Dip — that you don't have control of — and your source code. So when something chagnes in Dip, you update only the boundary code.
|
||||
|
||||
Dependency Injection is a pattern (more precisely - a set of patterns) as well as a singleton. And any pattern can be abused. DI can be used in a [wrong way]((http://www.loosecouplings.com/2011/01/dependency-injection-using-di-container.html)), container can easily become a [service locator](http://blog.ploeh.dk/2010/02/03/ServiceLocatorisanAnti-Pattern/). You should carefully decide when to use DI, you should not inject everything and everywhere and define a protocol for every single class you use. For every tool there is a right time and the same way as singleton can harm you the same way DI and protocols abuse can make your code unnececerry complex.
|
||||
|
||||
If you want to know more about Dependency Injection in general we recomend you to read ["Dependency Injection in .Net" by Mark Seemann](https://www.manning.com/books/dependency-injection-in-dot-net). Dip was inspired by implementations of IoC container for .Net platform and shares core principles described in that book.
|
||||
|
||||
*/
|
||||
|
||||
//: [Next: Auto-wiring](@next)
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,70 @@
|
||||
//: [Previous: Shared Instances](@previous)
|
||||
|
||||
|
||||
/*:
|
||||
|
||||
### Testing
|
||||
|
||||
Dip is convenient to use for testing. Here is s simple example of how you can write tests with Dip.
|
||||
|
||||
__Note__: That's a very simple example just to demostrate use of Dip in tests, not how you should or should not tests your code in general.
|
||||
You can learn more about testing based on state verification vs behavior verification [here](http://martinfowler.com/articles/mocksArentStubs.html).
|
||||
|
||||
*/
|
||||
|
||||
protocol Service {
|
||||
func doSomething()
|
||||
}
|
||||
|
||||
class Client {
|
||||
var service: Service!
|
||||
|
||||
func callService() {
|
||||
service.doSomething()
|
||||
}
|
||||
}
|
||||
|
||||
import XCTest
|
||||
import Dip
|
||||
|
||||
/*:
|
||||
Instead of the real `Service` implementation, provide a _fake_ implementation with test hooks that you need:
|
||||
*/
|
||||
|
||||
class FakeService: Service {
|
||||
var doSomethingCalled = false
|
||||
|
||||
func doSomething() {
|
||||
doSomethingCalled = true
|
||||
}
|
||||
|
||||
init() {}
|
||||
}
|
||||
|
||||
class MyTests: XCTestCase {
|
||||
var container: DependencyContainer!
|
||||
|
||||
override func setUp() {
|
||||
super.setUp()
|
||||
|
||||
/*:
|
||||
Register fake implementation as `Service`:
|
||||
*/
|
||||
container = DependencyContainer { container in
|
||||
container.register { FakeService() as Service }
|
||||
}
|
||||
}
|
||||
|
||||
func testThatDoSomethingIsCalled() {
|
||||
let sut = Client()
|
||||
sut.service = try! container.resolve() as Service
|
||||
|
||||
sut.callService()
|
||||
|
||||
/*:
|
||||
And finally you test it was called:
|
||||
*/
|
||||
XCTAssertTrue((sut.service as! FakeService).doSomethingCalled)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,24 @@
|
||||
/*:
|
||||
__Note__: _This playground needs to be open as part of the `Dip.xcworkspace` so it can import the Dip framework / module and demonstrate its usage. (The playground won't work properly if you open it on its own)._
|
||||
|
||||
_You might also need to ask Xcode to build the Dip framework first (Command-B) before it can find and import it in this playground._
|
||||
*/
|
||||
|
||||
/*:
|
||||
## What is Dip?
|
||||
|
||||
_Dip_ is a lightweight Swift implementation of [IoC container](https://en.wikipedia.org/wiki/Inversion_of_control).
|
||||
|
||||
If you follow [Protocol-Oriented programming](https://developer.apple.com/videos/play/wwdc2015-408/) or [SOLID principles](http://butunclebob.com/ArticleS.UncleBob.PrinciplesOfOod) then instead of concrete classes you should use protocols to define dependencies between components of your system. I.e. if you need to access some network API, you should use instances of an `APIClient` protocol instead of instances of a concrete class `APIClientImp`.
|
||||
|
||||
[Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) is a good tool to leverage Protocol-Oriented or SOLID design. Using this principle, you move the point where you create concrete instances _from inside objects_ that use them, _to higher levels_ of your system. **Now your objects do not depend on concrete implementations of their dependencies**, they depend **only on their public interfaces**, defined by protocols that they implement. That gives you all sorts of advantages from **easier testability** to **greater flexibility** of your system.
|
||||
|
||||
But still there should be some point in your program where concrete instances are created. The thing is that it's better to have one well defined point for that than to scatter setup logic all over the place with different factories and lazy properties. IoC containers like _Dip_ play the role of that point.
|
||||
|
||||
The following pages in this Playground demonstrates how to use _Dip_ to adopt all those concepts in practice.
|
||||
|
||||
If you want to know more about Dependency Injection in general we recomend you to read ["Dependency Injection in .Net" by Mark Seemann](https://www.manning.com/books/dependency-injection-in-dot-net). Dip was inspired by implementations of IoC container for .Net platform and shares core principles described in that book.
|
||||
|
||||
*/
|
||||
//: [Next: Creating a DependencyContainer](@next)
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Timeline
|
||||
version = "3.0">
|
||||
<TimelineItems>
|
||||
</TimelineItems>
|
||||
</Timeline>
|
||||
@@ -0,0 +1,78 @@
|
||||
import Foundation
|
||||
|
||||
public protocol Service {}
|
||||
|
||||
public class ServiceImp1: Service {
|
||||
public init() {}
|
||||
}
|
||||
public class ServiceImp2: Service {
|
||||
public init() {}
|
||||
}
|
||||
public class ServiceImp3: Service {
|
||||
public init() {}
|
||||
}
|
||||
|
||||
public class ServiceImp4: Service {
|
||||
|
||||
public let name: String
|
||||
|
||||
public init(name: String, baseURL: NSURL, port: Int) {
|
||||
self.name = name
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public protocol Client: class {
|
||||
var service: Service {get}
|
||||
init(service: Service)
|
||||
}
|
||||
public class ClientImp1: Client {
|
||||
public var service: Service
|
||||
public required init(service: Service) {
|
||||
self.service = service
|
||||
}
|
||||
}
|
||||
|
||||
public class ClientImp2: Client {
|
||||
public var service: Service
|
||||
public required init(service: Service) {
|
||||
self.service = service
|
||||
}
|
||||
}
|
||||
|
||||
public class ServiceFactory {
|
||||
public init() {}
|
||||
|
||||
public func someService() -> Service {
|
||||
return ServiceImp1()
|
||||
}
|
||||
}
|
||||
|
||||
public class ClientServiceImp: Service {
|
||||
public weak var client: Client?
|
||||
public init() {}
|
||||
}
|
||||
|
||||
public protocol Logger {}
|
||||
public protocol Tracker {}
|
||||
public protocol DataProvider {}
|
||||
public protocol Router {}
|
||||
|
||||
public class LoggerImp: Logger {
|
||||
public init() {}
|
||||
}
|
||||
|
||||
public class TrackerImp: Tracker {
|
||||
public init() {}
|
||||
}
|
||||
|
||||
public class RouterImp: Router {
|
||||
public init() {}
|
||||
}
|
||||
|
||||
public class DataProviderImp: DataProvider {
|
||||
public init() {}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<playground version='6.0' target-platform='ios' display-mode='rendered'>
|
||||
<pages>
|
||||
<page name='What is Dip?'/>
|
||||
<page name='Creating container'/>
|
||||
<page name='Registering components'/>
|
||||
<page name='Resolving components'/>
|
||||
<page name='Runtime arguments'/>
|
||||
<page name='Scopes'/>
|
||||
<page name='Circular dependencies'/>
|
||||
<page name='Shared Instances'/>
|
||||
<page name='Auto-wiring'/>
|
||||
<page name='Auto-injection'/>
|
||||
<page name='Testing'/>
|
||||
</pages>
|
||||
</playground>
|
||||
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
</Workspace>
|
||||
@@ -1,10 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Workspace
|
||||
version = "1.0">
|
||||
<FileRef
|
||||
location = "group:Dip.xcodeproj">
|
||||
</FileRef>
|
||||
<FileRef
|
||||
location = "group:Pods/Pods.xcodeproj">
|
||||
</FileRef>
|
||||
</Workspace>
|
||||
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>IDEWorkspaceSharedSettings_AutocreateContextsIfNeeded</key>
|
||||
<false/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,59 +0,0 @@
|
||||
//
|
||||
// DependencyContainers.swift
|
||||
// Dip
|
||||
//
|
||||
// Created by Olivier Halligon on 10/10/2015.
|
||||
// Copyright © 2015 AliSoftware. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import Dip
|
||||
|
||||
// MARK: Configuration
|
||||
|
||||
/* Change this to toggle between real and fake data */
|
||||
private let FAKE_PERSONS = false
|
||||
private let FAKE_STARSHIPS = false
|
||||
/* ---- */
|
||||
|
||||
|
||||
|
||||
// MARK: Dependency Container for WebServices & NetworkLayer
|
||||
let wsDependencies = DependencyContainer() { dip in
|
||||
|
||||
// Register the NetworkLayer, same for everyone here (but we have the ability to register a different one for a specific WebService if we wanted to)
|
||||
dip.register(instance: URLSessionNetworkLayer(baseURL: "http://swapi.co/api/")! as NetworkLayer)
|
||||
|
||||
}
|
||||
|
||||
|
||||
// MARK: Dependency Container for Providers
|
||||
let providerDependencies = DependencyContainer() { dip in
|
||||
|
||||
if FAKE_PERSONS {
|
||||
|
||||
// 1) Register the PersonProviderAPI singleton, one generic and one specific for a specific personID
|
||||
dip.register(instance: DummyPilotProvider() as PersonProviderAPI)
|
||||
dip.register(0, instance: PlistPersonProvider(plist: "mainPilot") as PersonProviderAPI)
|
||||
|
||||
} else {
|
||||
|
||||
// 1) Register the SWAPIPersonProvider (that hits the real swapi.co WebService)
|
||||
dip.register(instance: SWAPIPersonProvider() as PersonProviderAPI)
|
||||
|
||||
}
|
||||
|
||||
if FAKE_STARSHIPS {
|
||||
|
||||
// 2) Register the StarshipProviderAPI factories, one generic and one specific for a specific starshipID
|
||||
dip.register() { HardCodedStarshipProvider() as StarshipProviderAPI }
|
||||
dip.register(0) { DummyStarshipProvider(pilotName: "Main Pilot") as StarshipProviderAPI }
|
||||
|
||||
} else {
|
||||
|
||||
// 2) Register the SWAPIStarshipProvider (that hits the real swapi.co WebService)
|
||||
dip.register(instance: SWAPIStarshipProvider() as StarshipProviderAPI)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// DummyPilotProvider.swift
|
||||
// Dip
|
||||
//
|
||||
// Created by Olivier Halligon on 12/09/2015.
|
||||
// Copyright © 2015 AliSoftware. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct DummyPilotProvider : PersonProviderAPI {
|
||||
|
||||
func fetchIDs(completion: [Int] -> Void) {
|
||||
completion(Array(0..<5))
|
||||
}
|
||||
|
||||
func fetch(id: Int, completion: Person? -> Void) {
|
||||
completion(dummyPerson(id))
|
||||
}
|
||||
|
||||
private func dummyPerson(idx: Int) -> Person {
|
||||
let colors = ["blue", "brown", "yellow", "orange", "red", "dark"]
|
||||
let genders: [Gender?] = [Gender.Male, Gender.Female, nil]
|
||||
return Person(
|
||||
name: "John Dummy Doe #\(idx)",
|
||||
height: 150 + (idx*27%40),
|
||||
mass: 50 + (idx*7%30),
|
||||
hairColor: colors[idx*3%colors.count],
|
||||
eyeColor: colors[idx*2%colors.count],
|
||||
gender: genders[idx%3],
|
||||
starshipIDs: [idx % 3, 2*idx % 4]
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
//
|
||||
// DummyStarshipProvider.swift
|
||||
// Dip
|
||||
//
|
||||
// Created by Olivier Halligon on 08/10/2015.
|
||||
// Copyright © 2015 AliSoftware. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
struct DummyStarshipProvider : StarshipProviderAPI {
|
||||
var pilotName: String
|
||||
|
||||
func fetchIDs(completion: [Int] -> Void) {
|
||||
let nbShips = pilotName.characters.count
|
||||
completion(Array(0..<nbShips))
|
||||
}
|
||||
|
||||
func fetch(id: Int, completion: Starship? -> Void) {
|
||||
completion(dummyStarship(id))
|
||||
}
|
||||
|
||||
private func dummyStarship(idx: Int) -> Starship {
|
||||
return Starship(
|
||||
name: "\(pilotName)'s awesome starship #\(idx)",
|
||||
model: "\(pilotName)Ship",
|
||||
manufacturer: "Dummy Industries",
|
||||
crew: 1 + (idx%3),
|
||||
passengers: 10 + (idx*7 % 40),
|
||||
pilotIDs: [idx]
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
//
|
||||
// HardCodedStarshipProvider.swift
|
||||
// Dip
|
||||
//
|
||||
// Created by Olivier Halligon on 11/09/2015.
|
||||
// Copyright © 2015 AliSoftware. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
class HardCodedStarshipProvider : StarshipProviderAPI {
|
||||
|
||||
let starships = [
|
||||
Starship(name: "First Ship", model: "AwesomeShip", manufacturer: "HardCoded Inc.", crew: 3, passengers: 20, pilotIDs: [1,2]),
|
||||
Starship(name: "Second Ship", model: "AwesomeShip Express", manufacturer: "HardCoded Inc.", crew: 4, passengers: 10, pilotIDs: [1]),
|
||||
Starship(name: "Third Ship", model: "AwesomeShip Cargo", manufacturer: "HardCoded Inc.", crew: 12, passengers: 150, pilotIDs: [2]),
|
||||
] + Array(4..<75).map { Starship(name: "Ship #\($0)", model: "AwesomeShip Fighter", manufacturer: "HardCoded Inc.", crew: 1, passengers: 2, pilotIDs: [1]) }
|
||||
|
||||
func fetchIDs(completion: [Int] -> Void) {
|
||||
completion(Array(0..<starships.count))
|
||||
}
|
||||
|
||||
func fetch(id: Int, completion: Starship? -> Void) {
|
||||
guard id < starships.count else {
|
||||
completion(nil)
|
||||
return
|
||||
}
|
||||
completion(starships[id])
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
source 'https://github.com/CocoaPods/Specs.git'
|
||||
|
||||
use_frameworks!
|
||||
platform :ios, '8.0'
|
||||
|
||||
target 'DipSampleApp' do
|
||||
pod 'Dip', :path => '../'
|
||||
end
|
||||
|
||||
target 'DipTests' do
|
||||
pod "Dip", :path => '../'
|
||||
end
|
||||
@@ -1,14 +0,0 @@
|
||||
PODS:
|
||||
- Dip (2.0.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- Dip (from `../`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Dip:
|
||||
:path: ../
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Dip: ae784a32e584d5c57809b2cdc4fd2f287d075f7a
|
||||
|
||||
COCOAPODS: 0.39.0
|
||||
@@ -1,21 +0,0 @@
|
||||
{
|
||||
"name": "Dip",
|
||||
"version": "2.0.0",
|
||||
"summary": "A simple Dependency Resolver: Dependency Injection using Protocol resolution.",
|
||||
"description": "Dip is a Swift framework to manage your Dependencies between your classes\nin your app using Dependency Injection.\n\nIt's aimed to be very simple to use while improving testability\nof your app by allowing you to get rid of those sharedInstances and instead\ninject values based on protocol resolution.\n\nDefine your API using a protocol, then ask Dip to resolve this protocol into\nan instance dynamically in your classes. Then your App and your Tests can be\nconfigured to resolve the protocol using a different instance or class so this\nimprove testability by decoupling the API and the concrete class used to implement it.",
|
||||
"homepage": "https://github.com/AliSoftware/Dip",
|
||||
"license": "MIT",
|
||||
"authors": {
|
||||
"Olivier Halligon": "olivier@halligon.net"
|
||||
},
|
||||
"source": {
|
||||
"git": "https://github.com/AliSoftware/Dip.git",
|
||||
"tag": "2.0.0"
|
||||
},
|
||||
"social_media_url": "https://twitter.com/aligatr",
|
||||
"platforms": {
|
||||
"ios": "8.0"
|
||||
},
|
||||
"requires_arc": true,
|
||||
"source_files": "Sources/**/*"
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
PODS:
|
||||
- Dip (2.0.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- Dip (from `../`)
|
||||
|
||||
EXTERNAL SOURCES:
|
||||
Dip:
|
||||
:path: ../
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Dip: ae784a32e584d5c57809b2cdc4fd2f287d075f7a
|
||||
|
||||
COCOAPODS: 0.39.0
|
||||
@@ -1,671 +0,0 @@
|
||||
// !$*UTF8*$!
|
||||
{
|
||||
archiveVersion = 1;
|
||||
classes = {
|
||||
};
|
||||
objectVersion = 46;
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
233F81BF5C5FCE081EE3E4963D0B28CD /* Pods-DipSampleApp-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 6DC6F865EBD27FE4416E8655E73F7426 /* Pods-DipSampleApp-dummy.m */; };
|
||||
3E5EF2244E6759BDB00BF6F862FFAD43 /* Dip-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 98D1A0DC92D3A4A2B32D1B6094DECDA3 /* Dip-dummy.m */; };
|
||||
598949CC3DD0DD2142DFA9759D331DB6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */; };
|
||||
73DFA9D2D6721ED2BF48E815083FC935 /* Dip.swift in Sources */ = {isa = PBXBuildFile; fileRef = D1855646D8AC0B232E538D845A7894FF /* Dip.swift */; };
|
||||
774AC175C524A1E16D01BB9CF19651ED /* Pods-DipTests-dummy.m in Sources */ = {isa = PBXBuildFile; fileRef = 08FDAF80E63D5379C5D67B2C5D37CB44 /* Pods-DipTests-dummy.m */; };
|
||||
8FB62E6448665FAB1B4B40278A9C18B3 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */; };
|
||||
92915F15583230B1CF7E9FAB6FFD5817 /* Dip-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 9F68496928C5CF49172AFF11B37314C7 /* Dip-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
CE06FE77C65C0BE8BDD6AFB33EAD328F /* Pods-DipSampleApp-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = ACEDE7C6DC726F30DC3F36A7ECD7A8C2 /* Pods-DipSampleApp-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
DF187AAE55CEA68761E21B080E2C2CF2 /* Pods-DipTests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 88B21BAF0A10E4BCDFF1F69039F04287 /* Pods-DipTests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
F8D681A620B7540C44E9B51BD381C514 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
62848E69B71441AB05941E7E2F09E1D8 /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 28230D259635091F92F106AA282AA138;
|
||||
remoteInfo = Dip;
|
||||
};
|
||||
F9BC91C90262AF7A128076332A48985F /* PBXContainerItemProxy */ = {
|
||||
isa = PBXContainerItemProxy;
|
||||
containerPortal = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
|
||||
proxyType = 1;
|
||||
remoteGlobalIDString = 28230D259635091F92F106AA282AA138;
|
||||
remoteInfo = Dip;
|
||||
};
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
040E6767354650F6353098E4EB50B3F7 /* Pods-DipSampleApp.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-DipSampleApp.modulemap"; sourceTree = "<group>"; };
|
||||
08FDAF80E63D5379C5D67B2C5D37CB44 /* Pods-DipTests-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-DipTests-dummy.m"; sourceTree = "<group>"; };
|
||||
093DB70F67DB4E609AB442CBB509D4E7 /* Pods-DipTests-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-DipTests-resources.sh"; sourceTree = "<group>"; };
|
||||
2F6C88DA4612709E46E6E64B8DE3DF7B /* Pods-DipTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-DipTests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
3BFEC463C4346DFBB40CFD331E7B8C8C /* Pods-DipSampleApp-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-DipSampleApp-acknowledgements.plist"; sourceTree = "<group>"; };
|
||||
3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.0.sdk/System/Library/Frameworks/Foundation.framework; sourceTree = DEVELOPER_DIR; };
|
||||
4AC7412F56C556428F0902BDB2B9CC74 /* Pods-DipSampleApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-DipSampleApp.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
4D03528B91AE7D78A28CE55BADFA6159 /* Pods-DipTests-acknowledgements.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = "Pods-DipTests-acknowledgements.plist"; sourceTree = "<group>"; };
|
||||
53E603F956BC0848C3DC16E858DAA805 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
551D96FB45D8D47702C68C545344BB55 /* Dip-prefix.pch */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Dip-prefix.pch"; sourceTree = "<group>"; };
|
||||
6418C112ABDD19D3EF1DD98DB3019F05 /* Pods_DipTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DipTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
6DC6F865EBD27FE4416E8655E73F7426 /* Pods-DipSampleApp-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Pods-DipSampleApp-dummy.m"; sourceTree = "<group>"; };
|
||||
88B21BAF0A10E4BCDFF1F69039F04287 /* Pods-DipTests-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-DipTests-umbrella.h"; sourceTree = "<group>"; };
|
||||
8A5334FC48EF0DBABDE182FB6C1E6C3D /* Pods_DipSampleApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DipSampleApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
98D1A0DC92D3A4A2B32D1B6094DECDA3 /* Dip-dummy.m */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.objc; path = "Dip-dummy.m"; sourceTree = "<group>"; };
|
||||
9F68496928C5CF49172AFF11B37314C7 /* Dip-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Dip-umbrella.h"; sourceTree = "<group>"; };
|
||||
A37235974396D8B3A4A2163B9FAF0328 /* Pods-DipSampleApp-resources.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-DipSampleApp-resources.sh"; sourceTree = "<group>"; };
|
||||
ACEDE7C6DC726F30DC3F36A7ECD7A8C2 /* Pods-DipSampleApp-umbrella.h */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.c.h; path = "Pods-DipSampleApp-umbrella.h"; sourceTree = "<group>"; };
|
||||
AF0EA8CE3EB9D052ABA91BBDF5935932 /* Pods-DipSampleApp-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-DipSampleApp-frameworks.sh"; sourceTree = "<group>"; };
|
||||
B13AB9998F2CB1AA813B9AB7A6851FBA /* Pods-DipTests-frameworks.sh */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.script.sh; path = "Pods-DipTests-frameworks.sh"; sourceTree = "<group>"; };
|
||||
BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Podfile; path = ../Podfile; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
|
||||
BDD421F6E0B38080BCB472073DA141EF /* Dip.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = Dip.modulemap; sourceTree = "<group>"; };
|
||||
C9D3BEDF370AEED8CE8D3838C4F8BCB1 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
D1855646D8AC0B232E538D845A7894FF /* Dip.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = Dip.swift; sourceTree = "<group>"; };
|
||||
D431A88F8543B8C4079050ACDD792D51 /* Dip.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = Dip.xcconfig; sourceTree = "<group>"; };
|
||||
D70F3F84928AF07F304E2A78BED54F5E /* Pods-DipTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-DipTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
DD7CF98DF0A99296E41AF2D9C3B473F9 /* Pods-DipTests-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-DipTests-acknowledgements.markdown"; sourceTree = "<group>"; };
|
||||
DDDDDD06DF5540C55DA4B0C74E1EC511 /* Pods-DipTests.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = "sourcecode.module-map"; path = "Pods-DipTests.modulemap"; sourceTree = "<group>"; };
|
||||
E1A14DC75595E6F6652CBCCE34EF2BC2 /* Dip.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Dip.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
E2C25F36DD7F27E8BA0BDFFF808541A7 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
F5067212B9AFB98F7CCBC7151A60A220 /* Pods-DipSampleApp-acknowledgements.markdown */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = "Pods-DipSampleApp-acknowledgements.markdown"; sourceTree = "<group>"; };
|
||||
FCA73F622E211B8366C7D190CE804EA5 /* Pods-DipSampleApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-DipSampleApp.release.xcconfig"; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
7054D0CB6C690B6BE41E609084CA0958 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8FB62E6448665FAB1B4B40278A9C18B3 /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
9E15208AD5F4351018028853ABA69EB9 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
F8D681A620B7540C44E9B51BD381C514 /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
ED999B179D5C9983F80D581113B9D018 /* Frameworks */ = {
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
598949CC3DD0DD2142DFA9759D331DB6 /* Foundation.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
02DBDCD39FB1D88711D499C4EE8EE355 /* Pods-DipTests */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
53E603F956BC0848C3DC16E858DAA805 /* Info.plist */,
|
||||
DDDDDD06DF5540C55DA4B0C74E1EC511 /* Pods-DipTests.modulemap */,
|
||||
DD7CF98DF0A99296E41AF2D9C3B473F9 /* Pods-DipTests-acknowledgements.markdown */,
|
||||
4D03528B91AE7D78A28CE55BADFA6159 /* Pods-DipTests-acknowledgements.plist */,
|
||||
08FDAF80E63D5379C5D67B2C5D37CB44 /* Pods-DipTests-dummy.m */,
|
||||
B13AB9998F2CB1AA813B9AB7A6851FBA /* Pods-DipTests-frameworks.sh */,
|
||||
093DB70F67DB4E609AB442CBB509D4E7 /* Pods-DipTests-resources.sh */,
|
||||
88B21BAF0A10E4BCDFF1F69039F04287 /* Pods-DipTests-umbrella.h */,
|
||||
2F6C88DA4612709E46E6E64B8DE3DF7B /* Pods-DipTests.debug.xcconfig */,
|
||||
D70F3F84928AF07F304E2A78BED54F5E /* Pods-DipTests.release.xcconfig */,
|
||||
);
|
||||
name = "Pods-DipTests";
|
||||
path = "Target Support Files/Pods-DipTests";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
3A648B4C2102C68BD49258688BF389CC /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E1A14DC75595E6F6652CBCCE34EF2BC2 /* Dip.framework */,
|
||||
8A5334FC48EF0DBABDE182FB6C1E6C3D /* Pods_DipSampleApp.framework */,
|
||||
6418C112ABDD19D3EF1DD98DB3019F05 /* Pods_DipTests.framework */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
46E7572EB1611944AB13E50F656187E9 /* Development Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C40734A4DEEFC0C72EE1D1BCF19DD769 /* Dip */,
|
||||
);
|
||||
name = "Development Pods";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
480A2A3476910EE7306AD0610F482D25 /* Support Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BDD421F6E0B38080BCB472073DA141EF /* Dip.modulemap */,
|
||||
D431A88F8543B8C4079050ACDD792D51 /* Dip.xcconfig */,
|
||||
98D1A0DC92D3A4A2B32D1B6094DECDA3 /* Dip-dummy.m */,
|
||||
551D96FB45D8D47702C68C545344BB55 /* Dip-prefix.pch */,
|
||||
9F68496928C5CF49172AFF11B37314C7 /* Dip-umbrella.h */,
|
||||
C9D3BEDF370AEED8CE8D3838C4F8BCB1 /* Info.plist */,
|
||||
);
|
||||
name = "Support Files";
|
||||
path = "Example/Pods/Target Support Files/Dip";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
7DB346D0F39D3F0E887471402A8071AB = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BA6428E9F66FD5A23C0A2E06ED26CD2F /* Podfile */,
|
||||
46E7572EB1611944AB13E50F656187E9 /* Development Pods */,
|
||||
BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */,
|
||||
3A648B4C2102C68BD49258688BF389CC /* Products */,
|
||||
A9D31FC7B7A14D2E4651A6C66A1A86EC /* Targets Support Files */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
A9D31FC7B7A14D2E4651A6C66A1A86EC /* Targets Support Files */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E6EDC7112547C1E567413310A74E6AB2 /* Pods-DipSampleApp */,
|
||||
02DBDCD39FB1D88711D499C4EE8EE355 /* Pods-DipTests */,
|
||||
);
|
||||
name = "Targets Support Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BC3CA7F9E30CC8F7E2DD044DD34432FC /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
BF6342C8B29F4CEEA088EFF7AB4DE362 /* iOS */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
BF6342C8B29F4CEEA088EFF7AB4DE362 /* iOS */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3E4E89230EF59BC255123B67864ACF77 /* Foundation.framework */,
|
||||
);
|
||||
name = iOS;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
C40734A4DEEFC0C72EE1D1BCF19DD769 /* Dip */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CF3CAD3FD76F762243056FAE7CFCDD9D /* Sources */,
|
||||
480A2A3476910EE7306AD0610F482D25 /* Support Files */,
|
||||
);
|
||||
name = Dip;
|
||||
path = ../..;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
CF3CAD3FD76F762243056FAE7CFCDD9D /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
D1855646D8AC0B232E538D845A7894FF /* Dip.swift */,
|
||||
);
|
||||
path = Sources;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
E6EDC7112547C1E567413310A74E6AB2 /* Pods-DipSampleApp */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
E2C25F36DD7F27E8BA0BDFFF808541A7 /* Info.plist */,
|
||||
040E6767354650F6353098E4EB50B3F7 /* Pods-DipSampleApp.modulemap */,
|
||||
F5067212B9AFB98F7CCBC7151A60A220 /* Pods-DipSampleApp-acknowledgements.markdown */,
|
||||
3BFEC463C4346DFBB40CFD331E7B8C8C /* Pods-DipSampleApp-acknowledgements.plist */,
|
||||
6DC6F865EBD27FE4416E8655E73F7426 /* Pods-DipSampleApp-dummy.m */,
|
||||
AF0EA8CE3EB9D052ABA91BBDF5935932 /* Pods-DipSampleApp-frameworks.sh */,
|
||||
A37235974396D8B3A4A2163B9FAF0328 /* Pods-DipSampleApp-resources.sh */,
|
||||
ACEDE7C6DC726F30DC3F36A7ECD7A8C2 /* Pods-DipSampleApp-umbrella.h */,
|
||||
4AC7412F56C556428F0902BDB2B9CC74 /* Pods-DipSampleApp.debug.xcconfig */,
|
||||
FCA73F622E211B8366C7D190CE804EA5 /* Pods-DipSampleApp.release.xcconfig */,
|
||||
);
|
||||
name = "Pods-DipSampleApp";
|
||||
path = "Target Support Files/Pods-DipSampleApp";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXHeadersBuildPhase section */
|
||||
91E0558A996F1C7D67CEF7650719B736 /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
92915F15583230B1CF7E9FAB6FFD5817 /* Dip-umbrella.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
BBAC4F3AB5D36D3D0D5D75D8B850C13E /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CE06FE77C65C0BE8BDD6AFB33EAD328F /* Pods-DipSampleApp-umbrella.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
DD721702CA080CE29A0491036618E6FD /* Headers */ = {
|
||||
isa = PBXHeadersBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
DF187AAE55CEA68761E21B080E2C2CF2 /* Pods-DipTests-umbrella.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXHeadersBuildPhase section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
28230D259635091F92F106AA282AA138 /* Dip */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 31CFDCC9535978BB70FDA95D6D357629 /* Build configuration list for PBXNativeTarget "Dip" */;
|
||||
buildPhases = (
|
||||
6A1130E1D8B20BCD2F3070FD7541D03E /* Sources */,
|
||||
9E15208AD5F4351018028853ABA69EB9 /* Frameworks */,
|
||||
91E0558A996F1C7D67CEF7650719B736 /* Headers */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = Dip;
|
||||
productName = Dip;
|
||||
productReference = E1A14DC75595E6F6652CBCCE34EF2BC2 /* Dip.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
3A53F07A7DBB3101BFCAD512E679F62C /* Pods-DipSampleApp */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = B70E7A5902F5B0D610680BC908B731F3 /* Build configuration list for PBXNativeTarget "Pods-DipSampleApp" */;
|
||||
buildPhases = (
|
||||
A943C34198589805B647072D0565220C /* Sources */,
|
||||
ED999B179D5C9983F80D581113B9D018 /* Frameworks */,
|
||||
BBAC4F3AB5D36D3D0D5D75D8B850C13E /* Headers */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
394A3171C70875A58CBC5E1A1DC019D7 /* PBXTargetDependency */,
|
||||
);
|
||||
name = "Pods-DipSampleApp";
|
||||
productName = "Pods-DipSampleApp";
|
||||
productReference = 8A5334FC48EF0DBABDE182FB6C1E6C3D /* Pods_DipSampleApp.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
A282C21E8EC965D4836B3AECBB21F499 /* Pods-DipTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 35DD63728C36940D0AE695EF42CC6F57 /* Build configuration list for PBXNativeTarget "Pods-DipTests" */;
|
||||
buildPhases = (
|
||||
62BE8684290E236F96D180ADDAB07160 /* Sources */,
|
||||
7054D0CB6C690B6BE41E609084CA0958 /* Frameworks */,
|
||||
DD721702CA080CE29A0491036618E6FD /* Headers */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
5541F443020F2B10F9A04FE23958A4C6 /* PBXTargetDependency */,
|
||||
);
|
||||
name = "Pods-DipTests";
|
||||
productName = "Pods-DipTests";
|
||||
productReference = 6418C112ABDD19D3EF1DD98DB3019F05 /* Pods_DipTests.framework */;
|
||||
productType = "com.apple.product-type.framework";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
|
||||
/* Begin PBXProject section */
|
||||
D41D8CD98F00B204E9800998ECF8427E /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastSwiftUpdateCheck = 0700;
|
||||
LastUpgradeCheck = 0700;
|
||||
};
|
||||
buildConfigurationList = 2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
knownRegions = (
|
||||
en,
|
||||
);
|
||||
mainGroup = 7DB346D0F39D3F0E887471402A8071AB;
|
||||
productRefGroup = 3A648B4C2102C68BD49258688BF389CC /* Products */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
28230D259635091F92F106AA282AA138 /* Dip */,
|
||||
3A53F07A7DBB3101BFCAD512E679F62C /* Pods-DipSampleApp */,
|
||||
A282C21E8EC965D4836B3AECBB21F499 /* Pods-DipTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
62BE8684290E236F96D180ADDAB07160 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
774AC175C524A1E16D01BB9CF19651ED /* Pods-DipTests-dummy.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
6A1130E1D8B20BCD2F3070FD7541D03E /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
3E5EF2244E6759BDB00BF6F862FFAD43 /* Dip-dummy.m in Sources */,
|
||||
73DFA9D2D6721ED2BF48E815083FC935 /* Dip.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
A943C34198589805B647072D0565220C /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
233F81BF5C5FCE081EE3E4963D0B28CD /* Pods-DipSampleApp-dummy.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
/* End PBXSourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXTargetDependency section */
|
||||
394A3171C70875A58CBC5E1A1DC019D7 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = Dip;
|
||||
target = 28230D259635091F92F106AA282AA138 /* Dip */;
|
||||
targetProxy = 62848E69B71441AB05941E7E2F09E1D8 /* PBXContainerItemProxy */;
|
||||
};
|
||||
5541F443020F2B10F9A04FE23958A4C6 /* PBXTargetDependency */ = {
|
||||
isa = PBXTargetDependency;
|
||||
name = Dip;
|
||||
target = 28230D259635091F92F106AA282AA138 /* Dip */;
|
||||
targetProxy = F9BC91C90262AF7A128076332A48985F /* PBXContainerItemProxy */;
|
||||
};
|
||||
/* End PBXTargetDependency section */
|
||||
|
||||
/* Begin XCBuildConfiguration section */
|
||||
1473D344CDCA306DE692B6341E997B38 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 2F6C88DA4612709E46E6E64B8DE3DF7B /* Pods-DipTests.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
INFOPLIST_FILE = "Target Support Files/Pods-DipTests/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MACH_O_TYPE = staticlib;
|
||||
MODULEMAP_FILE = "Target Support Files/Pods-DipTests/Pods-DipTests.modulemap";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
OTHER_LDFLAGS = "";
|
||||
OTHER_LIBTOOLFLAGS = "";
|
||||
PODS_ROOT = "$(SRCROOT)";
|
||||
PRODUCT_NAME = Pods_DipTests;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
6A72424D270F509461FC20CD059294D4 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = D431A88F8543B8C4079050ACDD792D51 /* Dip.xcconfig */;
|
||||
buildSettings = {
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_PREFIX_HEADER = "Target Support Files/Dip/Dip-prefix.pch";
|
||||
INFOPLIST_FILE = "Target Support Files/Dip/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MODULEMAP_FILE = "Target Support Files/Dip/Dip.modulemap";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
PRODUCT_NAME = Dip;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
78F0B5FBEADFB5A705557C10BE04C413 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 4AC7412F56C556428F0902BDB2B9CC74 /* Pods-DipSampleApp.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
INFOPLIST_FILE = "Target Support Files/Pods-DipSampleApp/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MACH_O_TYPE = staticlib;
|
||||
MODULEMAP_FILE = "Target Support Files/Pods-DipSampleApp/Pods-DipSampleApp.modulemap";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
OTHER_LDFLAGS = "";
|
||||
OTHER_LIBTOOLFLAGS = "";
|
||||
PODS_ROOT = "$(SRCROOT)";
|
||||
PRODUCT_NAME = Pods_DipSampleApp;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
A70CDAD61F90AC503C7D04CC22DA2923 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
SYMROOT = "${SRCROOT}/../build";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
B974ED11B24EB1E4C3321062F24469F4 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = D431A88F8543B8C4079050ACDD792D51 /* Dip.xcconfig */;
|
||||
buildSettings = {
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
GCC_PREFIX_HEADER = "Target Support Files/Dip/Dip-prefix.pch";
|
||||
INFOPLIST_FILE = "Target Support Files/Dip/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MODULEMAP_FILE = "Target Support Files/Dip/Dip.modulemap";
|
||||
MTL_ENABLE_DEBUG_INFO = YES;
|
||||
PRODUCT_NAME = Dip;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
CBDDB14779D5F8C01DB8F4A9A013509C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = FCA73F622E211B8366C7D190CE804EA5 /* Pods-DipSampleApp.release.xcconfig */;
|
||||
buildSettings = {
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
INFOPLIST_FILE = "Target Support Files/Pods-DipSampleApp/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MACH_O_TYPE = staticlib;
|
||||
MODULEMAP_FILE = "Target Support Files/Pods-DipSampleApp/Pods-DipSampleApp.modulemap";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
OTHER_LDFLAGS = "";
|
||||
OTHER_LIBTOOLFLAGS = "";
|
||||
PODS_ROOT = "$(SRCROOT)";
|
||||
PRODUCT_NAME = Pods_DipSampleApp;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
F1BFBC0693AAA13A7013B018CED4126C /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = D70F3F84928AF07F304E2A78BED54F5E /* Pods-DipTests.release.xcconfig */;
|
||||
buildSettings = {
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
CURRENT_PROJECT_VERSION = 1;
|
||||
DEFINES_MODULE = YES;
|
||||
DYLIB_COMPATIBILITY_VERSION = 1;
|
||||
DYLIB_CURRENT_VERSION = 1;
|
||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||
INFOPLIST_FILE = "Target Support Files/Pods-DipTests/Info.plist";
|
||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
MACH_O_TYPE = staticlib;
|
||||
MODULEMAP_FILE = "Target Support Files/Pods-DipTests/Pods-DipTests.modulemap";
|
||||
MTL_ENABLE_DEBUG_INFO = NO;
|
||||
OTHER_LDFLAGS = "";
|
||||
OTHER_LIBTOOLFLAGS = "";
|
||||
PODS_ROOT = "$(SRCROOT)";
|
||||
PRODUCT_NAME = Pods_DipTests;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = YES;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
VERSIONING_SYSTEM = "apple-generic";
|
||||
VERSION_INFO_PREFIX = "";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
FB45FFD90572718D82AB9092B750F0CA /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES;
|
||||
CLANG_WARN_EMPTY_BODY = YES;
|
||||
CLANG_WARN_ENUM_CONVERSION = YES;
|
||||
CLANG_WARN_INT_CONVERSION = YES;
|
||||
CLANG_WARN_OBJC_ROOT_CLASS = YES;
|
||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
ENABLE_NS_ASSERTIONS = NO;
|
||||
GCC_C_LANGUAGE_STANDARD = gnu99;
|
||||
GCC_PREPROCESSOR_DEFINITIONS = "RELEASE=1";
|
||||
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
|
||||
GCC_WARN_ABOUT_RETURN_TYPE = YES;
|
||||
GCC_WARN_UNDECLARED_SELECTOR = YES;
|
||||
GCC_WARN_UNINITIALIZED_AUTOS = YES;
|
||||
GCC_WARN_UNUSED_FUNCTION = YES;
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||
STRIP_INSTALLED_PRODUCT = NO;
|
||||
SYMROOT = "${SRCROOT}/../build";
|
||||
VALIDATE_PRODUCT = YES;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
2D8E8EC45A3A1A1D94AE762CB5028504 /* Build configuration list for PBXProject "Pods" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
A70CDAD61F90AC503C7D04CC22DA2923 /* Debug */,
|
||||
FB45FFD90572718D82AB9092B750F0CA /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
31CFDCC9535978BB70FDA95D6D357629 /* Build configuration list for PBXNativeTarget "Dip" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
B974ED11B24EB1E4C3321062F24469F4 /* Debug */,
|
||||
6A72424D270F509461FC20CD059294D4 /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
35DD63728C36940D0AE695EF42CC6F57 /* Build configuration list for PBXNativeTarget "Pods-DipTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1473D344CDCA306DE692B6341E997B38 /* Debug */,
|
||||
F1BFBC0693AAA13A7013B018CED4126C /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
B70E7A5902F5B0D610680BC908B731F3 /* Build configuration list for PBXNativeTarget "Pods-DipSampleApp" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
78F0B5FBEADFB5A705557C10BE04C413 /* Debug */,
|
||||
CBDDB14779D5F8C01DB8F4A9A013509C /* Release */,
|
||||
);
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
/* End XCConfigurationList section */
|
||||
};
|
||||
rootObject = D41D8CD98F00B204E9800998ECF8427E /* Project object */;
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
@interface PodsDummy_Dip : NSObject
|
||||
@end
|
||||
@implementation PodsDummy_Dip
|
||||
@end
|
||||
@@ -1,4 +0,0 @@
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#endif
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
FOUNDATION_EXPORT double DipVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char DipVersionString[];
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
framework module Dip {
|
||||
umbrella header "Dip-umbrella.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Private/Dip" "${PODS_ROOT}/Headers/Public"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
SKIP_INSTALL = YES
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,26 +0,0 @@
|
||||
# Acknowledgements
|
||||
This application makes use of the following third party libraries:
|
||||
|
||||
## Dip
|
||||
|
||||
Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Generated by CocoaPods - http://cocoapods.org
|
||||
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreferenceSpecifiers</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>This application makes use of the following third party libraries:</string>
|
||||
<key>Title</key>
|
||||
<string>Acknowledgements</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
</string>
|
||||
<key>Title</key>
|
||||
<string>Dip</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Generated by CocoaPods - http://cocoapods.org</string>
|
||||
<key>Title</key>
|
||||
<string></string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>StringsTable</key>
|
||||
<string>Acknowledgements</string>
|
||||
<key>Title</key>
|
||||
<string>Acknowledgements</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,5 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
@interface PodsDummy_Pods_DipSampleApp : NSObject
|
||||
@end
|
||||
@implementation PodsDummy_Pods_DipSampleApp
|
||||
@end
|
||||
@@ -1,91 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
|
||||
SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
|
||||
|
||||
install_framework()
|
||||
{
|
||||
if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
|
||||
local source="${BUILT_PRODUCTS_DIR}/$1"
|
||||
elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
|
||||
local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
|
||||
elif [ -r "$1" ]; then
|
||||
local source="$1"
|
||||
fi
|
||||
|
||||
local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
|
||||
if [ -L "${source}" ]; then
|
||||
echo "Symlinked..."
|
||||
source="$(readlink "${source}")"
|
||||
fi
|
||||
|
||||
# use filter instead of exclude so missing patterns dont' throw errors
|
||||
echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
|
||||
rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
|
||||
|
||||
local basename
|
||||
basename="$(basename -s .framework "$1")"
|
||||
binary="${destination}/${basename}.framework/${basename}"
|
||||
if ! [ -r "$binary" ]; then
|
||||
binary="${destination}/${basename}"
|
||||
fi
|
||||
|
||||
# Strip invalid architectures so "fat" simulator / device frameworks work on device
|
||||
if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
|
||||
strip_invalid_archs "$binary"
|
||||
fi
|
||||
|
||||
# Resign the code if required by the build settings to avoid unstable apps
|
||||
code_sign_if_enabled "${destination}/$(basename "$1")"
|
||||
|
||||
# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
|
||||
if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
|
||||
local swift_runtime_libs
|
||||
swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
|
||||
for lib in $swift_runtime_libs; do
|
||||
echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
|
||||
rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
|
||||
code_sign_if_enabled "${destination}/${lib}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Signs a framework with the provided identity
|
||||
code_sign_if_enabled() {
|
||||
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
|
||||
# Use the current code_sign_identitiy
|
||||
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
|
||||
echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\""
|
||||
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Strip invalid architectures
|
||||
strip_invalid_archs() {
|
||||
binary="$1"
|
||||
# Get architectures for current file
|
||||
archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
|
||||
stripped=""
|
||||
for arch in $archs; do
|
||||
if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
|
||||
# Strip non-valid architectures in-place
|
||||
lipo -remove "$arch" -output "$binary" "$binary" || exit 1
|
||||
stripped="$stripped $arch"
|
||||
fi
|
||||
done
|
||||
if [[ "$stripped" ]]; then
|
||||
echo "Stripped $binary of architectures:$stripped"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if [[ "$CONFIGURATION" == "Debug" ]]; then
|
||||
install_framework "Pods-DipSampleApp/Dip.framework"
|
||||
fi
|
||||
if [[ "$CONFIGURATION" == "Release" ]]; then
|
||||
install_framework "Pods-DipSampleApp/Dip.framework"
|
||||
fi
|
||||
@@ -1,95 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
|
||||
RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
|
||||
> "$RESOURCES_TO_COPY"
|
||||
|
||||
XCASSET_FILES=()
|
||||
|
||||
realpath() {
|
||||
DIRECTORY="$(cd "${1%/*}" && pwd)"
|
||||
FILENAME="${1##*/}"
|
||||
echo "$DIRECTORY/$FILENAME"
|
||||
}
|
||||
|
||||
install_resource()
|
||||
{
|
||||
case $1 in
|
||||
*.storyboard)
|
||||
echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
|
||||
ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
|
||||
;;
|
||||
*.xib)
|
||||
echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
|
||||
ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
|
||||
;;
|
||||
*.framework)
|
||||
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
;;
|
||||
*.xcdatamodel)
|
||||
echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
|
||||
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
|
||||
;;
|
||||
*.xcdatamodeld)
|
||||
echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
|
||||
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
|
||||
;;
|
||||
*.xcmappingmodel)
|
||||
echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\""
|
||||
xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm"
|
||||
;;
|
||||
*.xcassets)
|
||||
ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1")
|
||||
XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
|
||||
;;
|
||||
/*)
|
||||
echo "$1"
|
||||
echo "$1" >> "$RESOURCES_TO_COPY"
|
||||
;;
|
||||
*)
|
||||
echo "${PODS_ROOT}/$1"
|
||||
echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
|
||||
mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
fi
|
||||
rm -f "$RESOURCES_TO_COPY"
|
||||
|
||||
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
|
||||
then
|
||||
case "${TARGETED_DEVICE_FAMILY}" in
|
||||
1,2)
|
||||
TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
|
||||
;;
|
||||
1)
|
||||
TARGET_DEVICE_ARGS="--target-device iphone"
|
||||
;;
|
||||
2)
|
||||
TARGET_DEVICE_ARGS="--target-device ipad"
|
||||
;;
|
||||
*)
|
||||
TARGET_DEVICE_ARGS="--target-device mac"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
|
||||
OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
|
||||
while read line; do
|
||||
if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
|
||||
XCASSET_FILES+=("$line")
|
||||
fi
|
||||
done <<<"$OTHER_XCASSETS"
|
||||
|
||||
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
fi
|
||||
@@ -1,6 +0,0 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
FOUNDATION_EXPORT double Pods_DipSampleAppVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char Pods_DipSampleAppVersionString[];
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Dip.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Dip"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-DipSampleApp
|
||||
PODS_ROOT = ${SRCROOT}/Pods
|
||||
@@ -1,6 +0,0 @@
|
||||
framework module Pods_DipSampleApp {
|
||||
umbrella header "Pods-DipSampleApp-umbrella.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Dip.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Dip"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-DipSampleApp
|
||||
PODS_ROOT = ${SRCROOT}/Pods
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.cocoapods.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,26 +0,0 @@
|
||||
# Acknowledgements
|
||||
This application makes use of the following third party libraries:
|
||||
|
||||
## Dip
|
||||
|
||||
Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
Generated by CocoaPods - http://cocoapods.org
|
||||
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>PreferenceSpecifiers</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>This application makes use of the following third party libraries:</string>
|
||||
<key>Title</key>
|
||||
<string>Acknowledgements</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
</string>
|
||||
<key>Title</key>
|
||||
<string>Dip</string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Generated by CocoaPods - http://cocoapods.org</string>
|
||||
<key>Title</key>
|
||||
<string></string>
|
||||
<key>Type</key>
|
||||
<string>PSGroupSpecifier</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>StringsTable</key>
|
||||
<string>Acknowledgements</string>
|
||||
<key>Title</key>
|
||||
<string>Acknowledgements</string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,5 +0,0 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
@interface PodsDummy_Pods_DipTests : NSObject
|
||||
@end
|
||||
@implementation PodsDummy_Pods_DipTests
|
||||
@end
|
||||
@@ -1,91 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
|
||||
SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}"
|
||||
|
||||
install_framework()
|
||||
{
|
||||
if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then
|
||||
local source="${BUILT_PRODUCTS_DIR}/$1"
|
||||
elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then
|
||||
local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")"
|
||||
elif [ -r "$1" ]; then
|
||||
local source="$1"
|
||||
fi
|
||||
|
||||
local destination="${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
|
||||
if [ -L "${source}" ]; then
|
||||
echo "Symlinked..."
|
||||
source="$(readlink "${source}")"
|
||||
fi
|
||||
|
||||
# use filter instead of exclude so missing patterns dont' throw errors
|
||||
echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\""
|
||||
rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}"
|
||||
|
||||
local basename
|
||||
basename="$(basename -s .framework "$1")"
|
||||
binary="${destination}/${basename}.framework/${basename}"
|
||||
if ! [ -r "$binary" ]; then
|
||||
binary="${destination}/${basename}"
|
||||
fi
|
||||
|
||||
# Strip invalid architectures so "fat" simulator / device frameworks work on device
|
||||
if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then
|
||||
strip_invalid_archs "$binary"
|
||||
fi
|
||||
|
||||
# Resign the code if required by the build settings to avoid unstable apps
|
||||
code_sign_if_enabled "${destination}/$(basename "$1")"
|
||||
|
||||
# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
|
||||
if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
|
||||
local swift_runtime_libs
|
||||
swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
|
||||
for lib in $swift_runtime_libs; do
|
||||
echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
|
||||
rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
|
||||
code_sign_if_enabled "${destination}/${lib}"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
# Signs a framework with the provided identity
|
||||
code_sign_if_enabled() {
|
||||
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
|
||||
# Use the current code_sign_identitiy
|
||||
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
|
||||
echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements \"$1\""
|
||||
/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} --preserve-metadata=identifier,entitlements "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# Strip invalid architectures
|
||||
strip_invalid_archs() {
|
||||
binary="$1"
|
||||
# Get architectures for current file
|
||||
archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)"
|
||||
stripped=""
|
||||
for arch in $archs; do
|
||||
if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then
|
||||
# Strip non-valid architectures in-place
|
||||
lipo -remove "$arch" -output "$binary" "$binary" || exit 1
|
||||
stripped="$stripped $arch"
|
||||
fi
|
||||
done
|
||||
if [[ "$stripped" ]]; then
|
||||
echo "Stripped $binary of architectures:$stripped"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if [[ "$CONFIGURATION" == "Debug" ]]; then
|
||||
install_framework "Pods-DipTests/Dip.framework"
|
||||
fi
|
||||
if [[ "$CONFIGURATION" == "Release" ]]; then
|
||||
install_framework "Pods-DipTests/Dip.framework"
|
||||
fi
|
||||
@@ -1,95 +0,0 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
|
||||
mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
|
||||
RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt
|
||||
> "$RESOURCES_TO_COPY"
|
||||
|
||||
XCASSET_FILES=()
|
||||
|
||||
realpath() {
|
||||
DIRECTORY="$(cd "${1%/*}" && pwd)"
|
||||
FILENAME="${1##*/}"
|
||||
echo "$DIRECTORY/$FILENAME"
|
||||
}
|
||||
|
||||
install_resource()
|
||||
{
|
||||
case $1 in
|
||||
*.storyboard)
|
||||
echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
|
||||
ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .storyboard`.storyboardc" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
|
||||
;;
|
||||
*.xib)
|
||||
echo "ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile ${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib ${PODS_ROOT}/$1 --sdk ${SDKROOT}"
|
||||
ibtool --reference-external-strings-file --errors --warnings --notices --output-format human-readable-text --compile "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$1\" .xib`.nib" "${PODS_ROOT}/$1" --sdk "${SDKROOT}"
|
||||
;;
|
||||
*.framework)
|
||||
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
echo "rsync -av ${PODS_ROOT}/$1 ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
rsync -av "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
;;
|
||||
*.xcdatamodel)
|
||||
echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1"`.mom\""
|
||||
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodel`.mom"
|
||||
;;
|
||||
*.xcdatamodeld)
|
||||
echo "xcrun momc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd\""
|
||||
xcrun momc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcdatamodeld`.momd"
|
||||
;;
|
||||
*.xcmappingmodel)
|
||||
echo "xcrun mapc \"${PODS_ROOT}/$1\" \"${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm\""
|
||||
xcrun mapc "${PODS_ROOT}/$1" "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$1" .xcmappingmodel`.cdm"
|
||||
;;
|
||||
*.xcassets)
|
||||
ABSOLUTE_XCASSET_FILE=$(realpath "${PODS_ROOT}/$1")
|
||||
XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE")
|
||||
;;
|
||||
/*)
|
||||
echo "$1"
|
||||
echo "$1" >> "$RESOURCES_TO_COPY"
|
||||
;;
|
||||
*)
|
||||
echo "${PODS_ROOT}/$1"
|
||||
echo "${PODS_ROOT}/$1" >> "$RESOURCES_TO_COPY"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
mkdir -p "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${CONFIGURATION_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then
|
||||
mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
fi
|
||||
rm -f "$RESOURCES_TO_COPY"
|
||||
|
||||
if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ]
|
||||
then
|
||||
case "${TARGETED_DEVICE_FAMILY}" in
|
||||
1,2)
|
||||
TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone"
|
||||
;;
|
||||
1)
|
||||
TARGET_DEVICE_ARGS="--target-device iphone"
|
||||
;;
|
||||
2)
|
||||
TARGET_DEVICE_ARGS="--target-device ipad"
|
||||
;;
|
||||
*)
|
||||
TARGET_DEVICE_ARGS="--target-device mac"
|
||||
;;
|
||||
esac
|
||||
|
||||
# Find all other xcassets (this unfortunately includes those of path pods and other targets).
|
||||
OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d)
|
||||
while read line; do
|
||||
if [[ $line != "`realpath $PODS_ROOT`*" ]]; then
|
||||
XCASSET_FILES+=("$line")
|
||||
fi
|
||||
done <<<"$OTHER_XCASSETS"
|
||||
|
||||
printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${IPHONEOS_DEPLOYMENT_TARGET}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}"
|
||||
fi
|
||||
@@ -1,6 +0,0 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
|
||||
FOUNDATION_EXPORT double Pods_DipTestsVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char Pods_DipTestsVersionString[];
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Dip.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Dip"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-DipTests
|
||||
PODS_ROOT = ${SRCROOT}/Pods
|
||||
@@ -1,6 +0,0 @@
|
||||
framework module Pods_DipTests {
|
||||
umbrella header "Pods-DipTests-umbrella.h"
|
||||
|
||||
export *
|
||||
module * { export * }
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "$CONFIGURATION_BUILD_DIR/Dip.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Dip"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods-DipTests
|
||||
PODS_ROOT = ${SRCROOT}/Pods
|
||||
@@ -0,0 +1,30 @@
|
||||
//
|
||||
// Dip
|
||||
//
|
||||
// Copyright (c) 2015 Olivier Halligon <olivier@halligon.net>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
//
|
||||
|
||||
import PackageDescription
|
||||
|
||||
let package = Package(
|
||||
name: "Dip"
|
||||
)
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
[](https://travis-ci.org/AliSoftware/Dip)
|
||||
[](http://cocoapods.org/pods/Dip)
|
||||
[](https://github.com/Carthage/Carthage)
|
||||
[](http://cocoapods.org/pods/Dip)
|
||||
[](http://cocoapods.org/pods/Dip)
|
||||
[](https://developer.apple.com/swift)
|
||||
[](https://developer.apple.com/swift)
|
||||
|
||||

|
||||
_Photo courtesy of [www.kevinandamanda.com](http://www.kevinandamanda.com/recipes/appetizer/homemade-soft-cinnamon-sugar-pretzel-bites-with-salted-caramel-dipping-sauce.html)_
|
||||
@@ -12,23 +15,30 @@ _Photo courtesy of [www.kevinandamanda.com](http://www.kevinandamanda.com/recipe
|
||||
|
||||
`Dip` is a simple **Dependency Injection Container**.
|
||||
|
||||
It's not true Dependency Injection, but it's damn close, and aimed to be as simple as possible.
|
||||
It's inspired by `.NET`'s [Unity Container](https://msdn.microsoft.com/library/ff647202.aspx).
|
||||
It's aimed to be as simple as possible yet provide rich functionality usual for DI containers on other platforms. It's inspired by `.NET`'s [Unity Container](https://msdn.microsoft.com/library/ff647202.aspx) and other DI containers.
|
||||
|
||||
* You start by creating `let dc = DependencyContainer()` and **register all your dependencies, by associating a `protocol` to an `instance` or a `factory`**.
|
||||
* Then anywhere in your application, you can call `dc.resolve()` to **resolve a `protocol` into an instance of a concrete type** using that `DependencyContainer`.
|
||||
* You start by creating `let dc = DependencyContainer()` and **register all your dependencies, by associating a `protocol` to a `factory`**.
|
||||
* Then you can call `dc.resolve()` to **resolve a `protocol` into an instance of a concrete type** using that `DependencyContainer`.
|
||||
|
||||
This allows you to define the real, concrete types only in one place ([e.g. like this in your app](https://github.com/AliSoftware/Dip/blob/master/Example/DipSampleApp/DependencyContainers.swift#L22-L27), and [resetting it in your `setUp` for each Unit Tests](https://github.com/AliSoftware/Dip/blob/master/Example/Tests/SWAPIPersonProviderTests.swift#L17-L21)) and then [only work with `protocols` in your code](https://github.com/AliSoftware/Dip/blob/master/Example/DipSampleApp/Providers/SWAPIStarshipProvider.swift#L12) (which only define an API contract), without worrying about the real implementation.
|
||||
This allows you to define the real, concrete types only in one place ([e.g. like this in your app](SampleApp/DipSampleApp/DependencyContainers.swift#L22-L27), and [resetting it in your `setUp` for each Unit Tests](SampleApp/Tests/SWAPIPersonProviderTests.swift#L17-L21)) and then [only work with `protocols` in your code](SampleApp/DipSampleApp/Providers/SWAPIStarshipProvider.swift#L12) (which only define an API contract), without worrying about the real implementation.
|
||||
|
||||
> You can easily use Dip along with Storyboards and Nibs - checkout [Dip-UI](https://github.com/AliSoftware/Dip-UI) extensions.
|
||||
|
||||
## Advantages of DI and loose coupling
|
||||
|
||||
* Define clear API contracts before even thinking about implementation, and make your code loosly coupled with the real implementation.
|
||||
* Easily switch between implementations — as long as they respect the same API contact (the `protocol`
|
||||
* Easily switch between implementations — as long as they respect the same API contact (the `protocol`), making your app modular and scalable.
|
||||
* Greatly improve testability, as you can register a real instance in your app but a fake instance in your tests dedicated for testing / mocking the fonctionnality
|
||||
* Get rid of those `sharedInstances` and avoid the singleton pattern at all costs
|
||||
* Enable parallel development in your team. You and your teammates can work independently on different parts of the app after you agree on the interfaces.
|
||||
* As a bonus get rid of those `sharedInstances` and avoid the singleton pattern at all costs.
|
||||
|
||||
|
||||
If you want to know more about Dependency Injection in general we recomend you to read ["Dependency Injection in .Net"](https://www.manning.com/books/dependency-injection-in-dot-net) by Mark Seemann. Dip was inspired particularly by implementations of some DI containers for .Net platform and shares core principles described in that book (even if you are not familiar with .Net platform the prenciples described in that book are platform agnostic).
|
||||
|
||||
## Installation
|
||||
|
||||
Since version 4.3.1 Dip is built with Swift 2.2. The lates version built with Swift 2.1 is 4.3.0.
|
||||
|
||||
Dip is available through [CocoaPods](http://cocoapods.org). To install
|
||||
it, simply add the following line to your Podfile:
|
||||
|
||||
@@ -36,123 +46,323 @@ it, simply add the following line to your Podfile:
|
||||
pod "Dip"
|
||||
```
|
||||
|
||||
If you use _Carthage_ add this line to your Cartfile:
|
||||
|
||||
```
|
||||
github "AliSoftware/Dip"
|
||||
```
|
||||
|
||||
If you use [_Swift Package Manager_](https://swift.org/package-manager/) add Dip as dependency to you `Package.swift`:
|
||||
|
||||
```
|
||||
let package = Package(
|
||||
name: "MyPackage",
|
||||
dependencies: [
|
||||
.Package(url: "https://github.com/AliSoftware/Dip.git", "4.4.0")
|
||||
]
|
||||
)
|
||||
```
|
||||
|
||||
## Running tests
|
||||
|
||||
On OSX you can run tests from Xcode. On Linux you need to have Swift Package Manager installed and use it to build test executable:
|
||||
|
||||
```
|
||||
cd Dip/DipTests
|
||||
swift build
|
||||
./.build/debug/DipTests
|
||||
```
|
||||
|
||||
## Playground
|
||||
|
||||
Dip comes with a **Playground** to introduce you to Inversion of Control, Dependency Injection, and how to use Dip in practice.
|
||||
|
||||
To play with it, [open `Dip.xcworkspace`](Dip/Dip.xcworkspace), then click on the `DipPlayground` entry in Xcode's Project Navigator and let it be your guide.
|
||||
|
||||
_Note: Do not open the `DipPlayground.playground` file directly, as it needs to be part of the workspace to access the Dip framework so that the demo code it contains can work._
|
||||
|
||||
The next paragraphs give you an overview of the Usage of _Dip_ directly, but if you're new to Dependency Injection, the Playground is probably a better start.
|
||||
|
||||
## Usage
|
||||
|
||||
### Register instances and instance factories
|
||||
### Register instance factories
|
||||
|
||||
First, create a `DependencyContainer` and use it to register instances and factories with protocols, using those methods:
|
||||
First, create a `DependencyContainer` and use it to register instance factories with protocols, using those methods:
|
||||
|
||||
* `register(instance: _)` will register a singleton instance with a given protocol.
|
||||
* `register(factory: _)` will register an instance factory — which generates a new instance each time you `resolve()`.
|
||||
* You need **cast the instance to the protocol type** you want to register it with (e.g. `register(instance: PlistUsersProvider() as UsersListProviderType)`).
|
||||
* `register() { … as SomeType }` will register provided factory with a given type.
|
||||
* if you want to register an concrete implementation for some abstraction (protocol) you need **cast the instance to that protocol type** (e.g. `register { PlistUsersProvider() as UsersListProviderType }`).
|
||||
* if you want just to register concrete type in container you may not need a type cast
|
||||
|
||||
Typically, to register your dependencies as early as possible in your app life-cycle, you will declare a `let dip: DependencyContainer = { … }()` somewhere (for example [in a dedicated `.swift` file](https://github.com/AliSoftware/Dip/blob/master/Example/DipSampleApp/DependencyContainers.swift#L22-L27)). In your (non-hosted, standalone) unit tests, you'll probably [reset them in your `func setUp()`](https://github.com/AliSoftware/Dip/blob/master/Example/Tests/SWAPIPersonProviderTests.swift#L17-L21) instead.
|
||||
Typically, to register your dependencies as early as possible in your app life-cycle, you will declare a `let dip: DependencyContainer = { … }()` somewhere, most likely in your `AppDelegate`. In unit tests you may configure container in each test method specifically and then reset it in `tearDown()`.
|
||||
|
||||
### Resolve dependencies
|
||||
|
||||
* `resolve()` will return a new instance matching the requested protocol.
|
||||
* Explicitly specify the return type of `resolve` so that Swift's type inference knows which protocol you're trying to resolve.
|
||||
* If that protocol was registered as a singleton instance (using `register(instance: …)`, the same instance will be returned each time you call `resolve()` for this protocol type. Otherwise, the instance factory will generate a new instance each time.
|
||||
* `try resolve() as SomeType` will return a new instance matching the requested type (protocol or concrete type).
|
||||
* `resolve()` is a generic method so you need to explicitly specify the return type (using `as` or explicitly providing type of a variable that will hold the resulting value) so that Swift's type inference knows which type you're trying to resolve.
|
||||
|
||||
```swift
|
||||
container.register { ServiceImp() as Service }
|
||||
let service = try! container.resolve() as Service
|
||||
```
|
||||
|
||||
Ususally you will use _abstractions_ for your dependencies, but container can also resolve concrete types, if you register them. You can use that in cases where abstraction is not really required.
|
||||
|
||||
```swift
|
||||
container.register { ServiceImp() }
|
||||
let service: ServiceImp = try! container.resolve()
|
||||
```
|
||||
|
||||
|
||||
### Scopes
|
||||
|
||||
Dip provides four _scopes_ that you can use to register dependencies:
|
||||
|
||||
* The `.Prototype` scope will make the `DependencyContainer` resolve your type as __a new instance every time__ you call `resolve`. It's a default scope.
|
||||
* The `.ObjectGraph` scope is like `.Prototype` scope but it will make the `DependencyContainer` to reuse resolved instances during one call to `resolve` method. When this call returns all resolved insances will be discarded and next call to `resolve` will produce new instances. This scope _must_ be used to properly resolve circular dependencies.
|
||||
* The `.Singleton` and `.EagerSingleton` scopes will make the `DependencyContainer` retain the instance once resolved the first time, and reuse it in the next calls to `resolve` during the container lifetime.
|
||||
|
||||
You specify scope when you register dependency like that:
|
||||
|
||||
```swift
|
||||
container.register() { ServiceImp() as Service } //.Prototype is a default
|
||||
container.register(.ObjectGraph) { ServiceImp() as Service }
|
||||
container.register(.Singleton) { ServiceImp() as Service }
|
||||
```
|
||||
|
||||
|
||||
### Using block-based initialization
|
||||
|
||||
When calling the initializer of `DependencyContainer()`, you can pass a block that will be called right after the initialization. This allows you to have a nice syntax to do all your `register(…)` calls in there, instead of having to do them separately.
|
||||
|
||||
It may not seem to provide much, but given the fact that `DependencyContainers` are typically declared as global constants using a top-level `let`, it gets very useful, because instead of having to do it like this:
|
||||
It may not seem to provide much, but it gets very useful, because instead of having to do setup the container like this:
|
||||
|
||||
```swift
|
||||
let dip: DependencyContainer = {
|
||||
let dip = DependencyContainer()
|
||||
|
||||
dip.register(instance: ProductionEnvironment(analytics: true) as EnvironmentType)
|
||||
dip.register(instance: WebService() as WebServiceAPI)
|
||||
dip.register { ProductionEnvironment(analytics: true) as EnvironmentType }
|
||||
dip.register { WebService() as WebServiceAPI }
|
||||
|
||||
return dip
|
||||
}()
|
||||
```
|
||||
|
||||
You can instead write this exact equivalent code, which is more compact, and indent better in Xcode (as the final closing brack is properly aligned):
|
||||
you can instead write this exact equivalent code, which is more compact, and indent better in Xcode (as the final closing brack is properly aligned):
|
||||
|
||||
```swift
|
||||
let dip = DependencyContainer { dip in
|
||||
dip.register(instance: ProductionEnvironment(analytics: true) as EnvironmentType)
|
||||
dip.register(instance: WebService() as WebServiceAPI)
|
||||
dip.register { ProductionEnvironment(analytics: true) as EnvironmentType }
|
||||
dip.register { WebService() as WebServiceAPI }
|
||||
}
|
||||
```
|
||||
|
||||
### Using tags to associate various factories to one protocol
|
||||
### Using tags to associate various factories to one type
|
||||
|
||||
* If you give a `tag` in the parameter to `register()`, it will associate that instance or factory with this tag, which can be used later during `resolve` (see below).
|
||||
* `resolve(tag)` will try to find an instance (or instance factory) that match both the requested protocol _and_ the tag. If it doesn't find any, it will fallback to an instance (or instance factory) that only match the requested protocol.
|
||||
* The tags can be StringLiteralType or IntegerLiteralType. That said you can use plain strings or integers as tags.
|
||||
* `resolve(tag: tag)` will try to find a factory that match both the requested protocol _and_ the tag. If it doesn't find any, it will fallback to the factory that only match the requested type.
|
||||
* The tags can be `StringLiteralType` or `IntegerLiteralType`. That said you can use plain strings or integers as tags.
|
||||
|
||||
|
||||
```swift
|
||||
enum WebService: String {
|
||||
case PersonWS
|
||||
case StarshipWS
|
||||
var tag: Tag { return Tag.String(self.rawValue) }
|
||||
case Production
|
||||
case Development
|
||||
|
||||
var tag: DependencyContainer.Tag { return DependencyContainer.Tag.String(self.rawValue) }
|
||||
}
|
||||
|
||||
let wsDependencies = DependencyContainer<WebService>() { dip in
|
||||
dip.register(WebService.PersonWS.tag, instance: URLSessionNetworkLayer(baseURL: "http://prod.myapi.com/api/")! as NetworkLayer)
|
||||
dip.register(WebService.StashipWS.tag, instance: URLSessionNetworkLayer(baseURL: "http://dev.myapi.com/api/")! as NetworkLayer)
|
||||
let wsDependencies = DependencyContainer() { dip in
|
||||
dip.register(tag: WebService.Production.tag) { URLSessionNetworkLayer(baseURL: "http://prod.myapi.com/api/")! as NetworkLayer }
|
||||
dip.register(tag: WebService.Development.tag) { URLSessionNetworkLayer(baseURL: "http://dev.myapi.com/api/")! as NetworkLayer }
|
||||
}
|
||||
|
||||
let networkLayer = try! dip.resolve(tag: WebService.PersonWS.tag) as NetworkLayer
|
||||
```
|
||||
|
||||
### Runtime arguments
|
||||
|
||||
You can register factories that accept up to six arguments. When you resolve dependency you can pass those arguments to `resolve()` method and they will be passed to the factory. Note that _number_, _types_ and _order_ of parameters matters (see _Runtime arguments_ page of the Playground).
|
||||
|
||||
```swift
|
||||
let webServices = DependencyContainer() { webServices in
|
||||
webServices.register { (url: NSURL, port: Int) in WebServiceImp1(url, port: port) as WebServiceAPI }
|
||||
}
|
||||
|
||||
let service = try! webServices.resolve(withArguments: NSURL(string: "http://example.url")!, 80) as WebServiceAPI
|
||||
|
||||
```
|
||||
Though Dip provides support for up to six runtime arguments out of the box you can extend that.
|
||||
|
||||
### Circular dependencies
|
||||
|
||||
_Dip_ supports circular dependencies. For that you need to register your components with `ObjectGraph` scope and use `resolveDependencies` method of `DefinitionOf` returned by `register` method like this:
|
||||
|
||||
```swift
|
||||
container.register(.ObjectGraph) {
|
||||
ClientImp(server: try container.resolve() as Server) as Client
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
.resolveDependencies { container, server in
|
||||
server.client = try container.resolve() as Client
|
||||
}
|
||||
```
|
||||
More information about circular dependencies you can find in the Playground.
|
||||
|
||||
### Auto-wiring
|
||||
|
||||
When you use constructor injection to inject dependencies in your component auto-wiring enables you to resolve it just with one call to `resolve` method without carying about how to resolve all constructor arguments - container will resolve them for you.
|
||||
|
||||
```swift
|
||||
class PresenterImp: Presenter {
|
||||
init(view: ViewOutput, interactor: Interactor, router: Router) { ... }
|
||||
...
|
||||
}
|
||||
|
||||
container.register { RouterImp() as Router }
|
||||
container.register { View() as ViewOutput }
|
||||
container.register { InteractorImp() as Interactor }
|
||||
container.register { PresenterImp(view: $0, interactor: $1, router: $2) as Presenter }
|
||||
|
||||
let presenter = try! container.resolve() as Presenter
|
||||
```
|
||||
|
||||
### Auto-injection
|
||||
|
||||
Auto-injection lets your resolve all property dependencies of the instance resolved by container with just one call, also allowing a simpler syntax to register circular dependencies.
|
||||
|
||||
```swift
|
||||
protocol Server {
|
||||
weak var client: Client? { get }
|
||||
}
|
||||
|
||||
protocol Client: class {
|
||||
var server: Server? { get }
|
||||
}
|
||||
|
||||
class ServerImp: Server {
|
||||
private var injectedClient = InjectedWeak<Client>()
|
||||
var client: Client? { return injectedClient.value }
|
||||
}
|
||||
|
||||
class ClientImp: Client {
|
||||
private var injectedServer = Injected<Server>()
|
||||
var server: Server? { get { return injectedServer.value} }
|
||||
}
|
||||
|
||||
container.register(.ObjectGraph) { ServerImp() as Server }
|
||||
container.register(.ObjectGraph) { ClientImp() as Client }
|
||||
|
||||
let client = try! container.resolve() as Client
|
||||
|
||||
```
|
||||
You can find more use cases for auto-injection in the Playground available in this repository.
|
||||
|
||||
> Tip: You can use either `Injected<T>` and `InjectedWeak<T>` wrappers provided by Dip, or your own wrappers (even plain `Box<T>`) that conform to `AutoInjectedPropertyBox` protocol.
|
||||
|
||||
### Thread safety
|
||||
|
||||
`DependencyContainer` is thread safe, you can register and resolve components from different threads.
|
||||
Still we encourage you to register components in the main thread early in the application lifecycle to prevent race conditions
|
||||
when you try to resolve component from one thread while it was not yet registered in container by another thread.
|
||||
|
||||
### Errors
|
||||
|
||||
The resolve operation has a potential to fail because you can use the wrong type, factory or a wrong tag. For that reason Dip throws a `DipError` if it fails to resolve a type. Thus when calling `resolve` you need to use a `try` operator.
|
||||
There are very rare use cases when your application can recover from this kind of error. In most of the cases you can use `try!` to cause an exception at runtime if error was thrown or `try?` if a dependency is optional. This way `try!` serves as an additional mark for developers that resolution can fail.
|
||||
Dip also provides helpful descriptions for errors that can occur when you call `resolve`. See the source code documentation to know more about that.
|
||||
|
||||
### Concrete Example
|
||||
|
||||
Somewhere in your App target, register the dependencies:
|
||||
|
||||
```swift
|
||||
let dip: DependencyContainer = {
|
||||
let dip = DependencyContainer()
|
||||
let env = ProductionEnvironment(analytics: true)
|
||||
dip.register(instance: env as EnvironmentType)
|
||||
dip.register(instance: WebService() as WebServiceType)
|
||||
dip.register() { DummyFriendsProvider(user: $0 ?? "Jane Doe") as FriendsProviderType }
|
||||
dip.register("me") { PlistFriendsProvider(plist: "myfriends") as FriendsProviderType }
|
||||
return dip
|
||||
}
|
||||
```
|
||||
|
||||
> Do the same in your Unit Tests target & test cases, but obviously with different Dependencies registered, depending on what you want to test and what instances you need to inject to provide dummy implementations for your tests.
|
||||
|
||||
|
||||
Then to use dependencies throughout your app, use `dip.resolve()`, like this:
|
||||
Let's say you have some view model that depends on some data provider and web service:
|
||||
|
||||
```swift
|
||||
struct WebService {
|
||||
let env: EnvironmentType = dip.resolve()
|
||||
let env: EnvironmentType
|
||||
|
||||
init(env: EnvironmentType) {
|
||||
self.env = env
|
||||
}
|
||||
|
||||
func sendRequest(path: String, …) {
|
||||
// ... use stuff like env.baseURL here
|
||||
// … use stuff like env.baseURL here
|
||||
}
|
||||
}
|
||||
|
||||
struct SomeViewModel {
|
||||
let ws: WebServiceType = dip.resolve()
|
||||
var friendsProvider: FriendsProviderType
|
||||
init(userName: String) {
|
||||
friendsProvider = dip.resolve(userName)
|
||||
let ws: WebServiceType
|
||||
let friendsProvider: FriendsProviderType
|
||||
|
||||
init(friendsProvider: FriendsProviderType, webService: WebServiceType) {
|
||||
self.friendsProvider = friendsProvider
|
||||
self.ws = webService
|
||||
}
|
||||
|
||||
func foo() {
|
||||
ws.someMethodDeclaredOnWebServiceType()
|
||||
let friends = friendsProvider.someFriendsProviderTypeMethod()
|
||||
print("friends: \(friends)")
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This way, when running your app target:
|
||||
As you can see we have few layers of dependencies here. All of them together represent _dependency graph_.
|
||||
To be able to resolve this graph with Dip we need to make it aware of those types.
|
||||
For that we register the dependencies somewhere early in app life cycle (most likely in AppDelegate):
|
||||
|
||||
* `ws` will be resolved as your singleton instance `WebService` registered before.
|
||||
* `friendsProvider` will be resolved as a new instance each time, which will be an instance created via `PlistFriendsProvider(plist: "myfriends")` if `userName` is `me` and created via `DummyFriendsProvider(userName)` for any other `userName` value (because `resolve(userName)` will fallback to `resolve(nil)` in that case, using the instance factory which was registered without a tag).
|
||||
```swift
|
||||
let dip: DependencyContainer = {
|
||||
let dip = DependencyContainer()
|
||||
let enableAnalytics = … //i.e. read the setting from plist
|
||||
dip.register(.Singleton) { ProductionEnvironment(analytics: enableAnalytics) as EnvironmentType }
|
||||
dip.register(.Singleton) { WebService(env: try dip.resolve()) as WebServiceType }
|
||||
|
||||
But when running your Unit tests target, it will probably resolve to other instances, depending on how you registered your dependencies in your Test Case.
|
||||
dip.register() { userName in DummyFriendsProvider(user: name) as FriendsProviderType }
|
||||
dip.register(tag: "me") { (_: String) in PlistFriendsProvider(plist: "myfriends") as FriendsProviderType }
|
||||
|
||||
dip.register() { userName in
|
||||
let webService = try dip.resolve() as WebServiceType
|
||||
let friendsProvider = try dip.resolve(tag: userName, withArguments: userName) as
|
||||
return SomeViewModel(friendsProvider: freindsProvider, webService: webService)
|
||||
}
|
||||
return dip
|
||||
}
|
||||
```
|
||||
|
||||
> Do the same in your Unit Tests target & test cases, but obviously with different _implementations_ (test doubles) registered.
|
||||
|
||||
Then to resolve the graph use `dip.resolve()`, like this:
|
||||
|
||||
```swift
|
||||
let viewModel = try! dip.resolve(withArguments: userName) as SomeViewModel
|
||||
//now you can use view model or pass it to it's consumer
|
||||
|
||||
```
|
||||
|
||||
This way with just one call to `resolve()` you will have the whole graph of your dependencies resolved and ready to use:
|
||||
|
||||
* environmet will be resolved as a singleton instance of `ProductionEnvironment` with enabled analitycs;
|
||||
* `ws` will be resolved as a singleton instance of `WebService` and will have it's `env` property set to `ProductionEnvironment`, already resolved (and reatined) by container.
|
||||
* `friendsProvider` will be resolved as a new instance each time you create a view model, which will be an instance created via
|
||||
`PlistFriendsProvider(plist: "myfriends")` if `userName` is `me` and created via `DummyFriendsProvider(userName)` for any other
|
||||
`userName` value (because `resolve(tag: userName, withArguments: userName)` will fallback to `resolve(tag: nil, withArguments: userName)` in that case, using
|
||||
the instance factory which was registered without a tag, but will pass `userName` as an argument).
|
||||
* view model will be created using `init(friendsProvider:webService:)` with `friendsProvider` and `webService` that have been
|
||||
already resolved by container.
|
||||
|
||||
When running your Unit tests target, it may be resolved with other instances, depending on how you registered your dependencies in your Test Case.
|
||||
|
||||
> Try to constrain calls to `resolve()` method to one place and try to use one call to `resolve()` to instantiate the whole graph of the dependencies.
|
||||
The same should be applied to dependencies registration - it should be performed with one call and should be done in one place.
|
||||
Don't scatter calls to container all around your code. Using `resolve` inside your implementations will be equal to creating dependencies directly and is actually against DI. Moreover it will drag the dependency on Dip everywhere and will make requirements of your types implicit instead of explicit.
|
||||
Instead you should combine use of container with DI patterns like _Constructor Injection_ and _Property Injection_. Any DI container is just a tool, not a goal.
|
||||
You should aplly DI patterns in your code first and only then think about using DI container as a tool to make dependencies management easier.
|
||||
You will find some other advices on how to use the container in the Playground.
|
||||
We hope that after reading this README and going through the Playground you will admit the benifits of DI and loose coupling that it enables whether you use Dip or not.
|
||||
|
||||
### Complete Example Project
|
||||
|
||||
You can find a complete example in the `Example/DipSampleApp` project provided in this repository.
|
||||
In addition to this Usage overview and to the aforementioned playground, you can also find a complete example in the `SampleApp/DipSampleApp` project provided in this repository.
|
||||
|
||||
This sample project is a bit more complex, but closer to real-world applications (even if this sample is all about StarWars!),
|
||||
by declaring protocols like `NetworkLayer` which can be resolved to a `URLSessionNetworkLayer` in the real app, but to a dummy
|
||||
@@ -163,7 +373,8 @@ This sample uses the Star Wars API provided by swapi.co to fetch Star Wars chara
|
||||
|
||||
## Credits
|
||||
|
||||
This library is authored by **Olivier Halligon**, olivier@halligon.net
|
||||
This library has been created by [**Olivier Halligon**](olivier@halligon.net).
|
||||
I'd also like to thank [**Ilya Puchka**](https://twitter.com/ilyapuchka) for his big contribution to it, as he added a lot of great features to it.
|
||||
|
||||
**Dip** is available under the **MIT license**. See the `LICENSE` file for more info.
|
||||
|
||||
|
||||
@@ -7,65 +7,61 @@
|
||||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
090012291BC6FECA0079C600 /* BaseCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012161BC6FECA0079C600 /* BaseCell.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
0900122A1BC6FECA0079C600 /* PersonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012171BC6FECA0079C600 /* PersonCell.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
0900122C1BC6FECA0079C600 /* PersonProviderAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900121B1BC6FECA0079C600 /* PersonProviderAPI.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
0900122D1BC6FECA0079C600 /* DummyPilotProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900121C1BC6FECA0079C600 /* DummyPilotProvider.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
0900122E1BC6FECA0079C600 /* HardCodedStarshipProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900121D1BC6FECA0079C600 /* HardCodedStarshipProvider.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
0900122F1BC6FECA0079C600 /* PlistPersonProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900121E1BC6FECA0079C600 /* PlistPersonProvider.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
0900123B1BC6FF4D0079C600 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0900123A1BC6FF4D0079C600 /* Main.storyboard */; settings = {ASSET_TAGS = (); }; };
|
||||
0900123D1BC7012A0079C600 /* StarshipProviderAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900123C1BC7012A0079C600 /* StarshipProviderAPI.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
090012401BC704C60079C600 /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900123F1BC704C60079C600 /* Person.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
090012421BC7059E0079C600 /* Starship.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012411BC7059E0079C600 /* Starship.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
090012441BC708A00079C600 /* DummyStarshipProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012431BC708A00079C600 /* DummyStarshipProvider.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
090012291BC6FECA0079C600 /* BaseCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012161BC6FECA0079C600 /* BaseCell.swift */; };
|
||||
0900122A1BC6FECA0079C600 /* PersonCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012171BC6FECA0079C600 /* PersonCell.swift */; };
|
||||
0900122C1BC6FECA0079C600 /* PersonProviderAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900121B1BC6FECA0079C600 /* PersonProviderAPI.swift */; };
|
||||
0900123B1BC6FF4D0079C600 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0900123A1BC6FF4D0079C600 /* Main.storyboard */; };
|
||||
0900123D1BC7012A0079C600 /* StarshipProviderAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900123C1BC7012A0079C600 /* StarshipProviderAPI.swift */; };
|
||||
090012401BC704C60079C600 /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900123F1BC704C60079C600 /* Person.swift */; };
|
||||
090012421BC7059E0079C600 /* Starship.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012411BC7059E0079C600 /* Starship.swift */; };
|
||||
0982AF081C503EEE00B62463 /* FakePersonsProviders.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982AF071C503EEE00B62463 /* FakePersonsProviders.swift */; };
|
||||
0982AF0A1C50401800B62463 /* FakeStarshipProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0982AF091C50401800B62463 /* FakeStarshipProvider.swift */; };
|
||||
099022621BC123C000E76F43 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 099022611BC123C000E76F43 /* AppDelegate.swift */; };
|
||||
099022691BC123C000E76F43 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 099022681BC123C000E76F43 /* Assets.xcassets */; };
|
||||
0990226C1BC123C000E76F43 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0990226A1BC123C000E76F43 /* LaunchScreen.storyboard */; };
|
||||
09D795FF1BC71F5A003C68EB /* PersonListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D795FE1BC71F5A003C68EB /* PersonListViewController.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796011BC722C0003C68EB /* StarshipListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796001BC722C0003C68EB /* StarshipListViewController.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796031BC72691003C68EB /* StarshipCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796021BC72691003C68EB /* StarshipCell.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796071BC73E8B003C68EB /* StoryboardConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796061BC73E8B003C68EB /* StoryboardConstants.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D7960D1BC7431C003C68EB /* FetchableTrait.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7960C1BC7431C003C68EB /* FetchableTrait.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796111BC97809003C68EB /* mainPilot.plist in Resources */ = {isa = PBXBuildFile; fileRef = 09D796101BC97809003C68EB /* mainPilot.plist */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796131BC9A5BC003C68EB /* SWAPIPersonProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796121BC9A5BC003C68EB /* SWAPIPersonProvider.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796151BC9A5FC003C68EB /* NetworkLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796141BC9A5FC003C68EB /* NetworkLayer.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796171BC9B53D003C68EB /* URLSessionNetworkLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796161BC9B53D003C68EB /* URLSessionNetworkLayer.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796191BC9BA49003C68EB /* DependencyContainers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796181BC9BA49003C68EB /* DependencyContainers.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D7961B1BC9BE65003C68EB /* SWAPIStarshipProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7961A1BC9BE65003C68EB /* SWAPIStarshipProvider.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D7961D1BC9C62E003C68EB /* SWAPICommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7961C1BC9C62E003C68EB /* SWAPICommon.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796221BCA8305003C68EB /* NetworkLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796141BC9A5FC003C68EB /* NetworkLayer.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796231BCA833E003C68EB /* SWAPIPersonProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796121BC9A5BC003C68EB /* SWAPIPersonProvider.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796241BCA8345003C68EB /* PersonProviderAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900121B1BC6FECA0079C600 /* PersonProviderAPI.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796251BCA8345003C68EB /* StarshipProviderAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900123C1BC7012A0079C600 /* StarshipProviderAPI.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796261BCA8348003C68EB /* SWAPIStarshipProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7961A1BC9BE65003C68EB /* SWAPIStarshipProvider.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796271BCA8550003C68EB /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900123F1BC704C60079C600 /* Person.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796281BCA8550003C68EB /* Starship.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012411BC7059E0079C600 /* Starship.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D796291BCA86D4003C68EB /* SWAPICommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7961C1BC9C62E003C68EB /* SWAPICommon.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D7962C1BCA8AD4003C68EB /* NetworkMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7962A1BCA8AB3003C68EB /* NetworkMock.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09D7962F1BCA922E003C68EB /* SWAPIStarshipProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7962D1BCA91D3003C68EB /* SWAPIStarshipProviderTests.swift */; settings = {ASSET_TAGS = (); }; };
|
||||
09B041B71C01F8CB000D383F /* Dip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09B041B61C01F8CB000D383F /* Dip.framework */; };
|
||||
09B041B81C01F8D1000D383F /* Dip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 09B041B61C01F8CB000D383F /* Dip.framework */; };
|
||||
09D795FF1BC71F5A003C68EB /* PersonListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D795FE1BC71F5A003C68EB /* PersonListViewController.swift */; };
|
||||
09D796011BC722C0003C68EB /* StarshipListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796001BC722C0003C68EB /* StarshipListViewController.swift */; };
|
||||
09D796031BC72691003C68EB /* StarshipCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796021BC72691003C68EB /* StarshipCell.swift */; };
|
||||
09D796071BC73E8B003C68EB /* StoryboardConstants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796061BC73E8B003C68EB /* StoryboardConstants.swift */; };
|
||||
09D7960D1BC7431C003C68EB /* FetchableTrait.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7960C1BC7431C003C68EB /* FetchableTrait.swift */; };
|
||||
09D796111BC97809003C68EB /* mainPilot.plist in Resources */ = {isa = PBXBuildFile; fileRef = 09D796101BC97809003C68EB /* mainPilot.plist */; };
|
||||
09D796131BC9A5BC003C68EB /* SWAPIPersonProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796121BC9A5BC003C68EB /* SWAPIPersonProvider.swift */; };
|
||||
09D796151BC9A5FC003C68EB /* NetworkLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796141BC9A5FC003C68EB /* NetworkLayer.swift */; };
|
||||
09D796171BC9B53D003C68EB /* URLSessionNetworkLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796161BC9B53D003C68EB /* URLSessionNetworkLayer.swift */; };
|
||||
09D796191BC9BA49003C68EB /* DependencyContainers.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796181BC9BA49003C68EB /* DependencyContainers.swift */; };
|
||||
09D7961B1BC9BE65003C68EB /* SWAPIStarshipProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7961A1BC9BE65003C68EB /* SWAPIStarshipProvider.swift */; };
|
||||
09D7961D1BC9C62E003C68EB /* SWAPICommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7961C1BC9C62E003C68EB /* SWAPICommon.swift */; };
|
||||
09D796221BCA8305003C68EB /* NetworkLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796141BC9A5FC003C68EB /* NetworkLayer.swift */; };
|
||||
09D796231BCA833E003C68EB /* SWAPIPersonProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D796121BC9A5BC003C68EB /* SWAPIPersonProvider.swift */; };
|
||||
09D796241BCA8345003C68EB /* PersonProviderAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900121B1BC6FECA0079C600 /* PersonProviderAPI.swift */; };
|
||||
09D796251BCA8345003C68EB /* StarshipProviderAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900123C1BC7012A0079C600 /* StarshipProviderAPI.swift */; };
|
||||
09D796261BCA8348003C68EB /* SWAPIStarshipProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7961A1BC9BE65003C68EB /* SWAPIStarshipProvider.swift */; };
|
||||
09D796271BCA8550003C68EB /* Person.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0900123F1BC704C60079C600 /* Person.swift */; };
|
||||
09D796281BCA8550003C68EB /* Starship.swift in Sources */ = {isa = PBXBuildFile; fileRef = 090012411BC7059E0079C600 /* Starship.swift */; };
|
||||
09D796291BCA86D4003C68EB /* SWAPICommon.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7961C1BC9C62E003C68EB /* SWAPICommon.swift */; };
|
||||
09D7962C1BCA8AD4003C68EB /* NetworkMock.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7962A1BCA8AB3003C68EB /* NetworkMock.swift */; };
|
||||
09D7962F1BCA922E003C68EB /* SWAPIStarshipProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 09D7962D1BCA91D3003C68EB /* SWAPIStarshipProviderTests.swift */; };
|
||||
607FACEC1AFB9204008FA782 /* SWAPIPersonProviderTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* SWAPIPersonProviderTests.swift */; };
|
||||
7BBD849465D99D9D1987AE6D /* Pods_DipTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 304AD039660A2C58EB08D985 /* Pods_DipTests.framework */; };
|
||||
84D8EBE5B2D583BEFB17C45A /* Pods_DipSampleApp.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 2FE9C70E965FF88C3F20AC76 /* Pods_DipSampleApp.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
090012161BC6FECA0079C600 /* BaseCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BaseCell.swift; sourceTree = "<group>"; };
|
||||
090012171BC6FECA0079C600 /* PersonCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersonCell.swift; sourceTree = "<group>"; };
|
||||
0900121B1BC6FECA0079C600 /* PersonProviderAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersonProviderAPI.swift; sourceTree = "<group>"; };
|
||||
0900121C1BC6FECA0079C600 /* DummyPilotProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DummyPilotProvider.swift; sourceTree = "<group>"; };
|
||||
0900121D1BC6FECA0079C600 /* HardCodedStarshipProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HardCodedStarshipProvider.swift; sourceTree = "<group>"; };
|
||||
0900121E1BC6FECA0079C600 /* PlistPersonProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PlistPersonProvider.swift; sourceTree = "<group>"; };
|
||||
0900123A1BC6FF4D0079C600 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = "<group>"; };
|
||||
0900123C1BC7012A0079C600 /* StarshipProviderAPI.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StarshipProviderAPI.swift; sourceTree = "<group>"; };
|
||||
0900123F1BC704C60079C600 /* Person.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Person.swift; sourceTree = "<group>"; };
|
||||
090012411BC7059E0079C600 /* Starship.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Starship.swift; sourceTree = "<group>"; };
|
||||
090012431BC708A00079C600 /* DummyStarshipProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DummyStarshipProvider.swift; sourceTree = "<group>"; };
|
||||
097D52FE1BC18A09006C893C /* CHANGELOG.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; name = CHANGELOG.md; path = ../CHANGELOG.md; sourceTree = "<group>"; };
|
||||
0982AF071C503EEE00B62463 /* FakePersonsProviders.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakePersonsProviders.swift; sourceTree = "<group>"; };
|
||||
0982AF091C50401800B62463 /* FakeStarshipProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FakeStarshipProvider.swift; sourceTree = "<group>"; };
|
||||
0990225F1BC123C000E76F43 /* DipSampleApp.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DipSampleApp.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
099022611BC123C000E76F43 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
|
||||
099022681BC123C000E76F43 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
|
||||
0990226B1BC123C000E76F43 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
|
||||
0990226D1BC123C000E76F43 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
09B041B61C01F8CB000D383F /* Dip.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Dip.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
09D795FE1BC71F5A003C68EB /* PersonListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PersonListViewController.swift; sourceTree = "<group>"; };
|
||||
09D796001BC722C0003C68EB /* StarshipListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StarshipListViewController.swift; sourceTree = "<group>"; };
|
||||
09D796021BC72691003C68EB /* StarshipCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StarshipCell.swift; sourceTree = "<group>"; };
|
||||
@@ -80,18 +76,9 @@
|
||||
09D7961C1BC9C62E003C68EB /* SWAPICommon.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SWAPICommon.swift; sourceTree = "<group>"; };
|
||||
09D7962A1BCA8AB3003C68EB /* NetworkMock.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NetworkMock.swift; sourceTree = "<group>"; };
|
||||
09D7962D1BCA91D3003C68EB /* SWAPIStarshipProviderTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SWAPIStarshipProviderTests.swift; sourceTree = "<group>"; };
|
||||
2FE9C70E965FF88C3F20AC76 /* Pods_DipSampleApp.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DipSampleApp.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
304AD039660A2C58EB08D985 /* Pods_DipTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_DipTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
607FACE51AFB9204008FA782 /* DipTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DipTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
607FACE51AFB9204008FA782 /* DipSampleAppTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = DipSampleAppTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
607FACEB1AFB9204008FA782 /* SWAPIPersonProviderTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SWAPIPersonProviderTests.swift; sourceTree = "<group>"; };
|
||||
64B6CB26CB93DFD18565BB72 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
|
||||
6AB71DAFECF410F2FB12A44C /* Pods-DipSampleApp.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DipSampleApp.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DipSampleApp/Pods-DipSampleApp.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
7E5EDFB4A9194B50CAED7E1A /* Pods-DipTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DipTests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-DipTests/Pods-DipTests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
9B78063878AFC700C876DEE9 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
|
||||
B16085421B606723B72DE694 /* Pods-DipSampleApp.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DipSampleApp.release.xcconfig"; path = "Pods/Target Support Files/Pods-DipSampleApp/Pods-DipSampleApp.release.xcconfig"; sourceTree = "<group>"; };
|
||||
D9BBF14E74848332935F75C4 /* Pods-DipTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-DipTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-DipTests/Pods-DipTests.release.xcconfig"; sourceTree = "<group>"; };
|
||||
FDB7C1D2EFEC1BA700762782 /* Dip.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = Dip.podspec; path = ../Dip.podspec; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -99,7 +86,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
84D8EBE5B2D583BEFB17C45A /* Pods_DipSampleApp.framework in Frameworks */,
|
||||
09B041B71C01F8CB000D383F /* Dip.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -107,7 +94,7 @@
|
||||
isa = PBXFrameworksBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
7BBD849465D99D9D1987AE6D /* Pods_DipTests.framework in Frameworks */,
|
||||
09B041B81C01F8D1000D383F /* Dip.framework in Frameworks */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -159,8 +146,7 @@
|
||||
090012381BC6FEFD0079C600 /* PersonProviders */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
0900121C1BC6FECA0079C600 /* DummyPilotProvider.swift */,
|
||||
0900121E1BC6FECA0079C600 /* PlistPersonProvider.swift */,
|
||||
0982AF071C503EEE00B62463 /* FakePersonsProviders.swift */,
|
||||
09D796121BC9A5BC003C68EB /* SWAPIPersonProvider.swift */,
|
||||
);
|
||||
name = PersonProviders;
|
||||
@@ -169,8 +155,7 @@
|
||||
090012391BC6FF080079C600 /* StarshipProviders */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
090012431BC708A00079C600 /* DummyStarshipProvider.swift */,
|
||||
0900121D1BC6FECA0079C600 /* HardCodedStarshipProvider.swift */,
|
||||
0982AF091C50401800B62463 /* FakeStarshipProvider.swift */,
|
||||
09D7961A1BC9BE65003C68EB /* SWAPIStarshipProvider.swift */,
|
||||
);
|
||||
name = StarshipProviders;
|
||||
@@ -207,8 +192,7 @@
|
||||
1A92CB92072DE61786F63E4C /* Frameworks */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2FE9C70E965FF88C3F20AC76 /* Pods_DipSampleApp.framework */,
|
||||
304AD039660A2C58EB08D985 /* Pods_DipTests.framework */,
|
||||
09B041B61C01F8CB000D383F /* Dip.framework */,
|
||||
);
|
||||
name = Frameworks;
|
||||
sourceTree = "<group>";
|
||||
@@ -216,19 +200,17 @@
|
||||
607FACC71AFB9204008FA782 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
607FACF51AFB993E008FA782 /* Podspec Metadata */,
|
||||
099022601BC123C000E76F43 /* DipSampleApp */,
|
||||
607FACE81AFB9204008FA782 /* Tests */,
|
||||
607FACD11AFB9204008FA782 /* Products */,
|
||||
1A92CB92072DE61786F63E4C /* Frameworks */,
|
||||
B10E0DA4AD9E022CCA0B272F /* Pods */,
|
||||
);
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACD11AFB9204008FA782 /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
607FACE51AFB9204008FA782 /* DipTests.xctest */,
|
||||
607FACE51AFB9204008FA782 /* DipSampleAppTests.xctest */,
|
||||
0990225F1BC123C000E76F43 /* DipSampleApp.app */,
|
||||
);
|
||||
name = Products;
|
||||
@@ -253,28 +235,6 @@
|
||||
name = "Supporting Files";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
607FACF51AFB993E008FA782 /* Podspec Metadata */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
FDB7C1D2EFEC1BA700762782 /* Dip.podspec */,
|
||||
64B6CB26CB93DFD18565BB72 /* README.md */,
|
||||
097D52FE1BC18A09006C893C /* CHANGELOG.md */,
|
||||
9B78063878AFC700C876DEE9 /* LICENSE */,
|
||||
);
|
||||
name = "Podspec Metadata";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
B10E0DA4AD9E022CCA0B272F /* Pods */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
6AB71DAFECF410F2FB12A44C /* Pods-DipSampleApp.debug.xcconfig */,
|
||||
B16085421B606723B72DE694 /* Pods-DipSampleApp.release.xcconfig */,
|
||||
7E5EDFB4A9194B50CAED7E1A /* Pods-DipTests.debug.xcconfig */,
|
||||
D9BBF14E74848332935F75C4 /* Pods-DipTests.release.xcconfig */,
|
||||
);
|
||||
name = Pods;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
@@ -282,12 +242,9 @@
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 0990226E1BC123C000E76F43 /* Build configuration list for PBXNativeTarget "DipSampleApp" */;
|
||||
buildPhases = (
|
||||
52BA3DF5A38A73C99738362E /* Check Pods Manifest.lock */,
|
||||
0990225B1BC123C000E76F43 /* Sources */,
|
||||
0990225C1BC123C000E76F43 /* Frameworks */,
|
||||
0990225D1BC123C000E76F43 /* Resources */,
|
||||
586A7844323215ADA94020FD /* Embed Pods Frameworks */,
|
||||
8665FFA2238FD898C8846391 /* Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
@@ -298,24 +255,21 @@
|
||||
productReference = 0990225F1BC123C000E76F43 /* DipSampleApp.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
607FACE41AFB9204008FA782 /* DipTests */ = {
|
||||
607FACE41AFB9204008FA782 /* DipSampleAppTests */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "DipTests" */;
|
||||
buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "DipSampleAppTests" */;
|
||||
buildPhases = (
|
||||
5CA726E6162DF780766DC6CA /* Check Pods Manifest.lock */,
|
||||
607FACE11AFB9204008FA782 /* Sources */,
|
||||
607FACE21AFB9204008FA782 /* Frameworks */,
|
||||
607FACE31AFB9204008FA782 /* Resources */,
|
||||
7982A68D936539C16CA74E2D /* Embed Pods Frameworks */,
|
||||
B0AB134AABD1E8CE42E5A2EC /* Copy Pods Resources */,
|
||||
);
|
||||
buildRules = (
|
||||
);
|
||||
dependencies = (
|
||||
);
|
||||
name = DipTests;
|
||||
name = DipSampleAppTests;
|
||||
productName = Tests;
|
||||
productReference = 607FACE51AFB9204008FA782 /* DipTests.xctest */;
|
||||
productReference = 607FACE51AFB9204008FA782 /* DipSampleAppTests.xctest */;
|
||||
productType = "com.apple.product-type.bundle.unit-test";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
@@ -336,7 +290,7 @@
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "Dip" */;
|
||||
buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "DipSampleApp" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 0;
|
||||
@@ -350,7 +304,7 @@
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
0990225E1BC123C000E76F43 /* DipSampleApp */,
|
||||
607FACE41AFB9204008FA782 /* DipTests */,
|
||||
607FACE41AFB9204008FA782 /* DipSampleAppTests */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@@ -376,124 +330,29 @@
|
||||
};
|
||||
/* End PBXResourcesBuildPhase section */
|
||||
|
||||
/* Begin PBXShellScriptBuildPhase section */
|
||||
52BA3DF5A38A73C99738362E /* Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
586A7844323215ADA94020FD /* Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DipSampleApp/Pods-DipSampleApp-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
5CA726E6162DF780766DC6CA /* Check Pods Manifest.lock */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Check Pods Manifest.lock";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [[ $? != 0 ]] ; then\n cat << EOM\nerror: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\nEOM\n exit 1\nfi\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
7982A68D936539C16CA74E2D /* Embed Pods Frameworks */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Embed Pods Frameworks";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DipTests/Pods-DipTests-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
8665FFA2238FD898C8846391 /* Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DipSampleApp/Pods-DipSampleApp-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
B0AB134AABD1E8CE42E5A2EC /* Copy Pods Resources */ = {
|
||||
isa = PBXShellScriptBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
);
|
||||
inputPaths = (
|
||||
);
|
||||
name = "Copy Pods Resources";
|
||||
outputPaths = (
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-DipTests/Pods-DipTests-resources.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
/* Begin PBXSourcesBuildPhase section */
|
||||
0990225B1BC123C000E76F43 /* Sources */ = {
|
||||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
09D796151BC9A5FC003C68EB /* NetworkLayer.swift in Sources */,
|
||||
0982AF081C503EEE00B62463 /* FakePersonsProviders.swift in Sources */,
|
||||
09D795FF1BC71F5A003C68EB /* PersonListViewController.swift in Sources */,
|
||||
0900122A1BC6FECA0079C600 /* PersonCell.swift in Sources */,
|
||||
09D796011BC722C0003C68EB /* StarshipListViewController.swift in Sources */,
|
||||
0900122C1BC6FECA0079C600 /* PersonProviderAPI.swift in Sources */,
|
||||
09D7961D1BC9C62E003C68EB /* SWAPICommon.swift in Sources */,
|
||||
090012291BC6FECA0079C600 /* BaseCell.swift in Sources */,
|
||||
0900122D1BC6FECA0079C600 /* DummyPilotProvider.swift in Sources */,
|
||||
099022621BC123C000E76F43 /* AppDelegate.swift in Sources */,
|
||||
09D796131BC9A5BC003C68EB /* SWAPIPersonProvider.swift in Sources */,
|
||||
090012421BC7059E0079C600 /* Starship.swift in Sources */,
|
||||
0900123D1BC7012A0079C600 /* StarshipProviderAPI.swift in Sources */,
|
||||
0982AF0A1C50401800B62463 /* FakeStarshipProvider.swift in Sources */,
|
||||
09D7961B1BC9BE65003C68EB /* SWAPIStarshipProvider.swift in Sources */,
|
||||
0900122E1BC6FECA0079C600 /* HardCodedStarshipProvider.swift in Sources */,
|
||||
09D796071BC73E8B003C68EB /* StoryboardConstants.swift in Sources */,
|
||||
09D796031BC72691003C68EB /* StarshipCell.swift in Sources */,
|
||||
090012401BC704C60079C600 /* Person.swift in Sources */,
|
||||
090012441BC708A00079C600 /* DummyStarshipProvider.swift in Sources */,
|
||||
09D7960D1BC7431C003C68EB /* FetchableTrait.swift in Sources */,
|
||||
0900122F1BC6FECA0079C600 /* PlistPersonProvider.swift in Sources */,
|
||||
09D796191BC9BA49003C68EB /* DependencyContainers.swift in Sources */,
|
||||
09D796171BC9B53D003C68EB /* URLSessionNetworkLayer.swift in Sources */,
|
||||
);
|
||||
@@ -533,7 +392,6 @@
|
||||
/* Begin XCBuildConfiguration section */
|
||||
0990226F1BC123C000E76F43 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 6AB71DAFECF410F2FB12A44C /* Pods-DipSampleApp.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||
@@ -549,7 +407,6 @@
|
||||
};
|
||||
099022701BC123C000E76F43 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = B16085421B606723B72DE694 /* Pods-DipSampleApp.release.xcconfig */;
|
||||
buildSettings = {
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
INFOPLIST_FILE = DipSampleApp/Info.plist;
|
||||
@@ -645,7 +502,6 @@
|
||||
};
|
||||
607FACF31AFB9204008FA782 /* Debug */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = 7E5EDFB4A9194B50CAED7E1A /* Pods-DipTests.debug.xcconfig */;
|
||||
buildSettings = {
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"DEBUG=1",
|
||||
@@ -660,7 +516,6 @@
|
||||
};
|
||||
607FACF41AFB9204008FA782 /* Release */ = {
|
||||
isa = XCBuildConfiguration;
|
||||
baseConfigurationReference = D9BBF14E74848332935F75C4 /* Pods-DipTests.release.xcconfig */;
|
||||
buildSettings = {
|
||||
INFOPLIST_FILE = Tests/Info.plist;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||
@@ -681,7 +536,7 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "Dip" */ = {
|
||||
607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "DipSampleApp" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
607FACED1AFB9204008FA782 /* Debug */,
|
||||
@@ -690,7 +545,7 @@
|
||||
defaultConfigurationIsVisible = 0;
|
||||
defaultConfigurationName = Release;
|
||||
};
|
||||
607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "DipTests" */ = {
|
||||
607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "DipSampleAppTests" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
607FACF31AFB9204008FA782 /* Debug */,
|
||||
@@ -17,7 +17,7 @@
|
||||
BlueprintIdentifier = "0990225E1BC123C000E76F43"
|
||||
BuildableName = "DipSampleApp.app"
|
||||
BlueprintName = "DipSampleApp"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
ReferencedContainer = "container:DipSampleApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
<BuildActionEntry
|
||||
@@ -29,9 +29,9 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACE41AFB9204008FA782"
|
||||
BuildableName = "DipTests.xctest"
|
||||
BlueprintName = "DipTests"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
BuildableName = "DipSampleAppTests.xctest"
|
||||
BlueprintName = "DipSampleAppTests"
|
||||
ReferencedContainer = "container:DipSampleApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildActionEntry>
|
||||
</BuildActionEntries>
|
||||
@@ -48,9 +48,9 @@
|
||||
<BuildableReference
|
||||
BuildableIdentifier = "primary"
|
||||
BlueprintIdentifier = "607FACE41AFB9204008FA782"
|
||||
BuildableName = "DipTests.xctest"
|
||||
BlueprintName = "DipTests"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
BuildableName = "DipSampleAppTests.xctest"
|
||||
BlueprintName = "DipSampleAppTests"
|
||||
ReferencedContainer = "container:DipSampleApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</TestableReference>
|
||||
</Testables>
|
||||
@@ -60,7 +60,7 @@
|
||||
BlueprintIdentifier = "0990225E1BC123C000E76F43"
|
||||
BuildableName = "DipSampleApp.app"
|
||||
BlueprintName = "DipSampleApp"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
ReferencedContainer = "container:DipSampleApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</MacroExpansion>
|
||||
<AdditionalOptions>
|
||||
@@ -83,7 +83,7 @@
|
||||
BlueprintIdentifier = "0990225E1BC123C000E76F43"
|
||||
BuildableName = "DipSampleApp.app"
|
||||
BlueprintName = "DipSampleApp"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
ReferencedContainer = "container:DipSampleApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
<AdditionalOptions>
|
||||
@@ -102,7 +102,7 @@
|
||||
BlueprintIdentifier = "0990225E1BC123C000E76F43"
|
||||
BuildableName = "DipSampleApp.app"
|
||||
BlueprintName = "DipSampleApp"
|
||||
ReferencedContainer = "container:Dip.xcodeproj">
|
||||
ReferencedContainer = "container:DipSampleApp.xcodeproj">
|
||||
</BuildableReference>
|
||||
</BuildableProductRunnable>
|
||||
</ProfileAction>
|
||||
@@ -7,21 +7,34 @@
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import Dip
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
|
||||
var window: UIWindow?
|
||||
|
||||
private let container = DependencyContainer()
|
||||
|
||||
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
|
||||
//This is a composition root where container is configured and all dependencies are resolved
|
||||
configureContainer(container)
|
||||
|
||||
let personProvider = try! container.resolve() as PersonProviderAPI
|
||||
let starshipProvider = try! container.resolve() as StarshipProviderAPI
|
||||
|
||||
if let tabBarVC = self.window?.rootViewController as? UITabBarController,
|
||||
let vcs = tabBarVC.viewControllers as? [UINavigationController] {
|
||||
if let personListVC = vcs[0].topViewController as? PersonListViewController {
|
||||
personListVC.personProvider = personProvider
|
||||
personListVC.starshipProvider = starshipProvider
|
||||
personListVC.loadFirstPage()
|
||||
}
|
||||
if let starshipListVC = vcs[1].topViewController as? StarshipListViewController {
|
||||
starshipListVC.starshipProvider = starshipProvider
|
||||
starshipListVC.personProvider = personProvider
|
||||
starshipListVC.loadFirstPage()
|
||||
}
|
||||
}
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 277 KiB After Width: | Height: | Size: 277 KiB |
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 2.3 KiB |