feuvan / opencore-amr-iOS

iOS port of opencore-amr, with prebuilt XCFrameworks available.
Apache License 2.0
254 stars 69 forks source link

iOS Simulator on Apple Silicon M1 #11

Open DmitryDNKK opened 1 year ago

DmitryDNKK commented 1 year ago

There is no build for iOS simulators running on Apple's new arm processors.

EchoLunar commented 2 months ago

I’m encountering the same issue. I reviewed the iosbuild.sh script for libwebp, and it also doesn’t include separate builds for Apple Silicon simulators.

From my understanding, it should be similar to Carthage, with one framework for iPhoneOS arm64 and another for x86_64 & arm64 for the simulator, then compiled into an XCFramework.

I’m not very experienced with this, so I hope someone can handle it. As a temporary solution, I’m using x86_64 and arm64 .a files. Xcode shows many yellow warnings, but it doesn’t affect functionality.

feuvan commented 1 month ago

@EchoLunar I've updated the build script to output XCFramework. Please give a try.

EchoLunar commented 1 month ago

I’m really surprised and impressed that you managed to solve my issue so quickly! I’ve successfully compiled and run it on both the M2 simulator and the iPhone device. Thank you so much for your help!

feuvan commented 1 month ago

glad to hear that.

EchoLunar commented 1 month ago

Hey~ I apologize. I did manage to compile successfully on both the simulator and the real device, but when I tried to upload the package, Apple rejected it. It was then that I realized the xcframework contains a .a file, while typically, an xcframework should contain something like what’s shown in the picture.

image Asset validation failed (90432) Unexpected file found in Frameworks. The “XXX.app/Frameworks/libopencore-amrnb.a” file is in the Frameworks directory, but the Swift runtime libraries are the only files permitted in that directory.

feuvan commented 1 month ago

@EchoLunar try the prebuilt xcframeworks. They are built by github actions with xcodebuild.

EchoLunar commented 1 month ago

I have tried, but the result remains the same. When I package and submit it to TestFlight, I receive the following error: “The X.app/Frameworks/libopencore-amrnb-iphoneos.a file is in the Frameworks directory, but the Swift runtime libraries are the only files permitted in that directory.”

I noticed that the xcframework.sh script for libwebp does something similar, where it creates a fat_a and then packages it into an xcframework, I attempted to package the libwebp xcframework into the project for submission, but it still failed to pass validation.

I checked the .app file, and it seems that all other libraries are packaged as frameworks, but libopencore-amrnb remains as a .a file, which seems to be disallowed.

EchoLunar commented 1 month ago

I have resolved this issue.

I created an Objective-C Framework using Xcode and included the header and .a files (compiled twice using different .a files for each compile).

I used ‘xcodebuild archive’ to compile the two Frameworks, and then combined them into an xcframework using ‘xcodebuild -create-xcframework’

I tested it on both real devices and simulators, and everything works fine. It has also been successfully uploaded to TestFlight.

However, I completed these steps manually. If you are interested, you might consider further refining this project.

feuvan commented 1 month ago

I have resolved this issue.

I created an Objective-C Framework using Xcode and included the header and .a files (compiled twice using different .a files for each compile).

I used ‘xcodebuild archive’ to compile the two Frameworks, and then combined them into an xcframework using ‘xcodebuild -create-xcframework’

I tested it on both real devices and simulators, and everything works fine. It has also been successfully uploaded to TestFlight.

However, I completed these steps manually. If you are interested, you might consider further refining this project.

Per Apple XCFramework documentation,it should be valid to pass .a with -lib to xcodebuild to create XCFrameworks. I will check this later or maybe just change the way creating XFramework,doing it by combine frameworks.