-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Karim/fix xcode previews #3124
base: main
Are you sure you want to change the base?
Karim/fix xcode previews #3124
Changes from all commits
708532d
f9c2caf
07ac04d
c6ec053
d8b13c3
b09735c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ enum PathKey: String { | |
case emitModulePath = "-emit-module-path" | ||
case emitObjCHeaderPath = "-emit-objc-header-path" | ||
case outputFileMap = "-output-file-map" | ||
case supplementaryOutputFileMap = "-supplementary-output-file-map" | ||
case sdk = "-sdk" | ||
} | ||
|
||
|
@@ -32,7 +33,7 @@ func processArgs( | |
|
||
if arg == "-wmo" || arg == "-whole-module-optimization" { | ||
isWMO = true | ||
} else if arg.hasSuffix(".preview-thunk.swift") { | ||
} else if arg.hasSuffix("usr/lib/swift/host/plugins") || arg.hasSuffix(".preview-thunk.swift") { | ||
isPreviewThunk = true | ||
} else { | ||
previousArg = arg | ||
|
@@ -56,7 +57,7 @@ func processArgs( | |
} | ||
|
||
return ( | ||
!paths.keys.contains(.outputFileMap) && isPreviewThunk, | ||
isPreviewThunk, | ||
isWMO, | ||
paths | ||
) | ||
|
@@ -116,11 +117,14 @@ func touchSwiftmoduleArtifacts(paths: [PathKey: URL]) throws { | |
.appendingPathExtension("swiftsourceinfo") | ||
var swiftinterfacePath = swiftmodulePath.deletingPathExtension() | ||
.appendingPathExtension("swiftinterface") | ||
var swiftconstvaluesPath = swiftmodulePath.deletingPathExtension() | ||
.appendingPathExtension("swiftconstvalues") | ||
|
||
try swiftmodulePath.touch() | ||
try swiftdocPath.touch() | ||
try swiftsourceinfoPath.touch() | ||
try swiftinterfacePath.touch() | ||
try swiftconstvaluesPath.touch() | ||
} | ||
|
||
if var generatedHeaderPath = paths[PathKey.emitObjCHeaderPath] { | ||
|
@@ -146,6 +150,20 @@ func handleXcodePreviewThunk(args: [String], paths: [PathKey: URL]) throws -> Ne | |
exit(1) | ||
} | ||
|
||
if let outputFileMapURL = paths[.supplementaryOutputFileMap] { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. without that i got an error
|
||
let data = try! Data(contentsOf: outputFileMapURL) | ||
let constValuesURL = String(data: data, encoding: .utf8)! | ||
.components(separatedBy: .newlines) | ||
.dropFirst() | ||
.first { $0.contains("const-values") }! | ||
.components(separatedBy: "\"")[1] | ||
|
||
var attributes = try FileManager.default.attributesOfItem(atPath: constValuesURL) | ||
let permissions: Int = 0o755 // rwxr-xr-x | ||
attributes[.posixPermissions] = permissions | ||
try FileManager.default.setAttributes(attributes, ofItemAtPath: constValuesURL) | ||
} | ||
|
||
// TODO: Make this work with custom toolchains | ||
// We could produce this file at the start of the build? | ||
let fullRange = NSRange(sdkPath.startIndex..., in: sdkPath) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ if [[ "$ACTION" != indexbuild ]]; then | |
if [[ -f "$BAZEL_OUTPUTS_PRODUCT_BASENAME" ]]; then | ||
# Product is a binary, so symlink instead of rsync, to allow for Bazel-set | ||
# rpaths to work | ||
ln -sfh "$PWD/$BAZEL_OUTPUTS_PRODUCT_BASENAME" "$TARGET_BUILD_DIR/$PRODUCT_NAME" | ||
ln -sfh "$PWD/$BAZEL_OUTPUTS_PRODUCT_BASENAME" "$TARGET_BUILD_DIR/lib$PRODUCT_NAME.a" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SwiftUIP Previews run
|
||
else | ||
# Product is a bundle | ||
rsync \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,12 @@ do | |
developer_dir="${1/\/Platforms\/*/}" | ||
;; | ||
|
||
*.debug.dylib) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. need to verify this on an App previews |
||
# Pass through for SwiftUI Preview thunk compilation | ||
# TODO: Make this work with custom toolchains | ||
exec "$developer_dir/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" "${passthrough_args[@]}" | ||
;; | ||
|
||
*.preview-thunk.dylib) | ||
# Pass through for SwiftUI Preview thunk compilation | ||
# TODO: Make this work with custom toolchains | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.