Welcome to follow the official wechat account: FSA Full Stack Action 👋

A, problem,

Recently, the company encountered the following error when packaging the component library with Jenkins

ERROR | [iOS] unknown: Encountered an unknown error (Could not find a `ios` simulator (valid values: ). Ensure that Xcode -> Window -> Devices has at least one `ios` simulator listed or otherwise add one.) during validation.
Copy the code

First, make sure there are no simulators

Xcode -> Window -> Devices and Simulators

All current Simulators are displayed under the list of Simulators on the left. If none are available, click + in the lower left corner to add them

If the interface is not available, use the following command to list the emulators

#List all the emulators
xcrun simctl list 
Copy the code

You can see here that there’s a simulator, and after a search, there’s basically two steps on the web

1, reload Cocoapods

gem uninstall cocoapods
gem install cocoapods
Copy the code

Update fourflusher

gem uninstall fourflusher
gem install fourflusher
Copy the code

Maybe it should have worked in general, but it didn’t work in my case.

Even weirdly, it’s ok to perform checksum packaging of component libraries on your own terminal, but it’s not ok to do it with Jenkins…

I’ll try creating a new Job on Jenkins and have it execute the following command

Bundle --version gem --version Ruby --version fastlane -v xcrun simctl list #Copy the code

After checking all the printed version information one by one, it was found that there was no problem and it was consistent with the result printed on the terminal

Second, solutions

After some thought, think about shutting down all emulators and emptying all emulators

sudo xcrun simctl shutdown all && sudo xcrun simctl erase all
Copy the code

After the execution, Jenkins was used to publish the private component. The result was successful ~😅

3. Other issues

These are some of the other problems encountered during the whole process, and note them down

1, problem,

Cannot find cocoapods

Traceback (most recent call last): 2: from /usr/local/bin/pod:23:in `<main>' 1: The from/Library/Ruby/Site/server/rubygems rb: 294: in ` activate_bin_path '/ Library/Ruby/Site/server/rubygems rb: 275: in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)Copy the code

2, the reason

The reason is that the Ruby environment is unhinged and the gem executable file cannot be found

3, solve

1. Reinstall the Ruby environment

Run the following command to reinstall the Ruby environment (the latest version is installed by default)

rvm reinstall ruby --disable-binary
Copy the code

The latest version is installed here, but the current installed version is not necessarily the default.

Run the following command to view the version

rvm list
Copy the code

The default version is 2.6.3. The current terminal uses version 3.0.0. When the terminal is reopened, version 2.6.3 will be used

LXFMBP:~ LXF $RVM list ruby-2.3.1 [x86_64] ruby-2.4.6 [x86_64] ruby-2.5.1 [missing bin/ruby] * ruby-2.6.3 [x86_64] ] ruby-2.7.2 [x86_64] => ruby-3.0.0 [x86_64]
# => - current
# =* - current && default
#  * - default
Copy the code

Run the following command to set the default version

#RVM --default use Version numberRVM - the default use 3.0.0Copy the code

Here are the results:

LXFMBP:~ LXF $RVM list ruby-2.3.1 [x86_64] ruby-2.4.6 [x86_64] ruby-2.5.1 [missing bin/ruby] ruby-2.6.3 [x86_64] missing bin/ruby Ruby-2.7.2 [x86_64] =* ruby-3.0.0 [x86_64]
# => - current
# =* - current && default
#  * - default
Copy the code

2. Reinstall Cocoapods and Fastlane

After reinstalling the Ruby version, you need to reinstall Cocoapods

gem install cocoapods
Copy the code

The same goes for Fastlane

gem install fastlane
Copy the code