Expose the `.bundle` product type (#479)
Part of https://github.com/tuist/tuist/issues/290 - Tuist support iOS resouce bundles - This can now be leveraged via specifying `.bundle` product types - Fixture has been updated to show case how this can be used Test Plan: - Run `tuist generate` within `fixtures/ios_app_with_framework_and_resources` - Verify the project `StaticFramework` has a bundle target called `StaticFrameworkResources` which includes resources - Verify the `StaticFrameworkResources` bundle is copied as a resouce in the App - Verify running the app prints out descriptions for images within `StaticFrameworkResources`
This commit is contained in:
parent
915f59f236
commit
1cbb9b402e
|
@ -18,6 +18,7 @@ Please, check out guidelines: https://keepachangelog.com/en/1.0.0/
|
|||
- Support for CocoaPods dependencies https://github.com/tuist/tuist/pull/465 by @pepibumur
|
||||
- Support custom .xcodeproj name at the model level https://github.com/tuist/tuist/pull/462 by @adamkhazi
|
||||
- `TuistConfig.compatibleXcodeVersions` support https://github.com/tuist/tuist/pull/476 by @pepibumur.
|
||||
- Expose the `.bundle` product type https://github.com/tuist/tuist/pull/479 by @kwridan
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ public enum Product: String, Codable {
|
|||
case staticFramework
|
||||
case unitTests = "unit_tests"
|
||||
case uiTests = "ui_tests"
|
||||
case bundle
|
||||
|
||||
// Not supported yet
|
||||
// case appExtension
|
||||
|
|
|
@ -644,6 +644,8 @@ extension TuistGenerator.Product {
|
|||
return .unitTests
|
||||
case .uiTests:
|
||||
return .uiTests
|
||||
case .bundle:
|
||||
return .bundle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -857,6 +857,7 @@ private func == (_ lhs: TuistGenerator.Product,
|
|||
.uiTests: .uiTests,
|
||||
.staticLibrary: .staticLibrary,
|
||||
.dynamicLibrary: .dynamicLibrary,
|
||||
.bundle: .bundle,
|
||||
]
|
||||
return map[lhs] == rhs
|
||||
}
|
||||
|
|
|
@ -402,6 +402,10 @@ The platform type represents the platform a target is built for. It can be any o
|
|||
case: '.uiTests',
|
||||
description: 'A UI tests bundle.',
|
||||
},
|
||||
{
|
||||
case: '.bundle',
|
||||
description: 'A custom bundle. (Currently only iOS resource bundles are supported)',
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
||||
|
|
|
@ -114,6 +114,8 @@ Scenario: The project is an iOS application that has resources (ios_app_with_fra
|
|||
Then the product 'App.app' with destination 'Debug-iphoneos' contains resource 'fr.lproj/Greetings.strings'
|
||||
Then the product 'App.app' with destination 'Debug-iphoneos' contains resource 'resource_without_extension'
|
||||
Then the product 'App.app' with destination 'Debug-iphoneos' does not contain resource 'do_not_include.dat'
|
||||
Then the product 'App.app' with destination 'Debug-iphoneos' contains resource 'StaticFrameworkResources.bundle'
|
||||
Then the product 'StaticFrameworkResources.bundle' with destination 'Debug-iphoneos' contains resource 'tuist-bundle.png'
|
||||
|
||||
Scenario: The project is an iOS application with frameworks and tests (ios_app_with_framework_linking_static_framework)
|
||||
Given that tuist is available
|
||||
|
|
|
@ -65,11 +65,16 @@ Workspace:
|
|||
- MainAppTests (iOS unit tests)
|
||||
- Framework1:
|
||||
- Framework1 (dynamic iOS framework)
|
||||
- StaticFramework
|
||||
- StaticFramework (static iOS framework)
|
||||
- StaticFrameworkResources (iOS bundle)
|
||||
```
|
||||
|
||||
Dependencies:
|
||||
|
||||
- App -> Framework1
|
||||
- App -> StaticFramework
|
||||
- App -> StaticFrameworkResources
|
||||
|
||||
## ios_app_with_framework_linking_static_framework
|
||||
|
||||
|
|
|
@ -20,6 +20,8 @@ let project = Project(
|
|||
],
|
||||
dependencies: [
|
||||
.project(target: "Framework1", path: "../Framework1"),
|
||||
.project(target: "StaticFramework", path: "../StaticFramework"),
|
||||
.project(target: "StaticFrameworkResources", path: "../StaticFramework"),
|
||||
]
|
||||
),
|
||||
Target(
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
import Framework1
|
||||
import UIKit
|
||||
import StaticFramework
|
||||
|
||||
@UIApplicationMain
|
||||
class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
let staticFrameworkResources = StaticFrameworkResouces()
|
||||
|
||||
func applicationDidFinishLaunching(_: UIApplication) {
|
||||
let framework1 = Framework1File()
|
||||
|
||||
print(hello())
|
||||
print("AppDelegate -> \(framework1.hello())")
|
||||
print("Image: \(UIImage(named: "tuist"))")
|
||||
print("Main bundle image: \(String(describing: UIImage(named: "tuist")))")
|
||||
print("StaticFrameworkResouce image: \(String(describing: staticFrameworkResources.tuist))")
|
||||
}
|
||||
|
||||
|
||||
func hello() -> String {
|
||||
return "AppDelegate.hello()"
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?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>$(DEVELOPMENT_LANGUAGE)</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>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>Copyright ©. All rights reserved.</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,22 @@
|
|||
<?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>$(DEVELOPMENT_LANGUAGE)</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>BNDL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,20 @@
|
|||
import ProjectDescription
|
||||
|
||||
let project = Project(name: "StaticFramework",
|
||||
targets: [
|
||||
Target(name: "StaticFramework",
|
||||
platform: .iOS,
|
||||
product: .staticFramework,
|
||||
bundleId: "io.tuist.StaticFramework",
|
||||
infoPlist: "Config/StaticFramework-Info.plist",
|
||||
sources: "Sources/**",
|
||||
dependencies: []),
|
||||
Target(name: "StaticFrameworkResources",
|
||||
platform: .iOS,
|
||||
product: .bundle,
|
||||
bundleId: "io.tuist.StaticFrameworkResources",
|
||||
infoPlist: "Config/StaticFrameworkResources-Info.plist",
|
||||
sources: [],
|
||||
resources: "Resources/**",
|
||||
dependencies: []),
|
||||
])
|
Binary file not shown.
After Width: | Height: | Size: 93 KiB |
|
@ -0,0 +1,24 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
|
||||
public class StaticFrameworkResouces {
|
||||
private var bundle: Bundle {
|
||||
let path = Bundle.main.path(forResource: "StaticFrameworkResources", ofType: "bundle")
|
||||
|
||||
guard let bundle = path.flatMap({ Bundle(path: $0) }) else {
|
||||
fatalError("StaticFrameworkResouces could not be loaded")
|
||||
}
|
||||
|
||||
return bundle
|
||||
}
|
||||
|
||||
public init() {
|
||||
|
||||
}
|
||||
|
||||
public var tuist: UIImage? {
|
||||
return UIImage(named: "tuist-bundle",
|
||||
in: bundle,
|
||||
compatibleWith: nil)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue