We are setting up CI/CD for iOS project using Gitlab & fastlane tools on Mac Mini(M1 Chip).
When there is a new pull request created, pipeline starts and it executes below command success.
fastlane ios build
But it shows "no such module 'Alamofire'" error for below command.
fastlane ios test
Other observations on same build machine Mac Mini(M1 Chip):
It shows same errors "no such module 'Alamofire'" when try to build or run tests using Xcode(Uncheck Open using Rosetta).
Both build & run tests works fine with Xcode(Check Open using Rosetta).
We are looking for build the iOS project and run unit tests on simulator for new/update pull request. Build works fine but run unit tests fails during compilation.
Any help on this would be greatly appreciated.
You are using cocoapods to import Alamofire right?
Do you happen to have any post_install steps that are setting build_settings in your podfile?
Related
I'm on an M1 Mac Mini, Monterey 12.0.1, with XCode 13.1 & it's command-line tools and freshly-installed Flutter MacOS 2.8.0. I create a base Flutter project with
flutter create appname
When I do "flutter run" in the ios folder (in the parent folder it launches ok in Chrome), I get the message:
Could not build the application for the simulator.
Error launching application on iPhone 13.
I tried it with the simulator running, and not. It looks like the Runner XCode project build stages runs a script, xcode_backend.sh. I also tried loading the project in the XCode UI to build and get 'Command PhaseScriptExecution failed with a nonzero exit code' on that script.
If I go and run this script directly, from the project folder of the ios folder:
guy#Guys-Mac-mini ios % /bin/sh "$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh"
I get the message:
error: Your Xcode project is incompatible with this version of Flutter. Run "rm -rf ios/Runner.xcodeproj" and "flutter create ." to regenerate.
I tried the steps indicated, which I also found on Google, and removed the folder and regenerated the project, but the same message is appearing. (I did export the FLUTTER_ROOT environment variable, both in the shell and it's also defined in the XCode project settings.
I can build and run the flutter apps to Chrome, but not for the iOS simulator. I also have no problem building and running Swift apps I've coded on the simulator.
I got my Windows and Android setup running in minutes, but on the M1 Mac it's been hours without success. Any ideas?
I'm a developer with decent of experience, but this is my first stab at Flutter and cross-platform (other than Xamarin). Any help is appreciated.
I can't fully explain it, but the problem I was having was related to my having the project files on an SMB share I was accessing from the Mac.
I setup the project on an SMB share so I could access it from my Windows and Mac workstations. I found that any flutter project on that share would fail compilation.
To test this, I created a new flutter app on my Mac Documents folder, comiled and ran it succesfully in the iOS simulator using 'flutter run'. When I moved that project to the SMB share and tried to run it, I got the compilation error again, and it wouldn't run (I also tried clean and run). I moved the project back to the local drive Documents folder, and was able to run it again.
I also noticed that the Mac access to the SMB share is painfully slow, though I tried a required_signon fixes from
https://kb.synology.com/en-us/DSM/tutorial/What_can_I_do_to_fix_slow_SMB_file_transfers_on_OS_X_10_11_5 but it didn't help.
I had even tried to factory reset my Mac, and I thought that fixed it, but it was only because I hadn't connected to the share yet, and made a test project on the local drive.
PS: I don't expect to use the exact same Flutter project between the Mac and Windows workstations because of paths and SDK locations, but I am using it as a convenient place for transfering the source files.
My team was able to solve this by supplying an absolute path to the xcode_backend script in a run phase and running it. Running it once seemed to be enough and we could remove it thereafter:
/bin/sh "/absolute-path-to-flutter/packages/flutter_tools/bin/xcode_backend.sh" thin
/bin/sh "/absolute-path-to-flutter/packages/flutter_tools/bin/xcode_backend.sh" embed
I've had this issue for a while now and now that Flutter 2.5 is out, have much more of a need to fix it. I'm trying to build Flutter in profile mode to take advantage of the shader SkSl warmup and reduce runtime jank on iOS (https://flutter.dev/docs/perf/rendering/shader).
The crux of the problem: I get a "No Provisioning Profile was found for your project's Bundle Identifier or your device." error when building to a real device with the "--profile" flag, but building in release mode works fine. To illustrate this:
Working: flutter run --flavor prod -t "lib/main.dart"
Not working: flutter run --profile --flavor prod -t "lib/main.dart" --cache-sksl --purge-persistent-cache
According to the Flutter documentation, the profile flag runs in a slightly modified release mode, so I'm not sure why the build fails.
A couple more details:
I'm using Fastlane Match for provisioning profiles. There's a corresponding "Profile-prod" configuration in XCode which uses the same provisioning profile and bundle identifier as the main production release configuration.
I also have dev and stage build flavors which build to the device fine using a command such as flutter run --flavor stage -t "lib/main_stage.dart"
I've also tried flutter run --profile --cache-sksl --purge-persistent-cache as explicitly mentioned in the documentation but that also fails with the same error
Any suggestions are appreciated!
How to run XCTest (UI test cases) of iOS mobile application in the Azure pipeline?
Tasks added in pipeline:
Install certificate
Install profile
Use Node 13.3.0
pod install
Xcode-> build action as "build-for-testing"
Test with Visual Studio App Center
At this final step "Test with Visual Studio App Center" we get error
Preparing tests... failed.
Error: Unable to find test runner app within /Users/runner/runners/2.164.8/work/1/a/DerivedData/Build/Products/Staging-iphoneos
[error]Error: /usr/local/bin/appcenter failed with return code: 3
How to run XCTest (UI test cases) of iOS mobile application in the azure pipeline?
According to the document Using Azure DevOps for UI Testing, you need make sure the Arguments in the Advanced section of the Xcode task , specify a derived data path, typically using -derivedDataPath DerivedData.
Bsides, You will also need an .ipa file for your application. An you can build the .ipa file in the same Xcode build-for-testing task by checking the Create app package option, or in a separate Xcode build step or in a Bash script step.
Hope this helps.
'Module was not compiled for testing' when using #testable does not resolve this post issue.
I am integrating Xcode project with CI/CD by using jenkins and fastlane. My Xcode project build success if project do not have test cases. If I added my test cases then xcode build failed in jenkins with error:
error: module 'JenkinsFastlaneExample' was not compiled for testing
ScreenShot of error
In one post I found answer to set scheme flag, I made same like answer but didn't work for me.
My test cases are also successful in Xcode 11.x , iOS 13.x. tested in iPhone XR
I unable to find out why jenkins build is failed.
Demo Repo (if needed) : https://github.com/thedahiyaboy/ios_jenkins_example
Edit:
I also tried to disable my test cases from Xcode so that I can run my cases from mac system only and with hope jenkins will skip test bundles, but getting the same issue.
In jenkins, configuration was Release (by default) which was unnoticed by me, after replacing it to Debug my build is succeeded.
Reference Image:
Reference Doc:
https://plugins.jenkins.io/xcode-plugin/
Special thanks to Scriptable for giving time and efforts for solving the issue.
I've set up jenkins on my local machine. Than I created a sample app with one failing and one succeeding unit test. When I issue the following command in the terminal
xcodebuild -scheme 'SampleWithTest' -sdk iphonesimulator7.0
-destination platform='iOS Simulator',OS=7.0,name='iPhone Retina (3.5-inch)' clean test
than it clean build the project, starts the simulator and makes the tests. This is how it should work.
When I run the same command via jenkins, it clean builds the project and ends with ** TEST SUCCEEDED ** without starting the simulator or print out the test results. Jenkins just fakes, that the tests was successful.
I test it on my local machine. Nothing headless, remote, source control, slave, code signing or whatever could make any trouble.
The Jenkins Xcode Plugin has not been updated to work with Xcode 5 and the XCTest framework. See this issue. Jenkins and the Xcode Plugin do not understand XCTest output.
Additionally, Xcode 5 changed how Xcode interacts with the simulator and devices when running tests. While there is something like a "headless mode" now for the simulator, access to that functionality isn't available to the Xcode plugin. This means that in some cases, it looks to the Xcode plugin as if the tests run and exit immediately, which is not accurate.
Xcode is known to be pretty tricky to setup with Jenkins, Travis or other non-Apple CI solutions.
Unit Tests support is even worse so you should try using xctool instead.
Related blog entry here.