5

I'm trying to build an iOS flutter app in windows using Codemagic. I created the flutter project in android studio and uploaded it to github in order to use it in Codemagic... But when I try to build the iOS app, Codemagic throws me this error:

Warning: Building for device with codesigning disabled. You will have to manually codesign before deploying to device.
Building com.jmmago.saltApp for device (ios-release)...
Running pod install...                                             16.0s
Running Xcode build...                                          
Xcode build done.                                           124.3s
Failed to build iOS app
Error output from Xcode build:
↳
    ** BUILD FAILED **


Xcode's output:
↳
    /Users/builder/programs/flutter/.pub-cache/hosted/pub.dartlang.org/barcode_scan-3.0.1/ios/Classes/protos/protos.pb.swift:14:8: error: compiling for iOS 8.0, but module 'SwiftProtobuf' has a minimum deployment target of iOS 9.0: /Users/builder/clone/build/ios/Release-iphoneos/SwiftProtobuf/SwiftProtobuf.framework/Modules/SwiftProtobuf.swiftmodule/armv7-apple-ios.swiftmodule
    import SwiftProtobuf
           ^
    Command CompileSwift failed with a nonzero exit code
    note: Using new build system
    note: Building targets in parallel
    note: Planning build
    note: Constructing build description
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'barcode_scan' from project 'Pods')
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'sqflite' from project 'Pods')
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'shared_preferences' from project 'Pods')
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'path_provider' from project 'Pods')
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'image_picker' from project 'Pods')
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'MTBBarcodeScanner' from project 'Pods')
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'FMDB' from project 'Pods')
    warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.1.99. (in target 'Flutter' from project 'Pods')

════════════════════════════════════════════════════════════════════════════════
Building a deployable iOS app requires a selected Development Team with a 
Provisioning Profile. Please ensure that a Development Team is selected by:
  1- Open the Flutter project's Xcode target with
       open ios/Runner.xcworkspace
  2- Select the 'Runner' project in the navigator then the 'Runner' target
     in the project settings
  3- Make sure a 'Development Team' is selected. 
     - For Xcode 10, look under General > Signing > Team.
     - For Xcode 11 and newer, look under Signing & Capabilities > Team.
     You may need to:
         - Log in with your Apple ID in Xcode first
         - Ensure you have a valid unique Bundle ID
         - Register your device with your Apple Developer Account
         - Let Xcode automatically provision a profile for your app
  4- Build or run your project again

For more information, please visit:
  https://flutter.dev/setup/#deploy-to-ios-devices

Or run on an iOS simulator without code signing
════════════════════════════════════════════════════════════════════════════════
Encountered error while building for device.


Build failed :|
Failed to build for iOS

In this question, they solved this same problem creating a podfile. But how I create a Podfile? I have to create it in my project and then push it to github? Or there is a way to create it in Codemagic?

Obed Monsalve
  • 171
  • 2
  • 12

2 Answers2

6

I think it might be enough to open up your project up in VSCODE and change the 'IPHONEOS_DEPLOYMENT_TARGET' to 9.0 in all 3 places where it is present. In addition check your AppFrameworkInfo.plist file and set the MinimumiOSVersion to 9.0 there as well.

If you wish to create a podfile through Codemagic however, then you might try to put this into your pre build script for the first run (and remove it later):

cd ios && pod init && git add . && git commit -m "Add Podfile to project" && git push

Arnold Veltmann
  • 666
  • 5
  • 5
  • The "IPHONEOS_DEPLOYMENT_TARGET" and "MinimumiOSVersion" are set to 9.0 by default, that's not the problem. Tried the line and got this [error](https://i.imgur.com/LCxdMPZ.png). Then, when I added `git config --global user.name "My Name"` `git config --global user.email my@email.com`, got this error: `remote: Permission to obedi123/salt-app.git denied to greenhouseci-team.` `fatal: unable to access 'https://github.com/myuser/myproject.git/': The requested URL returned error: 403` Any suggestion? – Obed Monsalve Nov 09 '20 at 18:20
  • 2
    Sure, seems like there's some access issue indeed, I think the best solution would be to add a Codemagic deploy key to your repository with 'push access'. Add the public key to your repositories 'Deploy keys' and add the encrypted key to the environment variables in the UI or .yaml. Set the name for example as ACCESS_SSH_KEY - make sure it ends with _SSH_KEY, so Codemagic will automatically add it to your keys. And then change the remote with this command: git remote set-url origin before the script. Quick demo: https://www.youtube.com/watch?v=zDpLqDh1ETs – Arnold Veltmann Nov 10 '20 at 11:28
  • 2
    Though maybe the easier way, is to set up an access token on Github: https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/creating-a-personal-access-token And add it to your ENV variables, then you should be able to push with: git push "https://your-username:$APP_PASSWORD_ENV_VARIABLE@your-git-service.com/your-repo.git" On GitLab: https://docs.gitlab.com/ee/user/profile/personal_access_tokens.html On BitBucket: https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/ – Arnold Veltmann Nov 11 '20 at 06:06
  • Sorry whats these 3 places? – West Oct 18 '21 at 03:41
-1

I, particularly, choose beta as flutter channel and worked well, did not try the app on a real device yet though.

Leandro Gamarra
  • 141
  • 2
  • 12