我试图在我的遗留Objc代码中测试一些Swift类(@objc类).我在我的测试类中导入"UnitTests-Swift.h".
然后我收到这个错误:
在自动生成的"UnitTests-Swift.h"中找不到模块"MyApp"
这是"UnitTests-Swift.h"顶部的内容
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
#if defined(__has_feature) && __has_feature(modules)
@import XCTest;
@import ObjectiveC;
@import MyApp;
@import CoreData;
#endif
Run Code Online (Sandbox Code Playgroud)
我清理了项目,检查了所有相关的标志(在Xcode单元测试中使用@testable时没有这样的模块,不能在Objective-C中使用Swift类),删除派生数据等等.不知道发生了什么,但我很确定@import MyApp不应该在那里..
谁能帮我这个?
我不能将我的项目升级为gradle 1.5:
build.gradle(root)项目刷新失败:从1.4.0开始,现在无法访问dex任务.错误:1.4.0引入了一个新的Transform API,允许操作.class文件.
有什么建议吗?
root build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
task allDependencies(type: DependencyReportTask) {}
}
Run Code Online (Sandbox Code Playgroud)
app build.gradle:
buildscript {
repositories {
mavenCentral()
maven { url 'http://download.crashlytics.com/maven' }
}
dependencies {
classpath 'com.crashlytics.tools.gradle:crashlytics-gradle:1.14.7'
classpath "com.newrelic.agent.android:agent-gradle-plugin:4.244.0"
}
}
repositories {
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
maven { url 'http://download.crashlytics.com/maven' }
}
task wrapper(type: Wrapper) {
gradleVersion = '2.7'
}
apply plugin: 'com.android.application'
android …
Run Code Online (Sandbox Code Playgroud) 我注意到,如果我创建一个UNCalendarNotificationTrigger
带有自定义日期的,除非输入:
let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: **true**)
苹果的例子是:
let date = DateComponents()
date.hour = 8
date.minute = 30
let trigger = UNCalendarNotificationTrigger(dateMatching: date, repeats: true)
Run Code Online (Sandbox Code Playgroud)
可以重复== true。
在我的场景中,我不需要创建一个可以重复多次的通知,但是我需要在一个特定的日历日期(当然是将来的日期)仅触发一次的多个通知。
如果我在做:
let calendar = Calendar(identifier: .gregorian)
let formatter = DateFormatter()
formatter.dateFormat = "yyyyMMdd"
let newdate = formatter.date(from: "20161201")
let components = calendar.dateComponents(in: .current, from: newdate!)
let trigger = UNCalendarNotificationTrigger(dateMatching: components, repeats: false)
Run Code Online (Sandbox Code Playgroud)
那么我总是收到0个待处理的通知...
UNUserNotificationCenter.current().getPendingNotificationRequests(completionHandler: { (notifications) in
print("num of pending notifications \(notifications.count)")
})
num of pending notification 0
Run Code Online (Sandbox Code Playgroud)
任何的想法? …