DEV Community

Agapov Alexey
Agapov Alexey

Posted on

1

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

Sentry mobile image

Mobile Vitals: A first step to Faster Apps

Slow startup times, UI hangs, and frozen frames frustrate users—but they’re also fixable. Mobile Vitals help you measure and understand these performance issues so you can optimize your app’s speed and responsiveness. Learn how to use them to reduce friction and improve user experience.

Read the guide →

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay