我在将 macOS 应用程序与 C 库链接时遇到一些问题。我有几个与这个问题相关的问题。
考虑到这将是非常自定义的库而不是与其他应用程序共享,最好将应用程序链接到动态或静态库?
我已将我的 macOS Xcode 应用程序与 ~14 个静态库 .a 链接起来,并且工作正常。我已经重新配置了 CMakeLists.txt 来创建这个库,但现在 Xcode 项目无法工作。主要的变化是改变我的目录
"$(SRCROOT)/../../c/<project_name>/outputs/lib/apple/static"
但现在我在同一路径中同时拥有静态(.a)和动态(.dylib)库
"$(SRCROOT)/../../c/server/outputs/lib/apple"
我不知道这是否重要,但是链接到静态库会导致运行我的 Xcode 项目后它抱怨无法加载lib.dylib所以也许它在库搜索路径下找到了这个动态库并且厌倦了加载它们但不'没有发现它们有联系吗?
也许我应该在这里改变一些东西?但是,如果我将我的应用程序分发到其他一些在此特定位置没有库的计算机,该怎么办?如何在 Xcode 包中包含动态库以便始终可以找到。
我知道我可能添加了很多问题。但想知道如何最好地解决这个问题?最好静态或动态链接,然后如何正确实现此目的以避免此错误。
更新
.dylib
只有当我将此库目录的路径添加到Runpath Search Paths
..a
它在.dylib
不在同一目录中时可以工作(我将.a
库移动到/static
子目录中),然后对于这个移动的库错误不再显示。但是,当同一目录中有.a和.dylib库时,是否有办法静态链接?我有 ViewModel 和一次性 Set 以这种方式定义
class ViewModel {
private var disposables = Set<AnyCancellable>()
func sync() {
repo.syncObjects()
.handleEvents(receiveCancel: {
print("Synced objects: CANCELED!")
})
.sink(receiveCompletion: { completion in
switch completion {
case .failure(let error):
print("Synced objects: \(error)")
case .finished:
print("Synced objects: finished")
}
}) { objects in
print("Synced objects: \(objects)")
}.store(in: &disposables)
}
deinit { print("ViewModel deinit") }
}
Run Code Online (Sandbox Code Playgroud)
我在 SwiftUI 视图中的 onAppear 中调用sync()。然后我快速切换屏幕,从 SwiftUI 视图引用的 ViewModel 被 ARC 释放,就像调用 deinit 一样,但订阅似乎仍然存在,一次性引用不会取消订阅,它从网络获取数据并将它们保存在 Core Data 中并打印 Synced 对象:对象,同步对象:完成。即使我停止切换屏幕几秒钟以完成旧请求,它仍然保持活动状态。
我应该手动取消 AnyCancellable 吗?不是应该自动取消吗?
我正在尝试编译这里基于示例项目创建的Angular 4 + ASP.NET Universal应用程序,使用此提示https://github.com/angular/universal#universal-gotchas 以及当我使用webpack构建项目时,然后运行它如果检查了块,则封装在其中的代码将引发错误
isPlatformBrowser
已在服务器端呈现。如何在不进行预渲染的情况下在客户端有效地强制执行此代码,而其他与服务器端预渲染正常工作的代码却要在服务器端进行预渲染?
这是我的组件,其传单代码封装在条件块中,用于检查平台是否为浏览器。
import {Component, OnInit, Inject} from '@angular/core';
import { PLATFORM_ID } from '@angular/core';
import { isPlatformBrowser, isPlatformServer } from '@angular/common';
import * as L from 'leaflet';
@Component({
selector: 'leaflet-map',
templateUrl: 'leaflet-map.component.html',
styleUrls: ['leaflet-map.component.css', '../../../..//node_modules/leaflet/dist/leaflet.css'],
})
export class LeafletMapComponent implements OnInit {
constructor(@Inject(PLATFORM_ID) private _platformId: Object) { }
ngAfterViewInit() {
}
ngOnInit() {
if (isPlatformBrowser(this._platformId)) {
L.map('leafletMap').setView([50.08, 19.93], 13);
}
if (isPlatformServer(this._platformId)) {
// Server only code.
// https://github.com/angular/universal#universal-gotchas
}
} …
Run Code Online (Sandbox Code Playgroud) 如何在@GestureState 和squanced 手势更新修饰符之间添加没有属性包装器/中间的手势状态。
在绑定的情况下,我们可以这样做:
@Binding value: Bool = false
Run Code Online (Sandbox Code Playgroud)
然后
let binding = Binding<Bool>(get: { self.value }, set { self.value = $0 })
then .updating(bidning) instead of .updating($value)
Run Code Online (Sandbox Code Playgroud)
如何使用@GestureState 实现这样的事情来拦截其值更改?我需要它,因为在长按然后拖动的情况下我没有调用从 .pressing 到 .inactive 状态的回调(如在 Apple 示例中)
我想问一下我使用时有关 SwiftUI 行为的问题.onChange( value) { }
为什么如果我使用@State var some: SomeType?
可选类型,然后@Binding var some: SomeType
此运算符仅检测到从某些 SomeType 值到 nil 的更改,反之亦然。但底层对象值的更改不会被检测为更改
前任。@Binging var 进度:Int?
将进度从 nil 更改为 100 会检测到更改,但如果我将值从 1 -> 2 -> 3 更改,它们就会被跳过 如果我使用@Binding var progress: Int
知道如何将选项与 onChange() 一起使用吗?
当使用Arquillian测试我的(JPA)实体作为集成测试的一部分时,似乎一切似乎都有效,除了测试ConstraintViolation
s.例如,不应该持久化实体实例,该实体实例null
在使用Bean Validation的@NotNull注释的字段中具有值.而不是ConstrainViolationException
我得到ArquillianProxyException
:
Unexpected exception, expected<javax.validation.ConstraintViolationException> but was<org.jboss.arquillian.test.spi.ArquillianProxyException>
Run Code Online (Sandbox Code Playgroud)
这是我的简单测试:
@Test(expected = ConstraintViolationException.class) // not set required fields
public void shouldNotCreateNewFirm() {
// Create instance of firm entity
Firm firm = new Firm("firma@allegro.pl", "allegro", "aAle2@", "Allegro Ltd.");
// persist the firm to the database
transaction.begin();
em.persist(firm);
em.remove(firm);
transaction.commit();
}
Run Code Online (Sandbox Code Playgroud)
和错误细节:
Caused by: org.jboss.arquillian.test.spi.ArquillianProxyException: javax.validation.ConstraintViolationException : Validation failed for classes [pl.salonea.entities.Firm] during persist time for groups [javax.validation.groups.Default, ]
List of constraint violations:[
ConstraintViolationImpl{interpolatedMessage='may not be …
Run Code Online (Sandbox Code Playgroud) 我已经实现了一些自定义异常,如:NotFoundException、BadRequestException、
对于它们中的每一个,我都实现了自己的 ExceptionMapper 像NotFoundExceptionMapper、BadRequestExceptionMapper以及类似GenericExceptionMapper 的东西:
@Provider
public class GenericExceptionMapper implements ExceptionMapper<Throwable> {
@Override
@Produces( {MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON} )
public Response toResponse(Throwable ex) {
ErrorResponseWrapper errorResponse = new ErrorResponseWrapper(ex.getMessage(), 500, "");
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(errorResponse).build();
}
}
Run Code Online (Sandbox Code Playgroud)
首先,这里的问题是GenericExceptionMapper不能像我预期的那样工作,它没有捕获 JAX-RS 抛出的通用异常,因为我认为每个要被此类 Mapper 捕获的异常必须尽早从getResource() throws 之类的方法中显式抛出 一些异常{
此外,该问题是,在RestEasy的我需要在登记例外映射器web.xm。见下文:
<!-- Custom exception handling provider -->
<context-param>
<param-name>resteasy.providers</param-name>
<param-value>pl.salonea.jaxrs.exceptions.GenericExceptionMapper</param-value>
</context-param>
Run Code Online (Sandbox Code Playgroud)
这是另一个问题,因为我无法注册(或者我不知道如何注册)我定义的每个自定义 ExceptionMapper。我只能注册单个自定义 ExceptionMapper。 如何全部注册?即 NotFoundExceptionMapper、BadRequestExceptionMapper 等。
所以现在每个异常只由通用异常映射器映射,这是第一个问题。
这是 RESTEasy 的限制吗?在泽西岛的一些教程中,我没有看到需要注册此类 ExceptionMapper,但我也不知道是否可以有多个异常 Mapper。
我想到的另一个解决方案(解决方法)是使用单个 GenericExceptionMapper …
我想把我的白色按钮放在屏幕中央,有这样的限制.1.在父边缘之间水平居中,并可能放置一些边距.2.在顶部父按钮和按钮按钮之间垂直居中.现在我的布局在图像上看起来像这样
好吧我想我可以把这个按钮放在一些FrameLayout然后约束它,但这似乎是压倒性的添加另一个布局.我添加了D-Pad和XAYB这样添加下一个FrameLayout甚至RelativeLayout似乎与使用ConstraintLayout相矛盾,其目的是防止许多布局的深度嵌套,如线性,相对,帧布局.
我正在尝试制作一个从标题滑动的下拉菜单。我有一个标题,里面有一些带有边框底部 1px 线和背景颜色的 div。在此 div 内,我想放置徽标、搜索框、一些链接和用户个人资料按钮。单击此按钮时,我想在此按钮下方显示下拉菜单。不幸的是,这个下拉菜单出现在标题前面,而不是从标题后面滑动(遮挡标题背景和底部边框线)。我尝试过如下解决方案(它是简化版本)。
header {
position: relative;
z-index: 5;
}
.dropdown {
background-color: yellow;
width: 100px;
height: 100px;
position: absolute;
z-index: 1;
}
.background {
position: absolute;
background-color: #ccca;
border-bottom: 1px solid black;
width: 100%;
height: 50px;
z-index: 2;
}
Run Code Online (Sandbox Code Playgroud)
<header>
<div class="background">
<div class="dropdown">
</div>
</div>
</header>
Run Code Online (Sandbox Code Playgroud)
我尝试了很多 z-index 配置,但似乎都不起作用。1. div.background 的 z-index 为 2,div.dropdown 的 z-index 为 1 甚至 -1 2. div.background 没有 z-index 和位置,div.dropdown 的 z-index -1(此处下拉列表位于标题后面但菜单链接停止工作,菜单也位于网页主要内容的后面)
如何使我的 div.dropdown 从标题栏后面滑动,并带有背景和边框底线?是否可以将此 div.dropdown 作为子元素放在 header div …
我的Android Studio即时应用项目遇到问题。如果我Manifest.xml
在/ app目录中选择,然后选择合并清单,那么我会遇到这样的错误:
Merging Errors: Error: Attribute provider#android.arch.lifecycle.ProcessLifecycleOwnerInitializer@authorities value=(com.theminte.TheMinte.lifecycle-trojan) from AndroidManifest.xml:10:15-75 is also present at AndroidManifest.xml:25:13-68 value=(com.theminte.TheMinte.app.lifecycle-trojan). Suggestion: add 'tools:replace="android:authorities"' to <provider> element at AndroidManifest.xml:10:5-201 to override. app main manifest (this file), line 9
Run Code Online (Sandbox Code Playgroud)
比起我无法使用“默认活动”启动我的应用程序,我只能使用“项目构建配置”中选择的“无活动”来启动它。如何解决这个合并问题?