如何从Swift包中输出iOS项目的静态库?



我有一个swift包,我想集成到我的CI中,并从中创建一个静态库。

这是Package.Swift的样子:

import PackageDescription
let package = Package(
name: "CMyLibrary",
platforms: [
.iOS(.v11),
.watchOS(.v6),
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
name: "CMyLibrary",
type: .static,
targets: ["CMyLibrary"]),
],
dependencies: [],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
.target(
name: "CMyLibrary",
dependencies: ["CWolfCrypt", "CWolfSsl"],
path: "Sources/CMyLibrary",
cSettings: [
.headerSearchPath("./"),
]),
.target(
name: "CWolfCrypt",
dependencies: [],
path: "Sources/CWolfCrypt",
cSettings: [
.headerSearchPath("./"),
]),
.target(
name: "CWolfSsl",
dependencies: ["CWolfCrypt"],
path: "Sources/CWolfSsl"),
],
cLanguageStandard: .c11
)

执行swift build命令创建一个带有静态库的构建文件夹,但它是MacOS arm64架构的静态库,不能集成到iOS中。

我如何指定的架构为iOS(模拟器/设备)创建这个静态库在iOS项目中使用?

// Logger.h
#import <Foundation/Foundation.h>
@interface Logger : NSObject
+(void)log:(NSString *)sLogStr;
@end
// Logger.m
#import “Logger.h”
@implementation Logger
+(void)log:(NSString *)sLogStr{
NSLog(@”%@”,sLogStr);
}
@end

最新更新