在 Xcode 中,我可以选择我的目的地作为“通用 iOS 设备”或任何 iOS 模拟器,我的包将为 ios 构建特定于平台的代码。
通过命令行“swift build”只为 macOS 构建我的目标。
我想为 CI 目的构建 iOS 目标。为 macOS 构建的问题在于不会构建 UIKit 特定的代码。
例如:
#if canImport(UIKit)
// some invalid code
#endif
Run Code Online (Sandbox Code Playgroud)
无效代码不会被注意到,并且会通过构建阶段。
理想情况下,我可以说类似swift build -platform iOS. 有没有办法做这样的事情?
概述
我有两个依赖项,一个作为 Swift 包提供,另一个仅作为 Cocoapod 提供。问题是每个版本都依赖于第三个包,这会导致存在多个版本时出现未定义的行为。
在基本层面上,这是我的依赖项的图形
APP imports:
B (SPM) imports:
C (SPM) imports:
D (SPM) <-
E (Pod) imports:
D (Pod) <-
Run Code Online (Sandbox Code Playgroud)
我想删除该版本并通过 Podfile 脚本或构建脚本D (Pod)指向该版本。D (SPM)
更具体的信息:
我有一个导入的 NetworkingService Swift 包Firebase,我的主应用程序导入 NetworkingService。我的 Podfile 导入GoogleMLKit/PoseDetection. Firebase 和 PoseDetection 共享依赖项,当存在重复项时,这些依赖项会导致未定义的行为(运行时崩溃)。
注意:通过删除中间 NetworkingService 包并将 Firebase 作为 Swift 包导入主应用程序,应该可以重现此错误。
Podfile
platform :ios, '15.0'
target 'MyApp' do
use_frameworks!
pod 'GoogleMLKit/PoseDetection', '2.5.0'
end
Run Code Online (Sandbox Code Playgroud)
在 Package.swift 中
.package(
name: "Firebase",
url: "https://github.com/firebase/firebase-ios-sdk.git",
.upToNextMajor(from: "8.10.0")
),
Run Code Online (Sandbox Code Playgroud)
它们复制了一些依赖项,包括GoogleUtilities …
我的SpriteKit游乐场书在我的MacBook Pro上平均为15 FPS.
游乐场比iOS设备模拟运行得慢吗?如果我在iPad Pro上运行相同的游乐场书,那么FPS限制是否相似?我的电脑上打开的其他应用程序是否会限制游乐场的速度?
编辑: 将子类和扩展的代码移动到操场手册的"Sources"文件夹中的辅助代码允许模拟更快地运行,因为代码只编译一次.
以下示例项目:https://github.com/aws-samples/simple-websockets-chat-app
onconnect 方法如下所示:
const AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB.DocumentClient({ apiVersion: '2012-08-10', region: process.env.AWS_REGION });
exports.handler = async event => {
const putParams = {
TableName: process.env.TABLE_NAME,
Item: {
connectionId: event.requestContext.connectionId
}
};
try {
await ddb.put(putParams).promise();
} catch (err) {
return { statusCode: 500, body: 'Failed to connect: ' + JSON.stringify(err) };
}
return { statusCode: 200, body: 'Connected.' };
};
Run Code Online (Sandbox Code Playgroud)
我怎样才能看到这个对象还有哪些其他字段event?我找不到文档。
连接websocket时可以从客户端传入参数吗?就像我如何从这个对象wss://path.to.socket/someparameter访问它?event
我想向数据库添加另一个参数:
const putParams = {
TableName: process.env.TABLE_NAME,
Item: …Run Code Online (Sandbox Code Playgroud) 我已经对 CALayer 进行了子类化以创建径向渐变(我从这里的代码开始)。问题是我需要更改渐变的颜色,这是在绘制函数中。我希望每次更改时都能够重绘图层colors。我不能直接打电话,draw(in:)因为我不知道用什么CGContext。有任何想法吗?
import Foundation
import UIKit
class CARadialGradientLayer: CALayer {
required override init() {
super.init()
needsDisplayOnBoundsChange = true
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
required override init(layer: Any) {
super.init(layer: layer)
}
public var colors = [UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 0.5).cgColor, UIColor(red: 0.2, green: 0.2, blue: 0.2, alpha: 0.00).cgColor] {
didSet {
/* Redraw the layer to update colors */
}
}
override func draw(in …Run Code Online (Sandbox Code Playgroud) swift ×4
xcode ×2
aws-lambda ×1
calayer ×1
cocoapods ×1
draw ×1
firebase ×1
google-mlkit ×1
ios ×1
swift4 ×1
uikit ×1
websocket ×1
xcodebuild ×1