apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

Xcode 15.0: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.0.99. #1379

Closed sbarber2 closed 3 months ago

sbarber2 commented 8 months ago

Bug Report

cordova-lib doesn't directly support Xcode 15.0's minimum target deployment version of 12.0

Problem

Using cordova-lib 12.0.1 with XCode 15.0:

/Users/xxxx/cordova_apps/hello/platforms/ios/CordovaLib/CordovaLib.xcodeproj The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.0.99.

What is expected to happen?

When using XCode 15.0, the IPHONEOS_DEPLOYMENT_TARGET is at least 12.0.

What does actually happen?

When using XCode 15.0, the IPHONEOS_DEPLOYMENT_TARGET is at 11.0, and this causes build errors and/or warnings.

For example:

/Users/xxxx/cordova_apps/xcode15test/platforms/ios/HelloCordova.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'HelloCordova' from project 'HelloCordova') /Users/xxxx/cordova_apps/xcode15test/platforms/ios/CordovaLib/CordovaLib.xcodeproj: warning: The iOS Simulator deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.0.99. (in target 'CordovaLib' from project 'CordovaLib')

These are just warnings in the build that occurs using the commands below, but in more complicated builds this version mismatch has caused an error and a failed build.

Information

This is all on MacOS Ventura 13.6.

Command or Code

Install XCode 15.0 or higher Bring up a Terminal

mkdir cordova_apps cordova create xcode15test cd xcode15test cordova add platform iOS cordova build iOS

Environment, Platform, Device

This is all on MacOS Ventura 13.6. The machine is a MacBook Air M1.

Version information

Cordova: Cordova CLI, Cordova Platforms, Cordova Plugins

cordova --version 12.0.0 (cordova-lib@12.0.1)

No plugins

MacOS Ventura 13.6 XCode 15.0

Checklist

breautek commented 8 months ago

cordova-lib is the cordova shared JS library, so I moved this ticket to the more appropriate repo for you.

but in more complicated builds this version mismatch has caused an error and a failed build.

Can you elaborate more on this? Personally I pushed to bump the minimum deployment target for cordova-ios 7 release, but the community kind of voted against it because it was just a warning... and instead favoured to use the lowest deployment target possible. :\

I think you can use the deployment-target preference to override it, so that might also be a workaround for the time being.

dpogue commented 8 months ago

This is just a warning and can be ignored.

As Norman mentions, you can set <preference name="deployment-target" value="12.0" /> in config.xml to force a specific deployment target

sbarber2 commented 8 months ago

I appreciate the responses, thanks.

Yes, all seems well with

It looks like I can no longer reproduce the build failures I mentioned, so I guess that statement can be ignored, life being short.

Also, apologies for putting this Issue in as a bug when upon reflection working with new versions of things tend to be enhancements. I'm such a noob sometimes.

It feels like there is an enhancement request in here somewhere, because it took me a while to find that deployment-target preference on my own.

Ah, here it is: I would have benefited from a clearer error message. Like, the error message about IPHONEOS_DEPLOYMENT_TARGET is coming from a leaky abstraction -- reporting about something that maybe means something to an XCode user, but doesn't point explicitly back to the relevant cordova-ios deployment-target preference.

breautek commented 8 months ago

reporting about something that maybe means something to an XCode user, but doesn't point explicitly back to the relevant cordova-ios deployment-target preference.

The warning comes from XCode. It's part of the native iOS project which has nothing to do with Cordova (from Apple's perspective). So naturally it's not going to provide details to what Cordova may have to configure the project.

mpmontanez commented 7 months ago

@sbarber2 Did you find that setting the "deployment-target" preference did update the IPHONEOS_DEPLOYMENT_TARGET setting in CordovaLib.xcodeproj? For me, setting that preference doesn't seem to change the CordovaLib target.

dpogue commented 7 months ago

setting that preference doesn't seem to change the CordovaLib target.

I don't think it will affect the CordovaLib project, it only applies to the application project

sc0ttdav3y commented 5 months ago

Hi there!

I've got this as well, and I'm hoping someone with more brains than I can kindly point me in the right direction?

In my case, I run:

cordova build ios --debug

and I get:

/app/platforms/ios/Pods/Pods.xcodeproj: warning: The iOS Simulator deployment target
'IPHONEOS_DEPLOYMENT_TARGET' is set to 9.0, but the range of supported deployment 
target versions is 12.0 to 17.2.99. (in target 'XXXXXX' from project 'Pods')

where XXXXXX is repeated for a bunch of low-level pods. The pod names seem to be a dependency of a dependency so I'm not sure what they are, but I can see that one of them is 'CordovaLib' from project 'CordovaLib' but there are many more as well.

In my config.xml I have set <preference name="deployment-target" value="15.0" />, and I can see the generated Podfile has this in it, so it appears to be honouring the preference:

# DO NOT MODIFY -- auto-generated by Apache Cordova
source 'https://cdn.cocoapods.org/'
platform :ios, '15.0'
use_frameworks!
target 'MyApp' do
    project 'MyApp.xcodeproj'
    pod 'CocoaLumberjack', '~> 3.7.2'
    pod 'MLKitTextRecognition'
end

I'm not entirely sure what Cordova does under the hood beyond that, but I can see in XCode it shows iOS 11 as the deployment target despite the Podfile and the preference:

Screenshot 2023-12-20 at 4 32 21 pm

Any help from the cordova-ios brains trust to point me in the right direction would be appreciated!

Also, love your work and thanks!

sc0ttdav3y commented 5 months ago

This further info may help.

If I search for IPHONEOS_DEPLOYMENT_TARGET in platforms/ios, it shows a mix of targets in the Pods project:

Screenshot 2023-12-20 at 5 01 11 pm

I spotted this warning as well:

The `My App [Release]` target overrides the `LD_RUNPATH_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-My App/Pods-My App.release.xcconfig'. This can lead to problems with the CocoaPods installation

Unfortunately for me, coming from a web developer background, so I'm a bit like that meme where I don't know what pods are and at this point I'm too afraid to ask :-)

Through trial and error I found a plugin that was causing this (for me it was plugin-cordova-ml-text).

My mental model is that the plugin was referencing pods that had lower build targets. Interestingly, I still see some lower numbered deployment targets in the Podfile (down to 9.0) and in CordovaLib (down to 11.0) after removing that plugin, but my project compiles now.

Here's my same search afterward in case (less bad targets but still some):

Screenshot 2023-12-20 at 6 11 36 pm

I'm not sure if this is a problem with cordova-ios or not — I don't quite understand it all — but TL;DR from me is to remove your plugins one by one until it works. 🤷🏻

julfrechette commented 3 months ago

Xcode 15 will be mandatory to build apps which can be submitted to the App Store:

Please note that as of April 2024 all iOS and iPadOS apps submitted to the App Store must be built with a minimum of Xcode 15 and the iOS 17 SDK.

Currently, the MyProject deployment minimum version can be updated using: <preference name="deployment-target" value="12.0" />

However this does not apply to CordovaLib.xcodeproj which triggers the a similar build error:

***/platforms/ios/CordovaLib/CordovaLib.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.2.99. (in target 'CordovaLib' from project 'CordovaLib')

Is there another preference which can be applied to all .xcodeproj dependencies generated in the iOS platform and not just MyProject?

All other alternatives which require to manually edit the project files will force us to update our CI/CD workflows which are currently generating the iOS and Android platforms from scratch.

(For best practice, we only commit the Cordova project to our repo, not the files generated at build time)

dpogue commented 3 months ago

However this does not apply to CordovaLib.xcodeproj which triggers the a similar build error:

***/platforms/ios/CordovaLib/CordovaLib.xcodeproj: warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 11.0, but the range of supported deployment target versions is 12.0 to 17.2.99. (in target 'CordovaLib' from project 'CordovaLib')

This is not an error, it is only a warning and can be ignored

ChiragMoradiya commented 3 months ago

We also encountered the same warning. We planned to ignore it for now as @dpogue suggested.

erisu commented 3 months ago

I will close out this ticket as it is only a warning message and shouldn't cause failures with builds or app store submissions.

connyhald commented 3 months ago

This issue may result in a warning or in an error like in this case:

clang: error: SDK does not contain 'libarclite' at the path '/Applications/Xcode_15.2.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a'; try increasing the minimum deployment target

** ARCHIVE FAILED **

Increasing the IPHONEOS_DEPLOYMENT_TARGET of the lib helps here but it looks like we can only set it using Xcode and not as configuration which would be needed for CI/CD, etc...

amcalgates commented 2 months ago

@erisu - this is not just a warning if you're using Xcode 15, and per @julfrechette's comment, we are all going to be forced to use it this month.

In my case this build error (which prevents compilation and is not just a warning) is due to plugins I'm using that bring in Cocoapods that have their deployment target set to a version <12.

This is a problem outside of Cordova as well. For my native apps I've solved the problem by appending this to my Podfile:

post_install do |installer|
    installer.generated_projects.each do |project|
        project.targets.each do |target|
            target.build_configurations.each do |config|
                config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '12.0'
            end
        end
    end
end

As seen here and in many other SO answers.

A temporary workaround to get my Cordova apps to build is to go into Xcode and manually change the deployment target of each offending pod target. However, these changes are all nuked every time I run cordova build ios.

Is there some way for cordova-ios users to modify the Podfile? It seems there is, but that that is also broken? As I have this in my config.xml:

<preference name="deployment-target" value="12.0" />

I really think this issue should be re-opened.

connyhald commented 2 months ago

We solved this using a rather ugly (but working) hack using the following script to post-process the project files.

const fs = require('fs');
const path = require('path');

function findFilePathsByFilename(directory, filename) {
    const files = fs.readdirSync(directory);
    const filePaths = [];

    for (const file of files) {
        const filePath = path.join(directory, file);
        const stats = fs.statSync(filePath);

        if (stats.isDirectory()) {
            // Recursively search in subdirectories
            const subdirectoryFilePaths = findFilePathsByFilename(filePath, filename);
            filePaths.push(...subdirectoryFilePaths);
        } else if (stats.isFile() && file === filename) {
            // If the file matches the filename, add its path to the result
            filePaths.push(filePath);
        }
    }
    return filePaths;
}

const paths1 = findFilePathsByFilename('.', 'project.pbxproj');
const paths2 = findFilePathsByFilename('.', 'Pods.xcodeproj');
const paths = paths1.concat(paths2)

console.log('Apply patch to', paths);

for (let path of paths) {
    let content = fs.readFileSync(path, { encoding: 'utf-8' });
    content = content.replace(/IPHONEOS_DEPLOYMENT_TARGET = [0-9]+.0;/g, 'IPHONEOS_DEPLOYMENT_TARGET = 12.0;');
    fs.writeFileSync(path, content);
}

console.log('Done setting IPHONEOS_DEPLOYMENT_TARGET');