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’ => ‘-pack…


This content originally appeared on DEV Community and was authored by Agapov Alexey

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'
}

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'
}


This content originally appeared on DEV Community and was authored by Agapov Alexey


Print Share Comment Cite Upload Translate Updates
APA

Agapov Alexey | Sciencx (2024-10-15T09:12:52+00:00) How to use Swift package access modifier with Cocoapods. Retrieved from https://www.scien.cx/2024/10/15/how-to-use-swift-package-access-modifier-with-cocoapods/

MLA
" » How to use Swift package access modifier with Cocoapods." Agapov Alexey | Sciencx - Tuesday October 15, 2024, https://www.scien.cx/2024/10/15/how-to-use-swift-package-access-modifier-with-cocoapods/
HARVARD
Agapov Alexey | Sciencx Tuesday October 15, 2024 » How to use Swift package access modifier with Cocoapods., viewed ,<https://www.scien.cx/2024/10/15/how-to-use-swift-package-access-modifier-with-cocoapods/>
VANCOUVER
Agapov Alexey | Sciencx - » How to use Swift package access modifier with Cocoapods. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/10/15/how-to-use-swift-package-access-modifier-with-cocoapods/
CHICAGO
" » How to use Swift package access modifier with Cocoapods." Agapov Alexey | Sciencx - Accessed . https://www.scien.cx/2024/10/15/how-to-use-swift-package-access-modifier-with-cocoapods/
IEEE
" » How to use Swift package access modifier with Cocoapods." Agapov Alexey | Sciencx [Online]. Available: https://www.scien.cx/2024/10/15/how-to-use-swift-package-access-modifier-with-cocoapods/. [Accessed: ]
rf:citation
» How to use Swift package access modifier with Cocoapods | Agapov Alexey | Sciencx | https://www.scien.cx/2024/10/15/how-to-use-swift-package-access-modifier-with-cocoapods/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.