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 image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more

👋 Kindness is contagious

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

Okay