The first part of this article will focus on packaging (or skip it) and the next part will focus on packaging itself.

Configuration of the machine

Since you are packing on another machine, you need to:

  1. Put your PC on the same LOCAL area network (or WIFI) as your packing machine
  2. inSystem Preferences -> SharedTo enable the remote login, screen sharing, and file sharing permissions
  3. Vest package renamed under the user directory, convenient packaging
  4. Configure an alias for direct packaging

Then the usual package is through access -> shared screen access, or SSH (remote login) link. If you need to be at home remotely, consider suspending a TeamViewer

Problems encountered

Unable to read key chain

If you log in to another macOS remotely in SSH mode, packaging may fail because the Keychain is not unlocked.

The solution is to create a login password file on the remote machine desktop, assuming the current login password is 12345678:

Echo 12345678 > ~/. Keychain_pass_file to manually create a fileCopy the code

Then, at the top of the script, add:

Note: The password is printed on the first line of the script. If you have concerns about this you can look at a different approach

Keychain_pass = sh("cat ~/.keychain_pass_file") sh "Security unlock-keychain -p #{keychain_pass}" unlock_keychain(path: "~/Library/Keychains/login.keychain", password: "$(cat ~/.keychain_pass_file)")Copy the code

Fastfile sharing

Since there are multiple sock puppets that may be handled by different people, and the packaging script may be updated, how do you get them to share the same Fastfile?

After a little digging, we found that there was an environment variable (ENV) and a remote file that fit the bill perfectly.

Environment variables: – Similar to xcconfig, configure Key/value pairs, and then use ENV[“Key”] to get different values in Fastfile – When packing, execute fastlane fir — ENV weixin, where weixin must be the same as ENV name, for example: .env.weixin Remote file: You can import a remote file to implement a package script that is always the latest version

Package asks for password when signing

When you first pack, you may be asked for a password, which can be solved with this line of command

security set-key-partition-list -S apple-tool:,apple: -k "$(cat ~/.keychain_pass_file)" ~/Library/Keychains/login.keychain
Copy the code

You can also go to the keychain and set the access control permissions for the certificate to do this.