Flutter macOS构建在Codemagic缺失librealm_dart.dylib,本地正常
问题:Flutter Realm应用在Codemagic单次构建缺失
librealm_dart.dylib,两次构建正常 问题背景
我正在开发一个使用Realm包的Flutter应用。本地执行flutter build macos --release构建的应用运行正常,但在Codemagic上单次构建时,生成的*.app文件夹中缺失librealm_dart.dylib,导致应用启动崩溃。奇怪的是,连续执行两次完整构建流程后,生成的*.app文件会包含该库,应用可正常运行。
报错信息
dyld[48302]: Library not loaded: @rpath/librealm_dart.dylib
Referenced from: <8FDD2B77-17E3-3688-BCB1-9EF31099437D> /Applications/.app/Contents/Frameworks/realm.framework/Versions/A/realm
Reason: tried: '/Applications//Contents/Frameworks/librealm_dart.dylib' (no such file), '/Applications/ /Contents/Frameworks/realm.framework/Versions/A/Frameworks/librealm_dart.dylib' (no such file),
... (后续路径省略)
单次执行失败的构建脚本
# Setup a new keychain keychain initialize # Fetch signing files app-store-connect fetch-signing-files "<redacted>" --type MAC_APP_STORE --platform MAC_OS --create # Mac installer distribution certificates app-store-connect create-certificate --type MAC_INSTALLER_DISTRIBUTION --save app-store-connect list-certificates --type MAC_INSTALLER_DISTRIBUTION --save # Set up signing certificates keychain add-certificates # Set up code signing settings on Xcode project xcode-project use-profiles flutter build macos --release --build-number=$(($PROJECT_BUILD_NUMBER + 151)) # Package application set -x APP_NAME=$(find $(pwd) -name ios -prune -o -name "*.app" -print) cd $(dirname "$APP_NAME") PACKAGE_NAME=$(basename "$APP_NAME" .app).pkg # Create unsigned package xcrun productbuild --component "$APP_NAME" /Applications/ unsigned.pkg # Installer cert INSTALLER_CERT_NAME=$(keychain list-certificates \ | jq '[.[] | select(.common_name | contains("Mac Developer Installer")) | .common_name][0]' \ | xargs) # Sign the package xcrun productsign --sign "$INSTALLER_CERT_NAME" unsigned.pkg "$PACKAGE_NAME" rm -f unsigned.pkg
连续执行两次成功的构建脚本
# Setup a new keychain keychain initialize # Fetch signing files app-store-connect fetch-signing-files "<redacted>" --type MAC_APP_STORE --platform MAC_OS --create # Mac installer distribution certificates app-store-connect create-certificate --type MAC_INSTALLER_DISTRIBUTION --save app-store-connect list-certificates --type MAC_INSTALLER_DISTRIBUTION --save # Set up signing certificates keychain add-certificates # Set up code signing settings on Xcode project xcode-project use-profiles flutter build macos --release --build-number=$(($PROJECT_BUILD_NUMBER + 151)) # Package application set -x APP_NAME=$(find $(pwd) -name ios -prune -o -name "*.app" -print) cd $(dirname "$APP_NAME") PACKAGE_NAME=$(basename "$APP_NAME" .app).pkg # Create unsigned package xcrun productbuild --component "$APP_NAME" /Applications/ unsigned.pkg # Installer cert INSTALLER_CERT_NAME=$(keychain list-certificates \ | jq '[.[] | select(.common_name | contains("Mac Developer Installer")) | .common_name][0]' \ | xargs) # Sign the package xcrun productsign --sign "$INSTALLER_CERT_NAME" unsigned.pkg "$PACKAGE_NAME" rm -f unsigned.pkg # Setup a new keychain keychain initialize # Fetch signing files app-store-connect fetch-signing-files "<redacted>" --type MAC_APP_STORE --platform MAC_OS --create # Mac installer distribution certificates app-store-connect create-certificate --type MAC_INSTALLER_DISTRIBUTION --save app-store-connect list-certificates --type MAC_INSTALLER_DISTRIBUTION --save # Set up signing certificates keychain add-certificates # Set up code signing settings on Xcode project xcode-project use-profiles flutter build macos --release --build-number=$(($PROJECT_BUILD_NUMBER + 151)) # Package application set -x APP_NAME=$(find $(pwd) -name ios -prune -o -name "*.app" -print) cd $(dirname "$APP_NAME") PACKAGE_NAME=$(basename "$APP_NAME" .app).pkg # Create unsigned package xcrun productbuild --component "$APP_NAME" /Applications/ unsigned.pkg # Installer cert INSTALLER_CERT_NAME=$(keychain list-certificates \ | jq '[.[] | select(.common_name | contains("Mac Developer Installer")) | .common_name][0]' \ | xargs) # Sign the package xcrun productsign --sign "$INSTALLER_CERT_NAME" unsigned.pkg "$PACKAGE_NAME" rm -f unsigned.pkg
疑问
我尝试调试但未找到问题所在,请问Codemagic上缺少什么配置导致该问题?
内容的提问来源于stack exchange,提问作者Daniel Weiss
相关产品推荐
相关产品推荐

