Insta360Develop / CameraSDK-iOS

iOS SDK to control Insta360 cameras.
40 stars 5 forks source link

Runtime Errors and Warnings with INSCameraSDKSample-3.0.4_403 #40

Open shoaoki-arent opened 5 months ago

shoaoki-arent commented 5 months ago

I have integrated the Framework from what appears to be the latest SDK version, INSCameraSDKSample-3.0.4_403, into my project. Upon building, I encountered the following issues. Could these issues be specific to my environment?

  1. Runtime Log Warnings When including INSCameraSDK.xcframework and INSCoreMedia.framework in my project and setting both to Embed & Sign under Frameworks, Libraries, and Embedded Content, the following warning appears in the log:
objc[1700]: Class INSPBWindowCropInfoRoot is implemented in both /private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCameraSDK.framework/INSCameraSDK (0x1048645e0) and /private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCoreMedia.framework/INSCoreMedia (0x10e0a9300). One of the two will be used. Which one is undefined.
objc[1700]: Class INSPBWindowCropInfo is implemented in both /private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCameraSDK.framework/INSCameraSDK (0x104864608) and /private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCoreMedia.framework/INSCoreMedia (0x10e0a9328). One of the two will be used. Which one is undefined.
objc[1700]: Class INSPBOffsetStateRoot is implemented in both /private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCameraSDK.framework/INSCameraSDK (0x104864860) and /private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCoreMedia.framework/INSCoreMedia (0x10e0a9d50). One of the two will be used. Which one is undefined.

Previously, I used INSCameraSDK.xcframework and INSCoreMedia.framework from INSCameraSDK-SampleOC-2.9.43_388, and these warnings were not present. Also, INSCoreMedia is a framework, not an xcframework.

  1. Runtime Errors with xcframework Using INSCameraSDK.xcframework and INSCoreMedia.xcframework results in runtime errors with the following log:
    
    dyld[1622]: Library not loaded: @rpath/SSZipArchive.framework/SSZipArchive
    Referenced from: <6AAA3B66-16B8-35E0-892F-16377AF003A2> /private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCoreMedia.framework/INSCoreMedia
    Reason: tried: '/private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file), '/private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCoreMedia.framework/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file), '/private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file), '/private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/INSCameraSDK.framework/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file), '/usr/lib/swift/SSZipArchive.framework/SSZipArchive' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/SSZipArchive.framework/SSZipArchive' (no such file), '/private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file), '/private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file), '/usr/lib/swift/SSZipArchive.framework/SSZipArchive' (no such file, not in dyld cache), '/private/preboot/Cryptexes/OS/usr/lib/swift/SSZipArchive.framework/SSZipArchive' (no such file), '/private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file), '/private/var/containers/Bundle/Application/{UUID}/{my app name}.app/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file), '/System/Library/Frameworks/SSZipArchive.framework/SSZipArchive' (no such file, not in dyld cache)

Both are set to Embed & Sign in Frameworks, Libraries, and Embedded Content, and both are using xcframework. As a preliminary fix, I tried adding SSZipArchive via pod install, which then indicated that NvEffectSdkCore was required.

Thank you for your assistance!
sssuourabh commented 5 months ago

Hi are you able to compile? I am not able to compile even.

Screenshot 2024-06-20 at 10 06 49 AM

@shoaoki-arent

sssuourabh commented 5 months ago

this is the output i am getting on Xcode 15.

A shell task (/usr/bin/xcrun lipo -create /Users/sourabhsingh/Library/Caches/org.carthage.CarthageKit/DerivedData/15.2_15C500b/Eureka/5.5.0/Build/Intermediates.noindex/ArchiveIntermediates/Eureka/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Eureka.framework/Eureka /Users/sourabhsingh/Library/Caches/org.carthage.CarthageKit/DerivedData/15.2_15C500b/Eureka/5.5.0/Build/Products/Release-iphonesimulator/Eureka.framework/Eureka -output /Users/sourabhsingh/Documents/NEWSDK/19june2024/INSCameraSDK/Carthage/Build/iOS/Eureka.framework/Eureka) failed with exit code 1: fatal error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: /Users/sourabhsingh/Library/Caches/org.carthage.CarthageKit/DerivedData/15.2_15C500b/Eureka/5.5.0/Build/Intermediates.noindex/ArchiveIntermediates/Eureka/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/Eureka.framework/Eureka and /Users/sourabhsingh/Library/Caches/org.carthage.CarthageKit/DerivedData/15.2_15C500b/Eureka/5.5.0/Build/Products/Release-iphonesimulator/Eureka.framework/Eureka have the same architectures (arm64) and can't be in the same fat output file

Building universal frameworks with common architectures is not possible. The device and simulator slices for "Eureka" both build for: arm64

sssuourabh commented 5 months ago

Please ignore my comments I am able to successfully run the example app.

shoaoki-arent commented 5 months ago

@sssuourabh Thank you for your comment. I found it difficult to run the sample app, so I decided not to proceed with it. I already have an older version of the INSCameraSDK embedded in my app, so I thought it would be sufficient to just replace it.

By the way, the sample app seems to be embedding a .framework instead of an .xcframework, so I don't think it provides any hints for solving the second point in my comment.

sssuourabh commented 5 months ago

@shoaoki-arent actually i figured out how to run the sample app. I haven't used in my app till now. if you need any help on running the sample app drop me a message. Thanks

shoaoki-arent commented 5 months ago

@sssuourabh Thank you very much.

When you have some time, could you please let me know what you did to get the sample app running? I'm sure it will be helpful to others as well.

Here’s what I have done so far: I tried fixing the path to the framework in the Frameworks directory (I couldn't find NSLogger.framework). image

After that, I'm encountering the following error with Eureka. It might be because I am using Xcode 15.2. However, this is the result of testing on a simulator, and the result may be different on a real device.

Compiled module was created by a different version of the compiler '5.9.0.128.108'; rebuild 'Eureka' and try again: /Users/{username}/Library/Developer/Xcode/DerivedData/INSCameraSDKSample-bluetooth-bnxikozjplyitngpcnkyktrpwnet/Index.noindex/Build/Products/Debug-iphoneos/Eureka.framework/Modules/Eureka.swiftmodule/arm64-apple-ios.swiftmodule
sssuourabh commented 5 months ago

Hi, Please follow these steps - In cartfile please update this - binary "https://ios-releases.insta360.com/INSCoreMedia.json" == 1.25.30 github "xmartlabs/Eureka" ~> 5.5

after that go to folder and run carthage update --use-xcframeworks

Screenshot 2024-06-21 at 11 10 08 AM

Just select the framework here and map to right address in right pane selecting the file. Go to build phase and check there is duplicate file addition of appdelegate and NSData+Hex remove them.

Screenshot 2024-06-21 at 11 12 15 AM

Ensure this in embed frameworks in build phase

ravilich86 commented 5 months ago

Hi @shoaoki-arent! I also have Xcode 15.2. As @sssuourabh suggested, you need to update the Cartfile. I also noticed that you have both INSCoreMedia.xcframework and INSCoreMedia.framework. You only need one of them. I removed NSLogger.framework entirely, and everything compiles for me.

Снимок экрана 2024-06-22 в 15 30 24 Снимок экрана 2024-06-22 в 15 30 32
shoaoki-arent commented 5 months ago

@sssuourabh @ravilich86 Thank you very much. I appreciate both of your assistance. I successfully managed to build on the actual device. I was struggling with errors, but after extracting the sample project again and starting over from the beginning, it worked out perfectly. Thank you for the wonderful tip!

shoaoki-arent commented 5 months ago

P.S. I understand that it is pointless since we are working with an real camera, but when trying to build on the simulator, I encountered an error in INSCameraSDK.xcframework indicating something like "no build for the simulator." Therefore, I have given up on running it on the simulator.

jessearmandse commented 5 months ago

@shoaoki-arent To have a universal framework, you'd need to build another simulator target. This can be an empty target in Xcode with sdk set to iphonesimulator. Then, you'd have to create a new xcframework from both architecture.

The resulting xcframework should contain these files:

Info.plist
ios-arm64
ios-arm64_x86_64-simulator

Although I wish Insta360 would just provide a proper INSCameraSDK.xcframework and INSCoreMedia.xcframework with universal architecture for us 😄

shoaoki-arent commented 5 months ago

@jessearmandse Thank you for the information. Does it actually work in the simulator, or is it solely intended to ensure a successful build?

jessearmandse commented 5 months ago

It's just to ensure a successful build. I guess you could also just link it on Apple Silicon machine, and bypass the simulator entirely.

sssuourabh commented 4 months ago

hi @jessearmandse can you please provide more info on this - https://github.com/Insta360Develop/CameraSDK-iOS/issues/40#issuecomment-2185851367 Need to create a fat binary to build on ios simulator also. @shoaoki-arent @kelvinhkw @capjason

sssuourabh commented 4 months ago

@shoaoki-arent To have a universal framework, you'd need to build another simulator target. This can be an empty target in Xcode with sdk set to iphonesimulator. Then, you'd have to create a new xcframework from both architecture.

The resulting xcframework should contain these files:

Info.plist
ios-arm64
ios-arm64_x86_64-simulator

Although I wish Insta360 would just provide a proper INSCameraSDK.xcframework and INSCoreMedia.xcframework with universal architecture for us 😄

@jessearmandse can you please help regarding this? Need to submit build!

jessearmandse commented 4 months ago

The process is not different from the official docs here: Creating a multi platform binary framework bundle

You'd just need to archive the simulator target, then create xcframework from the simulator archived framework and the arm64 framework.

sssuourabh commented 4 months ago

But we don't have the code of INSCameraSDK framework. so how to create an empty target in Xcode with sdk set to iPhonesimulator.? or what are steps to ensure your Xcode project has a scheme that builds only the framework target and its dependencies.? @jessearmandse

jessearmandse commented 4 months ago

You don't need the code to create xcframework, all you need is the binary. The Xcode project has no dependencies, it's just an empty target. You can add any code you want it doesn't matter. All it matters is it's a simulator architecture. Also don't misunderstood this process as running Insta360 SDK on a simulator, this is just to create an xcframework that contains both architecture.

sssuourabh commented 4 months ago

Yes you are correct i am little confused. So my steps should be i create a new project with name of INSCameraSDK with

Screenshot 2024-07-08 at 1 41 37 PM

and then archive it as mentioned in - https://developer.apple.com/documentation/xcode/creating-a-multi-platform-binary-framework-bundle and then use INSCameraSDK from InstaExample to create a xcframework.? Or any other technique please tell me if possible. @jessearmandse

jessearmandse commented 4 months ago

Yup, change the destination appropriately as described there. If the docs are not clear enough, you can refer to this:

How to create xcframework that contains iOS + iOS Simulator platforms

But, basically the fundamentals are already there in Apple docs

sssuourabh commented 4 months ago

okay so do i have to do for both INSCameraSDK ans INSCoreMedia both? @jessearmandse

jessearmandse commented 4 months ago

Ahmm, INSCoreMedia need a preliminary step to extract the x86_64 architecture, and once you have the arm64 binary, do the same step as INSCameraSDK

Please, read up on why this is the case from Apple official docs for more details, and how I came up with this process. The steps that I did here is not official recommended steps, and depends on your project needs.

Ideally, Insta360 should create this xcframework with both archs. I simply could not wait for them to do so.

sssuourabh commented 4 months ago

https://github.com/Insta360Develop/CameraSDK-iOS/issues/40#issuecomment-2213131040

@jessearmandse i tried this then when i combined and tried build in Simulator in app it says all headers missing from framework. Sometimes it didn't successfully create xcArchives. Please help me if possible, it's urgent. Thanks in advance.

Screenshot 2024-07-11 at 2 42 49 PM
sssuourabh commented 4 months ago

HI @jessearmandse Started by creating a new Project and selecting an Framework with same name as INSCameraSDK and INSCoreMedia.

i have created xcframework successfully for both INSCameraSDK and INSCoreMedia. Before creating xcframework for INSCoreMedia i have extracted the architecture x86_64 from library. `lipo -remove x86_64 " binary" '

Steps to create Xcframework for INSCameraSDK and INSCoreMediaSDK

wojciechzahradnikdeviniti commented 1 month ago

Hi any updates?