MSBuild 14.0(Visual Studio 2015附带的版本)在构建包含SSDT项目(rptproj或dwproj项目)的解决方案时记录警告(MSB4078).例如:
警告MSB4078:MSBuild不支持项目文件"Reports.rptproj",无法构建.
这很好,MSBuild不支持SSDT项目,我们必须回归到使用Visual Studio(即devenv.com)构建它们.例如,请参阅此答案.
但是,使用MSBuild 15.0(Visual Studio 2017附带的版本)时,构建相同的解决方案文件会出现以下错误:
Reports.rptproj(3,3):错误MSB4067:元素<Project>下的元素<State>无法识别.
虽然我可以从构建配置中删除SSDT项目,但这并不理想,因为我希望在Visual Studio中构建解决方案时构建它们.
有没有办法将错误MSB4067降级为警告,或者在构建解决方案时跳过某些项目?
.net msbuild sql-server-data-tools visual-studio-2017 msbuild-15
我安装了Xcode 10并将我的iOS应用程序升级到Swift 4.2.当我通过Xcode运行我的测试(UI和单元)时,在运行iOS 12的iPhone模拟器上,测试成功启动.当我尝试在运行先前iOS版本(例如iOS 10.3.1)的模拟器上运行测试时,我得到"无法加载测试包".这些测试在Xcode 9.4上成功运行.我可以在这个旧的模拟器上运行我的应用程序而不会出现问题.
Xcode输出如下("Reading List"是应用程序名称):
2018-09-16 15:11:36.667 ReadingList [11401:11478426]无法从文件加载测试包:/// Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator /ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/:Error Domain = NSCocoaErrorDomain Code = 3587"dlopen_preflight(/Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app /PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests):找不到合适的图像.找到:/Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests .xctest/ReadingList_UnitTests:mach-o,但不是为iOS模拟器构建的"UserInfo = {NSLocalizedFailureReason =捆绑包已损坏或缺少必要的资源.,NSLocalizedRecoverySuggestion =尝试重新安装捆绑包.,NSFilePath =/U sers/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests,NSDebugDescription = dlopen_preflight(/ Users/andrewbennet/Library/Developer/Xcode /DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests):找不到合适的图像.找到:/Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest/ReadingList_UnitTests:mach-o,但不是为iOS模拟器构建的,NSBundlePath =/Users/andrewbennet/Library/Developer/Xcode/DerivedData/ReadingList-edsxqugqvkymbgfrbivbjmzebuya/Build/Products/Debug-iphonesimulator/ReadingList.app/PlugIns/ReadingList_UnitTests.xctest,NSLocalizedDescription =无法加载捆绑"ReadingList_UnitTests"因为它已损坏或缺少必要的资源.}
这条线mach-o, but not built for iOS simulator似乎很关键.我该如何解决这个问题?
最近我重构我的课BookTableViewController从一个简单的继承UITableViewController,所以它现在从一个普通的类继承FetchedResultsTableViewController<TResultType, TCellType>其本身继承UITableViewController.
类声明如下所示:
class BookTableViewController: FetchedResultsTableViewController<Book, BookTableViewCell> {
override func viewDidLoad() {
// breakpoints in here do not catch!
}
}
class FetchedResultsTableViewController<TResultType, TCellType: UITableViewCell>:
UITableViewController, NSFetchedResultsControllerDelegate {
// implementation here
}
Run Code Online (Sandbox Code Playgroud)
在Storyboard中,Custom类和Module都已设置,我可以单击箭头跳转到BookTableViewController类的代码,建议故事板正确链接到类.但是,当我尝试运行应用程序时,无法识别该类 - 代码输入viewDidLoad()未运行,并且在运行我的应用程序时收到以下记录的消息:
Interface Builder文件中的未知类_TtC12Reading_List23BookTableViewController.
我正在运行XCode 7.3(Swift 2.2).这是故事板的限制,一个错误,还是我错过了什么?
谢谢!
更新:
经过一些实验,它似乎与通用继承有关,而不是类的可访问性.定义了以下类:
import Foundation
import UIKit
// Both of these classes are accessible by the Storyboard
class FirstInheritance : UITableViewController{}
class SecondInheritance : FirstInheritance{} …Run Code Online (Sandbox Code Playgroud) 我正在将我的 iOS 应用程序迁移到使用NSPersistentContainer. 默认情况下,此类将其持久存储文件定位在Library/Application Support目录中;以前我的商店文件存储在该Documents目录中。
我添加了一些代码来移动存储文件(如果在旧目录中找到它们):
func moveStoreFromLegacyLocationIfNecessary(toNewLocation newLocation: URL) {
// The old store location is in the Documents directory
let legacyStoreLocation = try! FileManager.default.url(for: .documentDirectory, in: .userDomainMask, appropriateFor: nil, create: true).appendingPathComponent("books.sqlite")
// Check whether the old store exists and the new one does not
if FileManager.default.fileExists(atPath: legacyStoreLocation.path) && !FileManager.default.fileExists(atPath: newLocation.path) {
print("Store located in Documents directory; migrating to Application Support directory")
let tempStoreCoordinator = NSPersistentStoreCoordinator()
try! tempStoreCoordinator.replacePersistentStore(at: newLocation, destinationOptions: nil, withPersistentStoreFrom: legacyStoreLocation, …Run Code Online (Sandbox Code Playgroud) 我正在使用的新的iOS 11 searchContoller属性UINavigationItem。我正在运行iOS 11.0 GM版本。
当我在搜索控制器处于活动状态时执行推送搜索时,它可以正常工作。当我随后弹出时,搜索栏将折叠起来,并压在状态栏中。然后,我无法取消搜索或编辑搜索文本。
请参阅以下图像序列:
最终的图像显示了弹出搜索期间表格的外观,该外观从显示的视图控制器返回到带有搜索栏的表格。奇怪的是,这并不总是发生。它有90%的时间会发生,但有时表现良好。我尚未弄清楚我正在做些什么来使其正常工作。搜索栏被压扁后,我必须强制关闭该应用程序以返回到明智状态。
设置搜索控制器的代码非常标准。相关的位viewDidLoad()如下:
searchController = UISearchController(searchResultsController: nil)
searchController.dimsBackgroundDuringPresentation = false
searchController.searchBar.returnKeyType = .done
searchController.searchBar.placeholder = "Your Library"
searchController.searchBar.searchBarStyle = .minimal
// We will manage the clearing of selections ourselves.
clearsSelectionOnViewWillAppear = false
// Some search bar styles are slightly different on iOS 11
if #available(iOS 11.0, *) {
navigationItem.searchController = searchController
navigationController!.navigationBar.prefersLargeTitles = true
}
else {
searchController.searchBar.backgroundColor = tableView.backgroundColor!
searchController.hidesNavigationBarDuringPresentation = false
tableView.tableHeaderView = searchController.searchBar
tableView.setContentOffset(CGPoint(x: …Run Code Online (Sandbox Code Playgroud) 我正在尝试有效地批量删除大量NSManagedObjects (不使用NSBatchDeleteRequest)。我一直遵循这个答案中的一般过程(适用于 Swift),通过批处理请求对象、删除、保存然后重置上下文的操作。我的获取请求设置includesPropertyValues为false.
然而,当它运行时,当每个对象从上下文中删除时,错误就会被触发。添加日志记录如下:
// Fetch one object without property values
let f = NSFetchRequest<NSManagedObject>(entityName: "Entity")
f.includesPropertyValues = false
f.fetchLimit = 1
// Get the result from the fetch. This will be a fault
let firstEntity = try! context.fetch(f).first!
// Delete the object, watch whether the object is a fault before and after
print("pre-delete object is fault: \(firstEntity.isFault)")
context.delete(firstEntity)
print("post-delete object is fault: \(firstEntity.isFault)")
Run Code Online (Sandbox Code Playgroud)
产生输出:
pre-delete object is fault: true …
在 SwiftUI 中List,如何使列表行背景(通过设置.listRowBackground())扩展视图的整个宽度,甚至在安全区域下?例如,在宽屏 iPhone(例如 iPhone 12 Pro Max)上横向运行时。目前,该单元格在安全区域开始之前在单元格的最左侧显示为白色。
示例代码:
struct ContentView: View {
var body: some View {
List {
Text("Test")
.listRowBackground(Color(.systemGray3))
}.listStyle(GroupedListStyle())
}
}
Run Code Online (Sandbox Code Playgroud)
这会产生如下所示的 UI。我希望单元格的灰色背景能够扩展设备的整个宽度。
我尝试过添加.edgesIgnoringSafeArea(.all)但Text没有什么区别。
我有一个UITableView在其导航栏中具有分段控件的控件。我使用相同的表格视图,以根据分段控件的选定索引显示3组不同的数据。我现在正在尝试保留每个段选项的滚动位置,以便似乎每个段选项都有一个表(即,每个选择的结果具有独立的滚动位置)。
为此,我CGPoint为每个状态存储一个变量,该变量设置为contentOffset所选段索引更改时的。该变量用于设置段更改后表格视图的内容偏移量。
但是,contentOffset当选定的段索引更改而表中的位置没有任何可见的更改时,值似乎会更改。就像内容偏移量的0位置正在移动,这使我的存储值现在出错了。
当我的控制器包含以下方法时:
override func viewDidLoad() {
// set up the view here...
print(tableView.contentOffset)
}
@IBAction func selectedSegmentChanged(sender: AnyObject) {
print(tableView.contentOffset)
// code to change the data shown in the table view...
}
Run Code Online (Sandbox Code Playgroud)
当视图加载时,我得到以下记录:
(0.0,0.0)
但更改细分后,我得到:
(0.0,-64.0)
所有状态都显示表格视图滚动到完全相同的位置,即-在顶部。
这种行为使我无法正确存储滚动位置,因为内容偏移量的“含义”似乎正在改变。
编辑:内容偏移量实际上是在viewDidLoad()和之间调整的viewDidAppear(),很可能是由于内容插入。因此,我现在在第一次viewDidAppear()调用时存储内容偏移值。
我的iOS应用可以打开CSV文件,以便导入其数据。我可以通过毫无问题地从应用程序内打开文件UIDocumentPickerViewController,选择“文件”应用程序中显示的文件。但是,当先在“文件”应用程序中查看文件,然后从那里打开我的应用程序时(通过“打开方式”共享表),我的应用程序无法在传递给我的应用程序的URL上看到该文件。该文件似乎不存在。
我在我的AppDelegate中添加了以下调试代码:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
print("Exists: \(FileManager.default.fileExists(atPath: url.path)) (\(url.path))")
return true
}
Run Code Online (Sandbox Code Playgroud)
当我从此应用程序中的“文件”中打开文件时,它会导致出现如下日志行:
存在:假(
/private/var/mobile/Library/Mobile Documents/com~apple~CloudDocs/Reading List - Andrew’s iPhone - 2018-10-18 11-19.csv)
从其他应用程序(例如Dropbox或电子邮件)打开文件时,可以处理该文件,并记录以下内容:
存在:true(
/private/var/mobile/Containers/Data/Application/F9110F90-7A91-4AB6-A92E-0ED933184EA4/Documents/Inbox/Reading List - Andrew’s iPhone - 2018-01-27 08-03.csv)
注意不同的路径(Documents/Inboxvs Mobile Documents/com~apple~CloudDocs)。是什么原因造成的?如何在我的应用程序中支持通过“文件”应用程序打开文件?
我的应用程序支持的文档类型如下:
我有一个HTML表,我试图使用jQuery UI可排序小部件来启用行的重新排序.我已经设置了sortable axis: 'y',我正在使用一个helper函数来保存拖动行的宽度,并将其设置containment为父表:
jQuery(function($) {
$("#rows").sortable({
handle: ".handle",
axis: "y",
containment: "#main-table",
helper: function(e, row) {
// From http://www.paulund.co.uk/fixed-width-sortable-tables.
// Sets the width of each cell to be its original width.
// This prevents the row collapsing into a narrower stub when being dragged.
row.children().each(function() {
$(this).width($(this).width());
});
return row;
}
});
});
Run Code Online (Sandbox Code Playgroud)
但是,当存在具有多个线高的行时,包含不会按预期运行:当拖动较大的行时,表的高度会减小,并且包含会收缩得更多,使得大行无法移动到底部的表.其他行工作正常.
可以在此处找到显示此行为的JSFiddle:https://jsfiddle.net/AndrewBennet/rc5pnazc/3/
这是已知/预期的行为吗?有没有解决方法?
ios ×8
swift ×7
core-data ×2
uikit ×2
xcode ×2
.net ×1
icloud ×1
ios11 ×1
ios12 ×1
javascript ×1
jquery ×1
jquery-ui ×1
msbuild ×1
msbuild-15 ×1
sqlite ×1
swiftui ×1
swiftui-list ×1
uiscrollview ×1
uisearchbar ×1
uitableview ×1
xcode10 ×1
xcode7 ×1
xctest ×1