Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update
  • Loading branch information
muukii committed Oct 25, 2025
commit 80fdd887b02082668c4a4dd738b062775bfee059
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
.netrc
.swiftpm
.claude
43 changes: 29 additions & 14 deletions Sources/SwiftUIHosting/SwiftUIHostingViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,39 @@ open class SwiftUIHostingViewController<Content: View>: UIViewController {

super.viewDidLoad()

let _content = content(self)
let _content = content(self).modifier(configuration.baseModifier)

let contentView = SwiftUIHostingView(
name,
file,
function,
line,
configuration: configuration
) { _content }
#if DEBUG

let hostingController = HostingController(
accessibilityIdentifier: _typeName(Content.self),
disableSafeArea: configuration.disableSafeArea,
ignoresKeyboard: configuration.ignoresKeyboard,
rootView: _content
)

#else

let hostingController = HostingController(
disableSafeArea: configuration.disableSafeArea,
ignoresKeyboard: configuration.ignoresKeyboard,
rootView: _content
)

#endif

addChild(hostingController)
view.addSubview(hostingController.view)
hostingController.didMove(toParent: self)

view.addSubview(contentView)
contentView.translatesAutoresizingMaskIntoConstraints = false
hostingController.view.backgroundColor = .clear
hostingController.view.translatesAutoresizingMaskIntoConstraints = false

NSLayoutConstraint.activate([
contentView.topAnchor.constraint(equalTo: view.topAnchor),
contentView.rightAnchor.constraint(equalTo: view.rightAnchor),
contentView.bottomAnchor.constraint(equalTo: view.bottomAnchor),
contentView.leftAnchor.constraint(equalTo: view.leftAnchor),
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.rightAnchor.constraint(equalTo: view.rightAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
hostingController.view.leftAnchor.constraint(equalTo: view.leftAnchor),
])

}
Expand Down