简体   繁体   中英

Using an objective c library (pop) with the swift package manager

I'm trying to migrate a project from Cocoapods to SPM and there is one dependency – pop framework – that I can't make work with SPM.

I've tried to compile it into xcframework and use it as a binaryTarget in SPM but it didn't work. This framework seems to be only visible from objective c projects.

These are the commands I used to make xcframework:

xcodebuild archive -scheme pop-ios-framework -archivePath pop-iphoneos.xcarchive -sdk iphoneos SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild archive -scheme pop-ios-framework -archivePath pop-iphonesimulator.xcarchive -sdk iphonesimulator SKIP_INSTALL=NO BUILD_LIBRARY_FOR_DISTRIBUTION=YES

xcodebuild -create-xcframework -framework pop-iphoneos.xcarchive/Products/Library/Frameworks/pop.framework -framework pop-iphonesimulator.xcarchive/Products/Library/Frameworks/pop.framework -output pop.xcframework

and this is how I imported this project to my package:

targets: [
        .binaryTarget(name: "pop", path: "pop.xcframework"),
        .target(
            name: "...",
            dependencies: [... "SnapKit", "pop"],
            path: "Sources",
            resources: [
                ...
            ]
        ),
    ]

The package compiles and even allows writing import pop . However, it doesn't see any of the classes defined inside the framework.

So, the problem was that I forgot to set Skip Install to No and Build Libraries for Distribution to YES. I thought that the eponymous params at the end of the commands will override these options.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM