如何通过 xcodegen swift 将文件 .a 添加到项目
How to Add file .a to project by xcodegen swift
我想添加 5 个扩展名为 .a 的文件到项目中。我单击“+”按钮然后选择 5 个文件。添加到项目是成功的。但是我的项目使用 xcodegen 所以我想配置文件 project.yml 以在生成新文件 xcodeproj 时自动添加文件 .a。帮我配置文件 project.yml
[IMAGE] General xcode project
[IMAGE] File code config project.yml
name: App
options:
postGenCommand: pod install
targets:
App:
type: application
platform: iOS
deploymentTarget: "12.0"
dependencies:
- target: MagickLibrary
sources:
- path: App
settings:
base:
INFOPLIST_FILE: MyProject/App/Info.plist
CODE_SIGN_STYLE: Manual
DEVELOPMENT_TEAM: I9W3PJNG89
PROVISIONING_PROFILE_SPECIFIER: company dev
CODE_SIGN_IDENTITY: iPhone Developer
DEBUG_INFORMATION_FORMAT: dwarf-with-dsym
TARGETED_DEVICE_FAMILY: 1
SWIFT_VERSION: 5.0
PRODUCT_BUNDLE_IDENTIFIER: com.company.MyProject
ENABLE_BITCODE: 'NO'
SWIFT_OBJC_BRIDGING_HEADER: MyProject/imageconverterios-Bridging-Header.h
MagickLibrary:
deploymentTarget: '12.0'
platform: iOS
sources:
- createIntermediateGroups: true
path: MyProject/iOSMagick-6.8.8-9-libs
type: library.static
我认为你链接静态库的方式是错误的。您需要在 App target
的依赖项中定义静态库(.a)
dependencies:
- framework: MyProject/iOSMagick-6.8.8-9-libs/file1.a
- framework: MyProject/iOSMagick-6.8.8-9-libs/file2.a
- framework: MyProject/iOSMagick-6.8.8-9-libs/file3.a
- framework: MyProject/iOSMagick-6.8.8-9-libs/file4.a
- framework: MyProject/iOSMagick-6.8.8-9-libs/file5.a
并且不要忘记在目标设置中定义 LIBRARY_SEARCH_PATHS:
settings:
base:
LIBRARY_SEARCH_PATHS: "$(inherited) $(PROJECT_DIR)/MyProject/iOSMagick-6.8.8-9-libs"
我想添加 5 个扩展名为 .a 的文件到项目中。我单击“+”按钮然后选择 5 个文件。添加到项目是成功的。但是我的项目使用 xcodegen 所以我想配置文件 project.yml 以在生成新文件 xcodeproj 时自动添加文件 .a。帮我配置文件 project.yml
[IMAGE] General xcode project
[IMAGE] File code config project.yml
name: App
options:
postGenCommand: pod install
targets:
App:
type: application
platform: iOS
deploymentTarget: "12.0"
dependencies:
- target: MagickLibrary
sources:
- path: App
settings:
base:
INFOPLIST_FILE: MyProject/App/Info.plist
CODE_SIGN_STYLE: Manual
DEVELOPMENT_TEAM: I9W3PJNG89
PROVISIONING_PROFILE_SPECIFIER: company dev
CODE_SIGN_IDENTITY: iPhone Developer
DEBUG_INFORMATION_FORMAT: dwarf-with-dsym
TARGETED_DEVICE_FAMILY: 1
SWIFT_VERSION: 5.0
PRODUCT_BUNDLE_IDENTIFIER: com.company.MyProject
ENABLE_BITCODE: 'NO'
SWIFT_OBJC_BRIDGING_HEADER: MyProject/imageconverterios-Bridging-Header.h
MagickLibrary:
deploymentTarget: '12.0'
platform: iOS
sources:
- createIntermediateGroups: true
path: MyProject/iOSMagick-6.8.8-9-libs
type: library.static
我认为你链接静态库的方式是错误的。您需要在 App target
的依赖项中定义静态库(.a)dependencies:
- framework: MyProject/iOSMagick-6.8.8-9-libs/file1.a
- framework: MyProject/iOSMagick-6.8.8-9-libs/file2.a
- framework: MyProject/iOSMagick-6.8.8-9-libs/file3.a
- framework: MyProject/iOSMagick-6.8.8-9-libs/file4.a
- framework: MyProject/iOSMagick-6.8.8-9-libs/file5.a
并且不要忘记在目标设置中定义 LIBRARY_SEARCH_PATHS:
settings:
base:
LIBRARY_SEARCH_PATHS: "$(inherited) $(PROJECT_DIR)/MyProject/iOSMagick-6.8.8-9-libs"