Skip to content

Commit

Permalink
Revert "Change FRAMEWORK_SEARCH_PATH for xcframeworks (yonaskolb#1015)…
Browse files Browse the repository at this point in the history
…" (yonaskolb#1081)

* Revert "Change FRAMEWORK_SEARCH_PATH for xcframeworks (yonaskolb#1015)"

This reverts commit 7b8f5a1.

* Don't actually revert the changelog entry

* ProjectSpec.md: document how to link an xcframework

* Update CHANGELOG.md
  • Loading branch information
elliottwilliams committed May 22, 2021
1 parent 938b826 commit 8bfa2f3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 56 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#### Fixed
- Added `()` to config variant trimming charater set to fix scheme config variant lookups for some configs like `Debug (Development)` that broke in 2.22.0 [#1078](https://github.com/yonaskolb/XcodeGen/pull/1078) @DavidWoohyunLee
- Fixed Linux builds on Swift 5.4 [#1083](https://github.com/yonaskolb/XcodeGen/pull/1083) @yonaskolb
- Reverted "Change FRAMEWORK_SEARCH_PATH for xcframeworks (#1015)", introduced in 2.20.0. XCFrameworks need to be
referenced directly in the project for Xcode's build system to extract the appropriate frameworks [#1081](https://github.com/yonaskolb/XcodeGen/pull/1081) @elliottwilliams

## 2.22.0

Expand Down
13 changes: 8 additions & 5 deletions Docs/ProjectSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ Note that target names can also be changed by adding a `name` property to a targ
- [ ] **groupOrdering**: **[[GroupOrdering]](#groupOrdering)** - An order of groups.
- [ ] **transitivelyLinkDependencies**: **Bool** - If this is `true` then targets will link to the dependencies of their target dependencies. If a target should embed its dependencies, such as application and test bundles, it will embed these transitive dependencies as well. Some complex setups might want to set this to `false` and explicitly specify dependencies at every level. Targets can override this with [Target](#target).transitivelyLinkDependencies. Defaults to `false`.
- [ ] **generateEmptyDirectories**: **Bool** - If this is `true` then empty directories will be added to project too else will be missed. Defaults to `false`.
- [ ] **findCarthageFrameworks**: **Bool** - When this is set to `true`, all the invididual frameworks for Carthage dependencies will automatically be found. This property can be overriden individually for each carthage dependency - for more details see See **findFrameworks** in the [Dependency](#dependency) section. Defaults to `false`.
- [ ] **findCarthageFrameworks**: **Bool** - When this is set to `true`, all the invididual frameworks for Carthage framework dependencies will automatically be found. This property can be overriden individually for each carthage dependency - for more details see See **findFrameworks** in the [Dependency](#dependency) section. Defaults to `false`.
- [ ] **localPackagesGroup**: **String** - The group name that local packages are put into. This defaults to `Packages`
- [ ] **fileTypes**: **[String: [FileType](#filetype)]** - A list of default file options for specific file extensions across the project. Values in [Sources](#sources) will overwrite these settings.
- [ ] **preGenCommand**: **String** - A bash command to run before the project has been generated. If the project isn't generated due to no changes when using the cache then this won't run. This is useful for running things like generating resources files before the project is regenerated.
Expand Down Expand Up @@ -232,7 +232,7 @@ Settings are merged in the following order: groups, base, configs.
- [ ] **configFiles**: **[Config Files](#config-files)** - `.xcconfig` files per config
- [ ] **settings**: **[Settings](#settings)** - Target specific build settings. Default platform and product type settings will be applied first before any custom settings defined here. Other context dependant settings will be set automatically as well:
- `INFOPLIST_FILE`: If it doesn't exist your sources will be searched for `Info.plist` files and the first one found will be used for this setting
- `FRAMEWORK_SEARCH_PATHS`: If carthage dependencies are used, the platform build path will be added to this setting
- `FRAMEWORK_SEARCH_PATHS`: If carthage framework dependencies are used, the platform build path will be added to this setting
- `OTHER_LDFLAGS`: See `requiresObjCLinking` below
- `TEST_TARGET_NAME`: for ui tests that target an application
- `TEST_HOST`: for unit tests that target an application
Expand All @@ -250,7 +250,7 @@ Settings are merged in the following order: groups, base, configs.
- [ ] **templates**: **[String]** - A list of [Target Templates](#target-template) referenced by name that will be merged with the target in order. Any instances of `${target_name}` within these templates will be replaced with the target name.
- [ ] **templateAttributes**: **[String: String]** - A list of attributes where each instance of `${attributeName}` within the templates listed in `templates` will be replaced with the value specified.
- [ ] **transitivelyLinkDependencies**: **Bool** - If this is not specified the value from the project set in [Options](#options)`.transitivelyLinkDependencies` will be used.
- [ ] **directlyEmbedCarthageDependencies**: **Bool** - If this is `true` Carthage dependencies will be embedded using an `Embed Frameworks` build phase instead of the `copy-frameworks` script. Defaults to `true` for all targets except iOS/tvOS/watchOS Applications.
- [ ] **directlyEmbedCarthageDependencies**: **Bool** - If this is `true` Carthage framework dependencies will be embedded using an `Embed Frameworks` build phase instead of the `copy-frameworks` script. Defaults to `true` for all targets except iOS/tvOS/watchOS Applications.
- [ ] **requiresObjCLinking**: **Bool** - If this is `true` any targets that link to this target will have `-ObjC` added to their `OTHER_LDFLAGS`. This is required if a static library has any catagories or extensions on Objective-C code. See [this guide](https://pewpewthespells.com/blog/objc_linker_flags.html#objc) for more details. Defaults to `true` if `type` is `library.static`. If you are 100% sure you don't have catagories or extensions on Objective-C code (pure Swift with no use of Foundation/UIKit) you can set this to `false`, otherwise it's best to leave it alone.
- [ ] **onlyCopyFilesOnInstall**: **Bool** – If this is `true`, the `Embed Frameworks` and `Embed App Extensions` (if available) build phases will have the "Copy only when installing" chekbox checked. Defaults to `false`.
- [ ] **preBuildScripts**: **[[Build Script](#build-script)]** - Build scripts that run *before* any other build phases
Expand Down Expand Up @@ -415,8 +415,8 @@ targets:
A dependency can be one of a 6 types:

- `target: name` - links to another target. If you are using project references you can specify a target within another project by using `ProjectName/TargetName` for the name
- `framework: path` - links to a framework
- `carthage: name` - helper for linking to a Carthage framework
- `framework: path` - links to a framework or XCFramework
- `carthage: name` - helper for linking to a Carthage framework (not XCFramework)
- `sdk: name` - links to a dependency with the SDK. This can either be a relative path within the sdk root or a single filename that references a framework (.framework) or lib (.tbd)
- `package: name` - links to a Swift Package. The name must match the name of a package defined in the top level `packages`
- `bundle: name` - adds the pre-built bundle for the supplied name to the copy resources build phase. This is useful when a dependency exists on a static library target that has an associated bundle target, both existing in a separate project. Only usable in target types which can copy resources.
Expand Down Expand Up @@ -447,6 +447,9 @@ Carthage frameworks are expected to be in `CARTHAGE_BUILD_PATH/PLATFORM/FRAMEWOR
- `PLATFORM` = the target's platform
- `FRAMEWORK` = the specified name.

To link an XCFramework produced by Carthage (in `CARTHAGE_BUILD_PATH/FRAMEWORK.xcframework`), use a normal `framework:`
dependency. The helper logic provided by this dependency type is not necessary.

All the individual frameworks of a Carthage dependency can be automatically found via `findFrameworks: true`. This overrides the value of [Options](#options).findCarthageFrameworks. Otherwise each one will have to be listed individually.
Xcodegen uses `.version` files generated by Carthage in order for this framework lookup to work, so the Carthage dependencies will need to have already been built at the time XcodeGen is run.

Expand Down
14 changes: 2 additions & 12 deletions Sources/XcodeGenKit/PBXProjGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -769,19 +769,9 @@ public class PBXProjGenerator {

case .framework:
if !dependency.implicit {
let buildPath = Path(dependency.reference)
let buildPathString: String

if buildPath.extension == "xcframework" {
buildPathString = """
"\(Path(dependency.reference).string)/**"
"""
} else {
buildPathString = buildPath.parent().string.quoted
}
frameworkBuildPaths.insert(buildPathString)
let buildPath = Path(dependency.reference).parent().string.quoted
frameworkBuildPaths.insert(buildPath)
}


let fileReference: PBXFileElement
if dependency.implicit {
Expand Down
39 changes: 0 additions & 39 deletions Tests/XcodeGenKitTests/ProjectGeneratorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1369,45 +1369,6 @@ class ProjectGeneratorTests: XCTestCase {
// generated plist should not be in buildsettings
try expect(targetConfig.buildSettings["INFOPLIST_FILE"] as? String) == predefinedPlistPath
}

describe("XCFramework dependencies") {
$0.context("with xcframework dependency") {
$0.it("should add FRAMEWORK_SEARCH_PATHS") {
let app = Target(
name: "MyApp",
type: .application,
platform: .iOS,
dependencies: [
Dependency(type: .framework, reference: "some/folder/MyXCFramework.xcframework"),
]
)
let project = Project(name: "test", targets: [app])
let pbxProject = try project.generatePbxProj()

let target = pbxProject.nativeTargets.first!
let configuration = target.buildConfigurationList!.buildConfigurations.first!
try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "\"some/folder/MyXCFramework.xcframework/**\""]
}
}
$0.context("with regular framework") {
$0.it("should add FRAMEWORK_SEARCH_PATHS") {
let app = Target(
name: "MyApp",
type: .application,
platform: .iOS,
dependencies: [
Dependency(type: .framework, reference: "some/folder/MyXCFramework.framework"),
]
)
let project = Project(name: "test", targets: [app])
let pbxProject = try project.generatePbxProj()

let target = pbxProject.nativeTargets.first!
let configuration = target.buildConfigurationList!.buildConfigurations.first!
try expect(configuration.buildSettings["FRAMEWORK_SEARCH_PATHS"] as? [String]) == ["$(inherited)", "\"some/folder\""]
}
}
}

describe("Carthage dependencies") {
$0.context("with static dependency") {
Expand Down

0 comments on commit 8bfa2f3

Please sign in to comment.