(1)dyld: Library not loaded: @rpath/libswiftCore.dylib
Xcode14.2下在项目中引入了 pod 'Purchases'后,运行项目崩溃报错:
dyld: Library not loaded: @rpath/libswiftCore.dylib
解决方式:
在Xcode的BuildSettings -> Linking -> runpath search paths中增加/usr/lib/swift后,在运行项目就正常了。
(2)使用RevenueCat做订阅时,错误信息:
[Purchases] - ERROR: 🍎‼️ Error fetching offerings - Error Domain=RCPurchasesErrorDomain Code=23 "There's a problem with your configuration. There are no products registered in the RevenueCat dashboard for your offerings. To configure products, follow the instructions in rev.cat/how-to-conf…. More information: rev.cat/why-are-off…" UserInfo={NSLocalizedDescription=There's a problem with your configuration. There are no products registered in the RevenueCat dashboard for your offerings. To configure products, follow the instructions in rev.cat/how-to-conf…. More information: rev.cat/why-are-off…, readable_error_code=CONFIGURATION_ERROR}
解决:在RevenueCat网站完成配置要求
(3)xcode15编译oc开发的项目,使用到一个swift库Purchases,在编译时报错:
ld: Undefined symbols: __swift_FORCE_LOAD__swiftCompatibility50_\_PurchasesCoreSwift in libPurchasesCoreSwift.a\[3\](AppleReceipt.o) \_\_swift\_FORCE\_LOAD\__swiftCompatibility51, referenced from: __swift_FORCE_LOAD__PurchasesCoreSwift in libPurchasesCoreSwift.a[3](AppleReceipt.o) __swift_FORCE_LOAD__swiftCompatibility56_\_PurchasesCoreSwift in libPurchasesCoreSwift.a\[3\](AppleReceipt.o) \_\_swift\_FORCE\_LOAD\__swiftCompatibilityConcurrency, referenced from: __swift_FORCE_LOAD__PurchasesCoreSwift in libPurchasesCoreSwift.a[3](AppleReceipt.o) __swift_FORCE_LOAD__swiftCompatibilityDynamicReplacements_$_PurchasesCoreSwift in libPurchasesCoreSwift.a[3](AppleReceipt.o)
解决:搜索"swift_FORCE_LOAD_$_swiftCompatibility50"找到类似的问题,别人给的解决方案,试了一下,有效(地址:bin.zmide.com/?p=677)
(3)使用TZImagePickerController库图片选择器,报错:
解决:在项目配置"Link Binary with Libraries"中引入PhotoUI.framework
(4)在iOS14系统中使用 TZImagePickerController 弹出图片选择器,但是不显示"取消"和"完成"按钮:
解决:在TZPhotoPickerController.m中找到函数addMorePhoto,修改为:
- (void)addMorePhoto { NSLog(@"iOS Version: %@", [[UIDevice currentDevice] systemVersion]); if (@available(iOS 14, *)) { @try { PHPhotoLibrary *photoLibrary = [PHPhotoLibrary sharedPhotoLibrary]; // 设置“取消”按钮的文字颜色 UIBarButtonItem *cancelButton = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class]]]; [cancelButton setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal]; // 设置“完成”按钮的文字颜色 UIBarButtonItem *doneButton = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UINavigationBar class]]]; [doneButton setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor systemBlueColor]} forState:UIControlStateNormal]; // 展示有限照片库选择器 [photoLibrary presentLimitedLibraryPickerFromViewController:self];
} @catch (NSException *exception) { // 捕获异常并处理 NSLog(@"Caught an exception: %@", exception); } @finally {
// 无论是否有异常都会执行的代码块 } }
}
(5)iOS使用ffmpeg框架遇到的问题
①真机运行项目,提示错误:
dyld: Library not loaded: @rpath/libswresample.framework/libswresampleReferenced from: /private/var/containers/Bundle/Application/53D6B0EA-1CB3-41D2-BD6E-E5E48D279357/DHWaterMarkManager.app/DHWaterMarkManagerReason: image not found
解决:
"Embed Frameworks" 是用于将动态链接库(如框架)嵌入到生成的应用程序包中的。
或者在General下找到对应的Framework库,设为"Embed Without Signing":
如果xcode在真机运行app提示校验签名失败:
Failed to verify code signature of /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.VyWVg5/extracted/iOSFaceMotionMaster.app/Frameworks/libswresample.framework : 0xe800801c (No code signature found.)
那么就把"Embed Without Signing"改成"Embed & Sign",编译时给 libswresample.framework签名。
详细步骤请参考:https://github.com/arthenica/ffmpeg-kit/wiki/Importing-iOS-Frameworks
(6)xcode上传app到appstore时
① 报错:
Asset validation failed
Unsupported Architectures. The executable for DHWaterMarkManager.app/Frameworks/ffmpegkit.framework contains unsupported architectures '[i386, x86_64]'.
请注意让"Build Phases"中的"Run Script"在"Embed Frameworks"之后,才能在app中已嵌入Framewoks后执行"Run Script"。
② 如果使用了该脚本,因为cocoapods中的framework继续报错如下:
Executable is /Users/wangjun1/Library/Developer/Xcode/DerivedData/iOSFaceMotionMaster-gsyimcfwvvvpxbfnfwsieaabswhj/Build/Intermediates.noindex/ArchiveIntermediates/iOSFaceMotionMaster/InstallationBuildProductsLocation/Applications/iOSFaceMotionMaster.app/Frameworks/SDWebImage.framework/SDWebImage
Extracting arm64 from SDWebImage
fatal error: lipo: input file (/Users/wangjun1/Library/Developer/Xcode/DerivedData/iOSFaceMotionMaster-gsyimcfwvvvpxbfnfwsieaabswhj/Build/Intermediates.noindex/ArchiveIntermediates/iOSFaceMotionMaster/InstallationBuildProductsLocation/Applications/iOSFaceMotionMaster.app/Frameworks/SDWebImage.framework/SDWebImage) must be a fat file when the -extract option is specified
Merging extracted architectures: arm64
fatal error: lipo: can't open input file: /Users/wangjun1/Library/Developer/Xcode/DerivedData/iOSFaceMotionMaster-gsyimcfwvvvpxbfnfwsieaabswhj/Build/Intermediates.noindex/ArchiveIntermediates/iOSFaceMotionMaster/InstallationBuildProductsLocation/Applications/iOSFaceMotionMaster.app/Frameworks/SDWebImage.framework/SDWebImage-arm64 (No such file or directory)
rm: /Users/wangjun1/Library/Developer/Xcode/DerivedData/iOSFaceMotionMaster-gsyimcfwvvvpxbfnfwsieaabswhj/Build/Intermediates.noindex/ArchiveIntermediates/iOSFaceMotionMaster/InstallationBuildProductsLocation/Applications/iOSFaceMotionMaster.app/Frameworks/SDWebImage.framework/SDWebImage-arm64: No such file or directory
Replacing original executable with thinned version
可以尝试使用我修改后的脚本忽略掉Cocoapods中的frameworks,脚本如下:
APP_PATH="${TARGET_BUILD_DIR}/${WRAPPER_NAME}"
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"
if [ ! -f "$FRAMEWORK_EXECUTABLE_PATH" ]; then
echo "Executable not found: $FRAMEWORK_EXECUTABLE_PATH"
continue
fi
EXTRACTED_ARCHS=()
for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
if [ $? -ne 0 ]; then
echo "Error extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
continue
fi
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done
if [ ${#EXTRACTED_ARCHS[@]} -eq 0 ]; then
echo "No architectures extracted for $FRAMEWORK_EXECUTABLE_NAME"
continue
fi
echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
if [ $? -ne 0 ]; then
echo "Error merging architectures for $FRAMEWORK_EXECUTABLE_NAME"
continue
fi
rm "${EXTRACTED_ARCHS[@]}"
echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"
done
(7)创建swift项目并使用swiftUI,项目使用了cocoapods后,编译报错:
error: Sandbox: rsync(15491) deny(1) file-write-create /Users/xxx/Library/Developer/Xcode/DerivedData/TestSwiftUI-cxtrbxhdgirwfcbbxqqzuddliyeg/Build/Products/Debug-iphoneos/TestSwiftUI.app/Frameworks/Alamofire.framework/.Alamofire.QtTTzq (in target 'TestSwiftUI' from project 'TestSwiftUI')
rsync: mkstemp "/Users/xxx/Library/Developer/Xcode/DerivedData/iOSFaceMotionMaster-hbdmudfpswgygwgdhroltjbtykvr/Build/Products/Debug-iphoneos/iOSFaceXXX.app/Frameworks/Alamofire.framework/.Alamofire.3Umkz1" failed: Operation not permitted (1)
解决:在Building Settings中的 ENABLE_USER_SCRIPT_SANDBOXING(也就是:User Script Sandboxing)设为NO.
(8)Xcode15运行使用了cocoapods的项目报错:
clang: error: SDK does not contain 'libarclite' at the path '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/arc/libarclite_iphoneos.a'; try increasing the minimum deployment target
解决:
stackoverflow.com/questions/7…
(9)Xcode15.2上编译swift项目正常,但是Archive时报错:
Alamofire.framework failed: No such file or directory
找不到Alamofire.framework的路径了,但我确定已经使用Cocoapods安装了Alamofire.framework。
解决:
Workaround is to update all the generated ...-frameworks.sh files to add the -f flag to the call to readlink. In other words, replace
source="$(readlink "${source}")"
with
source="$(readlink -f "${source}")"
This is my first time contributing to CocoaPods though, so take it with a grain of salt!
解释:应该是CocoaPods脚本的问题,可以在项目中搜索
source="$(readlink "${source}")"
找到后替换为
source="$(readlink -f "${source}")"
就可以了。
(10)iOS开发在Xcode15中使用GoogleDataTransport,错误:A function declaration without a prototype is deprecated in all versions of C
GoogleDataTransport.framework下的很多函数报这个错误。
解决:
找到Pod下的GoogleDataTransport,修改Strict Prototypes 为NO
(11)在Mac M3 Pro上MacOS Sonoma系统Xcode 15.3 ,编译运行APP正常,但是Archive报错:
chown: CORP\Domain Users: illegal group nameCommand SetOwnerAndGroup failed with a nonzero exit code
解决:
具体不知道什么原因,后来关闭了mac上的vpn软件ClashX,再次Archive成功。
(12)提交App Store后,苹果提示:二进制文件无效
ITMS-91056: Invalid privacy manifest - The PrivacyInfo.xcprivacy file from the following path is invalid: “Frameworks/CropViewController.framework/TOCropViewControllerBundle.bundle/PrivacyInfo.xcprivacy”. Keys and values in your app’s privacy manifests must be valid. For more details about privacy manifest files, visit: developer.apple.com/documentati…. ITMS-91056: Invalid privacy manifest - The PrivacyInfo.xcprivacy file from the following path is invalid: “Frameworks/Reachability.framework/ReachabilitySwift.bundle/PrivacyInfo.xcprivacy”. Keys and values in your app’s privacy manifests must be valid. For more details about privacy manifest files, visit: developer.apple.com/documentati….
解决:删除指定的PrivacyInfo.xcprivacy文件。