我在 Xcode 11.2 中遇到 NearbyMessages问题。当我添加pod 'NearbyMessages'然后执行时pod install,当我打开 时xcworkspace,我收到一个“重复输出文件”错误,Assets.car这是由“[CP] Copy Pods Resources”构建阶段生成的:
警告:重复输出文件 '/Users/.../DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Products/Debug-iphonesimulator/NearbyDemo.app/Assets.car' 任务:PhaseScriptExecution [CP] 复制 Pods 资源 /Users/.. ./DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Intermediates.noindex/NearbyDemo.build/Debug-iphonesimulator/NearbyDemo.build/Script-EB8FCF95DAAD8AF429AAA51F.sh(来自项目'NearbyDemo'的目标'NearbyDemo')
我搜索并发现了旧问题,例如Google Nearby Messages API Broke App Icon,它们似乎可能相关。那个帖子看起来可能是资产和 NearbyMessages 相同问题的早期表现,但看起来旧的编译器可能没有发现这个错误。
在 Xcode 10.3 中,这只是一个警告:
忽略重复的输出文件:'/Users/.../DerivedData/NearbyDemo-elvzmjtrsxnstlemqnzociqoajhv/Build/Products/Debug-iphonesimulator/NearbyDemo.app/Assets.car' 在 shell 脚本构建阶段'[CP] Copy Pods Resources'。此警告表示非常严重的项目配置错误,可能会导致项目中的某些 shell 脚本被完全跳过,从而导致其他构建失败或构建目录中的文件丢失。这将是未来的一个严重错误。(在目标“NearbyDemo”中)
有谁知道无论如何要解决这个问题?我可以降级 Xcode,可能让这个问题通过而不会出现严重错误,但这并不是一个非常吸引人的解决方案。
它可能不相关,但这是我的Podfile:
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'NearbyDemo' do
# …Run Code Online (Sandbox Code Playgroud) 这可能很容易回答..我有一个div里面有一些文本,在那个文本中可以有一些链接,例如你好http://google.com你好http://bing.com.
问题是如何使用css将这些链接显示为超链接.
谢谢
编辑:
我刚看到发布此问题后链接自动显示为超链接.我需要相同的东西.
我正在尝试标记我的应用程序的NSDocumentDirectory的整个文件夹,以便它从iCloud备份中排除,但当我去终端并运行:xattr -plxv com.apple.MobileBackup我收到此错误:没有这样的xattr: com.apple.MobileBackup
提前感谢您提供的任何帮助.
这是我正在使用的代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSURL *pathURL= [NSURL fileURLWithPath:documentsDirectory];
[self addSkipBackupAttributeToItemAtURL:pathURL];
}
- (BOOL)addSkipBackupAttributeToItemAtURL:(NSURL *)URL
{
if (&NSURLIsExcludedFromBackupKey == nil) { // iOS <= 5.0.1
const char* filePath = [[URL path] fileSystemRepresentation];
const char* attrName = "com.apple.MobileBackup";
u_int8_t attrValue = 1;
int result = setxattr(filePath, attrName, &attrValue, sizeof(attrValue), 0, 0);
return result == 0;
} else { // iOS >= 5.1
NSLog(@"%d",[URL setResourceValue:[NSNumber …Run Code Online (Sandbox Code Playgroud) 如何从方法和输出块中返回变量"myDoub(例如= 65)"?
- (double)executeRequestUrlString:(NSString *)urlString withBlock:(double (^)(double myDoub))block {
[NSURLConnection sendAsynchronousRequest:request
queue:[NSOperationQueue mainQueue]
completionHandler:^(NSURLResponse *response,
NSData *data,
NSError *error) {
if (!error){
//data = 65; for example
block(data);
}
}];
return block(data); // ???????? This NOT work
}
- (void)viewDidLoad
{
[super viewDidLoad];
//
.......
//
double myNewDouble = [self executeRequestUrlString:fullUrlImage withBlock:^double(double myDoub) {
return myDoub;
}];
// how i can get here variable "myDoub=65" ????
}
Run Code Online (Sandbox Code Playgroud) 我正在使用故事板中的一些标准标记,每个标记都有相同的背景色。我遇到的问题是,当segue过渡快要完成时,整个框架周围都会出现像背景这样的深色阴影。

这很微弱,但足以引起问题。有人遇到过吗?
我了解到并发DispatchQueue允许其中的代码立即返回,因此不会阻塞调用线程。这通常与加载大数据的后台任务一起使用。
我还了解到完成处理程序(例如, in URLSession)允许在某些任务完成后执行处理程序中的代码。
我的问题是:这是否意味着并发调度队列和完成处理程序具有重叠的目的?如果我已经使用了完成处理程序,就不需要用并发调度队列包装它吗?
比如下面是一个使用 URLSession 的耗时的数据加载任务,用并发调度队列包装它是不是一个好主意?
URLSession(configuration: URLSessionConfiguration.default).dataTask(with: propertiesRequest) { data, response, error in
// print("within dataTask: data: \(data), response: \(response), error: \(error)")
if let error = error {
print(error)
} else if let httpResponse = response as? HTTPURLResponse {
if httpResponse.statusCode == 200 {
print("success: property task request")
do {
handler(responseDict, nil) // This is a function supplied by caller
} catch let error as NSError {
handler(nil, error)
}
}
}
}
Run Code Online (Sandbox Code Playgroud) concurrency grand-central-dispatch completionhandler nsurlsession swift
现在,我正在尝试使用Git中的一个名为Insomnia的类来防止设备在充电时锁定.如果你好奇的话,这个项目就在这里.对于示例代码,它让我这样做:
final class AppDelegate: UIResponder, UIApplicationDelegate {
private let insomnia = Insomnia(mode: .whenCharging)
//app delegate code
}
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,它已声明AppDelegate为final使得insomnia变量未被释放,这将阻止它工作.但是,我不确定,这是不好的做法宣布我AppDelegate的final?或者这会导致我的应用程序出现问题吗?如果这是不好的做法,有没有更好的方法来确保insomnia不被解除分配?
我的 php 代码在服务器上创建了一个空图像
这是我的代码(swift4):
var encoded_img = imageTobase64(image: image1.image!)
func convertImageToBase64(image: UIImage) -> String {
let imageData = UIImagePNGRepresentation(image)!
return imageData.base64EncodedString(options: Data.Base64EncodingOptions.lineLength64Characters)
}
Run Code Online (Sandbox Code Playgroud)
代码:
$decodimg = base64_decode(_POST["encoded_img"]);
file_put_contents("images/".$imgname,$decodimg);
Run Code Online (Sandbox Code Playgroud)
以及准备请求的代码:
@IBAction func BtnSend(_ sender: UIButton) {
var url = "http://xxxxxx/msg.php"
var encoded_img = imageTobase64(image: image1.image!)
let postData = NSMutableData(data: ("message=" + message).data(using: String.Encoding.utf8)!)
postData.append(("&encoded_img=" + encoded_img).data(using: String.Encoding.utf8)!)
request = NSMutableURLRequest(url: NSURL(string: url)! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 20.0)
request.httpMethod = "POST"
request.httpBody = postData as Data
let session = URLSession.shared
let …Run Code Online (Sandbox Code Playgroud) 我正在尝试制作一个为用户绘制对象的应用程序.我现在有一个这样的对象,它是由一个类型的数组构成的[UIBezierPath].然后我使用循环UIBezierPath将数组中的所有s 更改为CGPaths,然后想要逐个绘制那些路径的动画.但是,当我尝试使用此代码时,它不起作用,我无法在网上找到任何有用的信息.这是代码被使用来转换阵列macbookPath它由UIBezierPath成CGPath:
for path in macbookPath {
drawingPath.append(path.cgPath)
}
Run Code Online (Sandbox Code Playgroud)
然后我使用此代码尝试绘制路径:
for cgPath in drawingPath {
shapeLayer.path = cgPath
}
Run Code Online (Sandbox Code Playgroud)
这是函数的其余代码,drawForm()它应该将表单绘制到一个名为的视图上aiDrawView:
@objc func drawForm() {
var drawingPath = [CGPath]()
var macbookPath = Forms.MacbookForm()
let shapeLayer = CAShapeLayer()
shapeLayer.frame = aiDrawView.bounds
for path in macbookPath {
drawingPath.append(path.cgPath)
}
for cgPath in drawingPath {
shapeLayer.path = cgPath
}
let strokeEndAnimation = CABasicAnimation(keyPath: "strokeEnd")
strokeEndAnimation.duration = 2.0
strokeEndAnimation.fromValue …Run Code Online (Sandbox Code Playgroud) 我正在尝试.srt使用以下命令打开文件String:
let str = try String(filePath , encoding : .utf8)\nRun Code Online (Sandbox Code Playgroud)\n但每次我想读取特定.srt文件时都会出现此错误:
\n\n\n无法使用文本编码打开\xe2\x80\x99
\n
问题是什么?
\nswift ×6
ios ×5
appdelegate ×1
arabic ×1
base64 ×1
block ×1
cashapelayer ×1
cgpath ×1
cocoapods ×1
concurrency ×1
css ×1
icloud ×1
image ×1
iphone ×1
javascript ×1
nsurlsession ×1
objective-c ×1
segue ×1
storyboard ×1
string ×1
uibezierpath ×1