SwiftFormat icon indicating copy to clipboard operation
SwiftFormat copied to clipboard

starting SwiftFormat from Xcode menu ignores ".swiftformat" config file

Open DubonYaar opened this issue 3 years ago • 12 comments

I'm using Swift format for Xcode extension. I've added ".swiftformat" config file in the project folder, starting Swiftformat from Xcode's menu ignores the config file.

DubonYaar avatar Jun 04 '22 12:06 DubonYaar

This is a known issue (it's due to a limitation in the sandbox restrictions for extensions).

The good news is there's a workaround and it will hopefully be fixed soon. In the meantime, you have to load your .swiftformat file manually in the SwiftFormat for Xcode app to configure the extension.

nicklockwood avatar Jun 04 '22 15:06 nicklockwood

Thanks, How do I load the .swiftformat manually?

DubonYaar avatar Jun 04 '22 17:06 DubonYaar

Use the File > Open… menu in the app

nicklockwood avatar Jun 04 '22 17:06 nicklockwood

@nicklockwood is there any way I can help fix this issue? maybe via a donation? I need this so all my other computers and colleagues are on the same formatting rules as me.

mesqueeb avatar Mar 14 '24 05:03 mesqueeb

@mesqueeb it's a sandboxing limitation imposed by Apple (Xcode extensions can't access the file system). Others have tried to find workarounds but nothing has worked so far

nicklockwood avatar Mar 14 '24 06:03 nicklockwood

@nicklockwood how about adding a text input to the app where we can paste a public url to the config (eg on a public git repo) and then each time your app launches it will fetch the latest config from there.

mesqueeb avatar Mar 14 '24 07:03 mesqueeb

This is something I can try building and PR? Doesn't seem too difficult. Or does the sandbox also prevent https get calls?

mesqueeb avatar Mar 15 '24 08:03 mesqueeb

This is something I can try building and PR? Doesn't seem too difficult. Or does the sandbox also prevent https get calls?

I'm not sure if http requests are allowed actually - it might work. You can't show any UI though, so you'd have to enter the url through the helper app and then sync it across to the extension via user defaults (same way config works currently)

nicklockwood avatar Mar 15 '24 08:03 nicklockwood