DEV Community

Agapov Alexey
Agapov Alexey

Posted on

How to use Swift package access modifier with Cocoapods

TL;DR:

❌ error:

The package access level used on 'method' requires a package name; set it with the compiler flag -package-name

If you don't have SPM, here is the fix in .podspec file:

s.pod_target_xcconfig = {
    'OTHER_SWIFT_FLAGS' => '-package-name MyPackage'
}
Enter fullscreen mode Exit fullscreen mode

MyPackage should be your Package/Pod name.


We still have a large codebase on Swift that is managed by Cocoapods.
Tons of modules.

We don't want to use SPM as our main package manager, so we have to fix an error with package access modifier.

The fix is adding a flag with -package-name MyPackage inside build settings. But you probably want to do it in source of cocoapods generation, not in Xcode itself.

# MyPackage.podspec
s.pod_target_xcconfig = {
    'OTHER_SWIFT_FLAGS' => '-package-name MyPackage'
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)