小编Ama*_*lho的帖子

如何为我的 pod 框架的 pod 依赖使用模块化标头配置?

我的 podspec 看起来像这样:

Pod::Spec.new do |s|
  s.name             = 'flutter_vlc_player'
  s.version          = '0.0.3'
  s.summary          = 'A new Flutter project.'
  s.description      = <<-DESC
A new Flutter project.
                       DESC
  s.homepage         = 'http://example.com'
  s.license          = { :file => '../LICENSE' }
  s.author           = { 'Your Company' => 'email@example.com' }
  s.source           = { :path => '.' }
  s.source_files = 'Classes/**/*'
  s.public_header_files = 'Classes/**/*.h'
  s.dependency 'Flutter'

  s.dependency 'MobileVLCKit', '~> 3.3.10'
  s.static_framework = true

  s.ios.deployment_target = '9.0'
end
Run Code Online (Sandbox Code Playgroud)

如何设置:modular_headers => truefor s.dependency 'MobileVLCKit', '~> 3.3.10'?我试着用像 …

objective-c ios cocoapods podspec swift

12
推荐指数
0
解决办法
1979
查看次数

如何仅使用 SwiftUI 从 @main App 访问 NSWindow?

在这个答案中,该解决方案适用于 Scene plus swiftUI。

但是使用@main 就像:

@main
struct MyApp: App {
    @StateObject private var model = MyModel()
    
    var body: some Scene {
        WindowGroup {
            Router {
                AppContent()
            }.environmentObject(self.model)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我还尝试通过使用获取主窗口

var window: NSWindow? {
        let window = NSApplication.shared.mainWindow
        return window
    }
Run Code Online (Sandbox Code Playgroud)

尽管如此,mainWindow总是返回nil

更新:

我需要NSWindow由于需要符合ASWebAuthenticationPresentationContextProviding哪些有义务返回NSWindow. 基本上,我正在尝试执行以下操作:

LoginView(store: AuthStore(window: window))
Run Code Online (Sandbox Code Playgroud)

WhereAuthStore用于AuthenticationServices执行身份验证。

macos swift swiftui

6
推荐指数
1
解决办法
1092
查看次数

How to set the modulemap for cocoapods project?

I was trying to use a pod that was written in Obj-C and my project is Swift-only. I got this error include of a non-modular header inside framework module in the import statement of a dependency inside the framework .h file.

The pod spec of the library is:

Pod::Spec.new do |s|
  s.name             = 'flutter_vlc_player'
  s.version          = '0.0.3'
  s.summary          = 'A new Flutter project.'
  s.description      = <<-DESC
A new Flutter project.
                       DESC
  s.homepage         = 'http://example.com'
  s.license          = { :file => '../LICENSE' …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios cocoapods swift

5
推荐指数
0
解决办法
1528
查看次数

无法使用 SwiftUI Preview 在 Xcode 中预览 Widget

我正在尝试使用 Widget 上下文预览一些视图,例如:

\n
struct MyTasksView_Previews: PreviewProvider {\n    static var previews: some View {\n            MyTasksView(\n                myTasks: Fake.myTasks,\n                user: Fake.user,\n                error: ""\n            )\n            .previewContext(WidgetPreviewContext(family: .systemMedium))\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

但是,我在尝试运行预览时收到此错误。而且,我不确定为什么会发生这种情况。

\n
\n

RemoteHumanReadableError:未知的预览提供程序 \xe2\x80\x9cMyTasksView_Previews\xe2\x80\x9d\nMyApp 不包含名为 \xe2\x80\x9cMyTasksView_Previews\xe2\x80\x9d 的预览提供程序。检查您的构建设置以确保预览提供程序已编译到您的产品中。

\n
\n

我也尝试使用简单的Text(text).previewContext(WidgetPreviewContext(family: .systemMedium)),但它也不起作用。我正在使用 Xcode beta 5。

\n

在 WWDC 2020 的 Apple Emoji Rangers Demo App 中,我们可以看到这段代码进行预览:

\n
struct CharacterNameView_Previews: PreviewProvider {\n    static var previews: some View {\n        CharacterNameView(CharacterDetail.panda)\n            .previewContext(WidgetPreviewContext(family: .systemSmall))\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n

表情符号流浪者示例

\n

macos xcode widgetkit swiftui

5
推荐指数
2
解决办法
8969
查看次数

标签 统计

swift ×3

cocoapods ×2

ios ×2

macos ×2

objective-c ×2

swiftui ×2

xcode ×2

podspec ×1

widgetkit ×1