flet icon indicating copy to clipboard operation
flet copied to clipboard

ipa and macOS packaging Error: `Swift Compiler Error (Xcode): No such module 'Python'`

Open ndonkoHenri opened this issue 1 year ago • 5 comments

Discussed in https://github.com/flet-dev/flet/discussions/3748

Originally posted by Zeb152 July 31, 2024

Question

Error: Swift Compiler Error (Xcode): No such module 'Python'

Recently, I messed up python on my computer while I was trying to build toolchain modules (like it says in the documentation) and others for the flet build ipa command, and so I had to completely uninstall it and reinstall it using Homebrew. Python now works, but unfortunately, this caused my python interpreter to be in a different file /opt/homebrew/bin/python3 instead of whatever it was before (I believe it wasn't with Homebrew).

So, I am pretty sure that if I am able to change the file directory of where Xcode pulls python from, it will fix the error. I need to change it to opt/homebrew/bin/python3.

However, because flet doesn't build an Xcode project I am not quite sure how I could change the directory python file. Any ideas? Thanks in advance!

Code sample

No response

Error message

[09:39:07] Created Flutter bootstrap project from gh:flet-dev/flet-build-template with ref    
           0.23.2 ✅                                                                          
           Customized app icons and splash images ✅                                          
[09:39:11] Generated app icons ✅                                                             
[09:39:13] Generated splash screens ✅                                                        
[09:39:18] Packaged Python app ✅                                                             
[09:40:04] Resolving dependencies...                                                          
           Downloading packages...                                                            
             collection 1.18.0 (1.19.0 available)                                             
             fl_chart 0.65.0 (0.68.0 available)                                               
             flutter_lints 2.0.3 (4.0.0 available)                                            
             flutter_markdown 0.6.23 (0.7.3 available)                                        
             http_parser 4.0.2 (4.1.0 available)                                              
             js 0.6.7 (0.7.1 available)                                                       
             lints 2.1.1 (4.0.0 available)                                                    
             material_color_utilities 0.8.0 (0.12.0 available)                                
             meta 1.12.0 (1.15.0 available)                                                   
           ! package_info_plus 8.0.1 (overridden)                                             
             sensors_plus 4.0.2 (6.0.0 available)                                             
             sensors_plus_platform_interface 1.2.0 (2.0.0 available)                          
             toml 0.15.0 (0.16.0 available)                                                   
           ! wakelock_plus 1.2.7 (overridden)                                                 
             web 0.5.1 (1.0.0 available)                                                      
             web_socket_channel 2.4.5 (3.0.1 available)                                       
           Got dependencies!                                                                  
           14 packages have newer versions incompatible with dependency constraints.          
           Try `flutter pub outdated` for more information.                                   
                                                                                              
           Archiving com.zebgames.plant...                                                    
           Updating minimum iOS deployment target to 12.0.                                    
           Upgrading project.pbxproj                                                          
           Upgrading AppFrameworkInfo.plist                                                   
           Upgrading Podfile                                                                  
           Updating project for Xcode compatibility.                                          
           Upgrading project.pbxproj                                                          
           Upgrading Runner.xcscheme                                                          
           Automatically signing iOS for device deployment using specified development team in
           Xcode project: 6D6NPPFU98                                                          
           Running pod install...                                             10.1s           
           Running Xcode build...                                                             
           Xcode archive done.                                         14.5s                  
           Failed to build iOS app                                                            
                                                                                              
           Swift Compiler Error (Xcode): No such module 'Python'                              
           /Users/harperbledsoe/.pub-cache/hosted/pub.dev/serious_python_darwin-0.7.1/darwin/C
           lasses/SeriousPythonPlugin.swift:7:7                                               
                                                                                              
           Encountered error while archiving for device.                                      
                                                                                              
           Error building Flet app - see the log of failed command above.

------------------------------------------------------

  • [X] I have searched for answers to my question both in the issues and in previous discussions.

ndonkoHenri avatar Sep 04 '24 07:09 ndonkoHenri

I had the same problem with flet build macos, see where to fix it.

wssnail avatar Sep 04 '24 13:09 wssnail

@wssnail if you still having this issue, please provide complementary details. (full logs with --v, flet version, python version, etc)

ndonkoHenri avatar Sep 04 '24 13:09 ndonkoHenri

@wssnail if you still having this issue, please provide complementary details. (full logs with --v, flet version, python version, etc)

I had the same problem with flet build macos

suyunSoft avatar Sep 28 '24 11:09 suyunSoft

@wssnail if you still having this issue, please provide complementary details. (full logs with --v, flet version, python version, etc)

Everything worked fine on macOS Sonoma (version 14), but after upgrading to macOS Sequoia (version 15), flet build macos started failing with errors. Even after reinstalling Flutter and Flet, the issue persists. Here is the error message:

 Building macOS bund  694.9s
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:macOS, arch:arm64, id:00008112-001241E00C06201E, name:My Mac }
{ platform:macOS, arch:x86_64, id:00008112-001241E00C06201E, name:My Mac }
/private/var/folders/qq/h1x1qc197w9f2yxfgkf2vxmw0000gn/T/flet_flutter_build_rXKqj1Swx5/build/macos/Build/Products/Release/XCFrameworkIntermediates/serious_python_darwin/Headers/module.modulemap:2:21: error: umbrella header 'Python.h' not found
    umbrella header "Python.h"
                    ^
/.pub-cache/hosted/pub.dev/serious_python_darwin-0.7.1/darwin/Classes/SeriousPythonPlugin.swift:8:8: error: could not build Objective-C module 'Python'
import Python
       ^
warning: Run script build phase 'Run Script' will be run during every build because it does not specify any outputs. To address this issue, either add output dependencies to the script phase, or configure it to run in every build by unchecking "Based on dependency analysis" in the script phase. (in target 'Flutter Assemble' from project 'Runner')
** BUILD FAILED **

System: macos 15.0

Python: 3.10

Flutter : (Channel stable, 3.24.3, on macOS 15.0 24A335 darwin-arm64

Flet: 0.24

Xcode: 16.0 (15)

suyunSoft avatar Sep 28 '24 11:09 suyunSoft

Try building with Flet pre-release.

FeodorFitsner avatar Oct 10 '24 21:10 FeodorFitsner