I got a project that I am developing for iOS only with a local Swift package that I want to localize, so I added the
Resources dir and added a
defaultLocalization line in the Package.swift. That local package has a dependency on GRDBQuery.
Now when I want to export the localized strings, I get this error:
I don't even use macOS in the Entities package:
This is a really annoying error. Does anyone know how to fix it? I can NOT add macOS as a target. Why does it say 'this target supports 10.13'?
I can localize my main target fine when my local package does NOT use localization. As soon as it does, I see in the logging that it uses macOS to build. When the local packages do not have localization, iOS SDK is used.
platforms entry can easily be misunderstood. Only the restrictions are listed inside the
platforms entry. (To my knowledge, you still cannot exclude platforms, see e.g. this older topic.) You do not have any listed restriction for macOS. When you use a package, you have to consider all platform restrictions of the package. Just add an according restriction for macOS and you should be fine.
According to the screenshot, you are building the
Entities target for macOS, maybe that's the root issue here? Also curious to see "Destination (null)".
Hmmm, I don't understand this answer. 'Only the restrictions are listed inside the
platforms entry.' How do you mean? The platform section is the supported platform section right?
'Just add an according restriction for macOS and you should be fine.' How would I do that?
I didn't do that, Xcode does that somehow automatically when there is a local package which can be localized, I checked that.
The whole problem is that it builds with macOS, I don't want that, my app does not support that. I think it is odd Xcode decides to build it with macOS.
platforms: [.iOS(.v16),] says to you have a restriction for iOS, but there is no restriction for any other platform. So I would think that
platforms: [.iOS(.v16), macOS(.v10_15),] would save you.
You mean that you cannot add
macOS(.v10_15) in the
No I can not add that, that will mean I have to wrap a lot of code inside #if IOS, something I don't really want to do
Well, I think for for an iOS app you should use the according Xcode project format and not a project for the Swift Package Manager, or has this changed? Can anyone else help with this? ... (Sorry, I do not do iOS apps so I maybe I did not see the main problem here.)
Ofcourse you can use SPM with an iOS Xcode project. The main problem is: I use UIKit in almost every file. I can not simply say: I use macOS now, that causes hundreds of compile errors. If Xcode would just build with iOS there would be no problem
So this is happening when using Product => Export Localizations and choosing the overarching iOS project or only when specifically choosing the local package?
What you did not understand is that adding
macOS(.v10_15) does not introduce a new target, it just restricts the macOS version when targeting macOS. If you do not mention macOS in the
platforms entry, macOS is not (!) excluded.
For both it will build with macOS.
Look for platform target settings within Xcode (not in Package.swift).
Aaah, alright, thanks for the clarification. It would probably work when I add the macOS version to the platform with the correct version and build with iOS. But if I add the version for macOS, I got error that UIKit is not available on macOS. This is the main problem: Xcode decides to build with macOS. My whole app is not designed for macOS, so this gives a lot of errors.
See my last comment. May this helps.
I checked it, it is iOS only
So I guess better use the Xcode project format for an iOS project. In such a project you can then add packages that are realized for the Swift Package Manager.
It seems I have the same issue.
I'm building an iOS app, and have multiple packages to split my main app into many modules (for different features or helpers). I specified the platforms: [ .iOS(.v16) ] in each package. Each package has a Resources folder with the folders for the languages (like fr.lproj). I can successfully run the app on simulators or real devices and the manual localisations added to the strings file are working as expected. But when I want to export the strings using the Product > Export Localizations menu, I get the same errors:
**Showing Recent Messages**
No such module 'UIKit'
UIKit is not available when building for macOS. Consider using `#if canImport(UIKit)` to conditionally import this framework.
This happen if I try to export the localisations either for the app target or for a single package. Is there a solution? Why is the export feature trying to compile for macOS?
Is there any solution to this problem? We're simply trying to export iOS localizations in our project that contains various SPM packages. Why in the world is this trying to build for macOS? How do we turn this idiotic option off?
Running following command allowed me to export my localized strings:
xcodebuild -exportLocalizations -localizationPath <output_dir> -project <project_name>-sdk iphoneos -exportLanguage en