每当我构建时,测试对我的Xcode项目的任何更改都会成为一种耐心的练习.在编译完所有源文件之后,我在Xcode顶部的活动窗口中收到以下消息:
"运行3个自定义Shell脚本中的3个"
我没有添加任何自己的自定义shell脚本,但我通过Cocoapods使用了很多依赖项,我使用2个框架构建环境,Crashlytics和Tapstream.Crashlytics要求你在构建阶段添加一个运行脚本,除了我不知道其他的来自哪里,它们似乎是我构建时间的瓶颈.
任何人都可以告诉我发生了什么以及我如何加快速度?
Swift 4正在添加一些非常酷的功能,如强类型键路径和JSON编码/解码使用Codable.
我想在仍然针对iOS 9及更高版本的同时使用这些新功能.
据我所知,Swift语言版本并未绑定到iOS版本,例如与Foundation框架相反.但是,如果这是正确的,我找不到任何信息.
在针对11岁以上的iOS时,我可以使用Swift 4吗?
Apple 在iOS8中添加了一个私有助手_printHierarchy,可以在LLDB控制台中使用:
po [[[UIWindow keyWindow] rootViewController] _printHierarchy]
Run Code Online (Sandbox Code Playgroud)
它以文本形式打印出整个视图控制器层次结构.
这只适用于在Objective C上调试代码.但是,在Swift中,这不起作用:
(lldb) po [[[UIWindow keyWindow] rootViewController] _printHierarchy]
error: <EXPR>:1:13: error: expected ',' separator
[[[UIWindow keyWindow] rootViewController] _printHierarchy]
^
,
<EXPR>:1:24: error: expected ',' separator
[[[UIWindow keyWindow] rootViewController] _printHierarchy]
^
,
<EXPR>:1:44: error: expected ',' separator
[[[UIWindow keyWindow] rootViewController] _printHierarchy]
^
,
Run Code Online (Sandbox Code Playgroud)
Swift中的等效用法也不起作用:
po UIApplication.sharedApplication().keyWindow!.rootViewController!._printHierarchy
Run Code Online (Sandbox Code Playgroud)
最终出现错误(可能是因为_printHierarchy是私人财产):
(lldb) po UIApplication.sharedApplication().keyWindow!.rootViewController!._printHierarchy()
error: <EXPR>:1:64: error: 'UIViewController' does not have a member named '_printHierarchy'
UIApplication.sharedApplication().keyWindow!.rootViewController!._printHierarchy
^ ~~~~~~~~~~~~~~~
Run Code Online (Sandbox Code Playgroud)
问题是:如何在Swift中打印出视图控制器层次结构?或者,即使在Swift项目中,如何在LLDB控制台中使用ObjC?
有没有办法在保持UIViewControllerBasedStatusBarAppearance启用的同时设置默认状态栏样式?
这是问题,我正在处理:
UIStatusBarStyle.LightContent由于导航栏背景较暗,因此几乎需要使用整个应用程序.最初,UIViewControllerBasedStatusBarAppearance被禁用,并且Info.plist在文本状态状态栏中设置了以下内容:
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
Run Code Online (Sandbox Code Playgroud)
这工作得很好,直到我发现这个.LightContent状态栏甚至显示为某些共享扩展,如Facebook Messenger,导致它不可读:
这可以通过使用来解决UIViewControllerBasedStatusBarAppearance,但是我需要将以下方法添加到我想要避免的所有视图控制器中,因为应用程序非常大.
此外,对于具有轻型导航栏背景的应用程序中的一个屏幕,我使用UIApplication.sharedApplication().setStatusBarStyle()但是在iOS 9中不推荐使用此方法.
任何想法如何解决这个问题?混写?
在 macOS 上放置在 List 中时,TextField 被禁用(不可编辑)。当为 iOS 构建相同的代码并在模拟器中运行时,它会按预期工作。
这是一个错误,还是我错过了什么?
编码:
struct ContentView : View {
@State private var text: String = ""
var body: some View {
VStack {
List {
// TextField is not editable when this code is ran on macOS
TextField($text, placeholder: Text("Entry text"))
Text("Entered text: \(text)")
}
// TextField is editable on both macOS as well as iOS
TextField($text, placeholder: Text("Entry text"))
}
}
}
Run Code Online (Sandbox Code Playgroud) 在我正在开发的应用程序中,我需要处理来自我们的支付服务提供商的3-D Secure重定向.这些重定向指向发卡机构的网页,该网页WKWebView在应用程序中显示在用户的网页中.
除了一个WKWebView没有为https://3dsecure.csas.cz/加载并且失败并出现以下错误的情况外,这种情况一直有效:
Error Domain=NSURLErrorDomain
Code=-1200
"An SSL error has occurred and a secure connection to the server cannot be made."
Run Code Online (Sandbox Code Playgroud)
有趣的是,相同的URL加载在Safari或中没有任何问题SFSafariViewController.甚至服务器的证书都可以:
我试图NSAppTransportSecurity在应用程序的Info.plist文件中使用设置,特别是启用NSAllowsArbitraryLoadsInWebContent,NSAllowsArbitraryLoads但它确实没有效果.
根据发行说明,Xcode 9增加了对获取索引的支持:
"数据模型编辑器为Core Data的新获取索引功能及其现有的属性索引和实体复合索引功能提供了统一的接口.旧的数据模型被转换为获取索引形式以进行编辑,并在必要时保存为旧的文件格式编译部署目标低于iOS 11,watchOS 4,macOS 10.13或tvOS 11的数据模型继续生成兼容的编译形式.(30843153)"
我的项目目前已将部署目标设置为iOS 9,但我无法编译我的CoreData模型,它为每个具有复合索引集的实体提供了以下错误:
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[0]: error: Expression requires a concrete result type.
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[0]: error: Expression attributes are not compatible with the current deployment target.
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[1]: error: Expression requires a concrete result type.
Model.xcdatamodeld/Model.xcdatamodel:MyEntity|compoundIndex[1]: error: Expression attributes are not compatible with the current deployment target.
Model.xcdatamodeld/Model.xcdatamodel:MyEntity: error: Fetch Indexes feature requires iOS deployment target 11.0 or later
Model.xcdatamodeld/Model.xcdatamodel:MyEntity: error: Fetch Indexes feature requires Xcode 9.0 tools or later
Run Code Online (Sandbox Code Playgroud)
知道如何修复构建错误吗?
更新:
除了从关系创建的情况外,Xcode 9正确地将复合索引转换为获取索引,如"已知问题"部分所述:
数据模型编辑器仅支持从此测试版中的属性和表达式创建获取索引,而不是从关系创建.(32407895)
受影响的提取索引如下所示,可以从下拉菜单中选择唯一的属性: …
我正在调试我的代码,searchBarTextDidBeginEditing:每次点击搜索栏(位于导航栏中)时,UISearchBar的委托方法都会被调用两次.
奇怪的是,只有这个委托方法被调用两次.其他人在整个过程中只被召唤一次,这是正确的行为.
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
// called only once
return YES;
}
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
// called twice every time
[searchBar setShowsCancelButton:YES animated:YES];
}
- (BOOL)searchBarShouldEndEditing:(UISearchBar *)searchBar
{
// called only once
[searchBar setShowsCancelButton:NO animated:YES];
return YES;
}
- (void)searchBarTextDidEndEditing:(UISearchBar *)searchBar
{
// called only once
}
Run Code Online (Sandbox Code Playgroud)
知道什么可能是错的吗?
UISeachrBar在Storyboard中设置,具有正确连接的插座,虽然它没有添加到任何视图,并且在特定视图中,控制器viewDidLoad是将搜索栏添加到导航栏的以下行:
self.searchDisplayController.displaysSearchBarInNavigationBar = YES;
Run Code Online (Sandbox Code Playgroud)
我正在使用Xcode 5.0.1并在iOS 7.0.3模拟器中运行代码.
根据NSHipster的说法,“使自定义UI类符合UIAppearance不仅是最佳实践,而且还表明在实现过程中要加倍注意。”
因此,我正在尝试将文本属性(稍后用于创建)设置为子类中NSAttributedString的属性var titleTextAttributes: [String : AnyObject]?,UIView如下所示:
func applyAppearance() {
UINavigationBar.appearance().translucent = true
UINavigationBar.appearance().tintColor = UIColor(named: .NavBarTextColor)
UINavigationBar.appearance().barTintColor = UIColor(named: .NavBarBlue)
UINavigationBar.appearance().titleTextAttributes = [
NSForegroundColorAttributeName: UIColor(named: .NavBarTextColor),
NSFontAttributeName: UIFont.navBarTitleFont()!
]
ActionBarView.appearance().backgroundColor = UIColor(white: 1, alpha: 0.15)
ActionBarView.appearance().titleTextAttributes = [
NSKernAttributeName: 1.29,
NSFontAttributeName: UIFont.buttonFont()!,
NSForegroundColorAttributeName: UIColor.whiteColor(),
]
}
Run Code Online (Sandbox Code Playgroud)
这是我的偷窥AppDelegate。
现在,当尝试设置ActionBarView.appearance().titleTextAttributes = [ ... ]时,出现以下运行时错误:
值得一提的是,在属性上设置属性UINavigationBar没有任何问题。
转到UINavigationBar的头文件将显示以下内容:
/* You may specify the font, text color, and shadow …Run Code Online (Sandbox Code Playgroud) 我的工作区中有以下项目:
CommonSecurity(取决于Common)Data(依赖于Common,Security(和CoreData))Api(依赖于Common,Security,Data)MyApp(依赖于Common,Security,Data,Api)除了MyAppCocoa Touch Frameworks 之外的所有项目,主要是用Swift编写的.
从Xcode 6.3.1开始,我无法编译,因为我在构建"Api"框架时收到以下消息:
<unknown>:0: error: timed out waiting to acquire lock file for module 'Data'
~/Developer/myapp/src/Api/Api/SomeClass.swift:4:8: error: cannot load underlying module for 'Data'
import Data
^
Run Code Online (Sandbox Code Playgroud)