Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with uploading into App Store Connect (flutter) #2113

Open
TDMNS opened this issue Sep 2, 2022 · 17 comments
Open

Problem with uploading into App Store Connect (flutter) #2113

TDMNS opened this issue Sep 2, 2022 · 17 comments

Comments

@TDMNS
Copy link

TDMNS commented Sep 2, 2022

Hi all. I ran into this problem while uploading an app on App Store Connect:
Introductory: my application uses the tdlib library (for telegram), written on a cross-platform (flutter), made and launched on Android, launched on iOS, but cannot be loaded into TestFlight. An error occurs:
Dear developer,
We identified one or more issues with a recent delivery for your app, “someName” 0.0.22 (30). Please correct the following issues, then upload again.
ITMS-90429: Invalid Swift Support - The files libswiftDarwin.dylib libswiftMetal.dylib libswiftCoreAudio.dylib libswiftQuartzCore.dylib libswiftos.dylib libswiftCoreMedia.dylib, libswiftCore.dylib, libswiftFoundation.dylib, libswiftCoreImage.dylib aren't at the expected location /Payload/Runner.app/Frameworks. Move the file to the expected location, rebuild your app using the current public (GM) version of Xcode, and resubmit it.
Our task is to upload the application to Testflight.
Tried to fix:
tried to disable the check when loading MP in the AppStore.
Hypotheses - Problem in validating .Swift files in Flutter that shouldn't be validated.
How to get rid of this problem is unknown. When we uncheck Strip Swift Symbols, the validation is still carried out in the Flutter libraries.
We plan to test the possibility of loading another application in Testflight with the tdlib library.
Rebuild library (built on intel in latest xcode, tried to boot from intel and M1)
Tell me, can someone come across such a problem?

@TDMNS
Copy link
Author

TDMNS commented Sep 2, 2022

Tried when loading 2 applications. I came to the conclusion that this is a library problem.

@levlam
Copy link
Contributor

levlam commented Sep 2, 2022

Do you include TDLib as Universal XCFramework and build it as described in https://github.com/tdlib/td/tree/master/example/ios?

@TDMNS
Copy link
Author

TDMNS commented Sep 3, 2022

Yes! I'm building Xcframwork and everything works fine in Xcode and Flutter, but it doesn't load in the App Store.

@levlam
Copy link
Contributor

levlam commented Sep 3, 2022

Issues with uploading apps to App store were common previously, but all of them were solved by using XCFramework instead of plain dynamic libraries. https://developer.apple.com/library/archive/technotes/tn2435/_index.html#//apple_ref/doc/uid/DTS40017543-CH1-TROUBLESHOOTING-BUNDLE_ERRORS mentions exactly this reason as the cause of "Invalid Swift Support".

@TDMNS
Copy link
Author

TDMNS commented Sep 6, 2022

We use XCFramework... And get this error.

@Anfet
Copy link

Anfet commented Sep 6, 2022

Same issue. Android works fine, IOS app connect rejects the library.
Any workaround? Or maybe some updated script for assembling?

@Kylmakalle
Copy link
Contributor

Kylmakalle commented Sep 10, 2022

The issue

I was able to contact with issue author and managed to get it works and publish their app to AppStore Connect.

So, levlam mentioned exact Apple docs that describes the issue.

Dynamic libraries outside of a framework bundle, which typically have the file extension .dylib, are not supported on iOS...

Current example/ios provides a build of .dylibs packed into .xcframework for compatibility with arm64 macs, since it's impossible to have a fat binary (more on that here #1620 (comment))

Well, it will work for any local or debug iOS builds, ad hoc distribution and etc., but will not work for AppStore distribution.

Is it a tdlib issue then...?)

Solutions so far

Wrap .dylib in a .framework

That's mentioned in Apple docs.

  1. So you need to create a wrapper with some "fake" .framework. This StackOverflow answer may help a lot. https://stackoverflow.com/a/62962641

  2. You will also need to redefine the -id with install_name_tool of a tdlib binary since dylib is now wrapped. And properly setup your Runpath Search paths. This StackOverflow answer may help.
    https://stackoverflow.com/questions/9798623/how-to-properly-set-run-paths-search-paths-and-install-names

  3. [Flutter] As for me, I was unable to properly setup tdlib's @rpath in flutter, so it required me to provide a full path to binary like @executable_path/Frameworks/libtdjson_wrapper.framework/libtdjson

P.S. You can combine all of these frameworks in one .xcframework if needed. Take a look at manuals in the internet. Or this script that i'm using for my pre-built binaries.

P.P.S. Be aware of DSYMs. I've not tested how it will work with this fake .framework.

Use static library

After you've build tdlib, you will find both dynamic and static libs at example/ios/build/install-<PLATFORM>/lib. These libs are eligible to be linked and embedded in iOS app for AppStore.

Here I will advertise some pre-built binaries by me at Swiftgram/TDLibFramework.
And here's how you may integrate it to your Flutter/Cocoapods project.

@Kylmakalle
Copy link
Contributor

Kylmakalle commented Sep 10, 2022

I will let @levlam decide on the future of this issue, here's our options

  1. Update the script so it will wrap .dylib in .framework. (Remember, .dylib is still eligible for local builds & ad-hoc distribution and fully eligible for macOS AppStore builds)
  2. Switch to static libraries in this example
  3. Take a note in a readme like Apple does (IMHO, it's really lacks of exact steps and information. We may also link this discussion.)

If your project will be submitted to the App Store you will need to package the ***.dylib into a Framework in order to avoid an iTunes Connect error. To package the framework properly, follow these steps.

@TDMNS TDMNS closed this as completed Sep 13, 2022
@levlam
Copy link
Contributor

levlam commented Oct 3, 2022

I will keep this issue open until TDLib build examples are updated, or Apple's policy is changed.

From the proposed options, I think that wrapping .dylib in .framework would be the best approach.

@levlam levlam reopened this Oct 3, 2022
@Wolfaks
Copy link

Wolfaks commented Dec 6, 2022

Hello. Has there been a solution? The methods described above are too complicated to understand.
Please write a more detailed instruction with all the commands that need to be executed with .dylib files in order for the application to be allowed on the App Store. Thanks

@Wolfaks
Copy link

Wolfaks commented Dec 8, 2022

@Kylmakalle These points are very unclear. Are there more detailed instructions? Thanks.

You will also need to redefine the -id with install_name_tool of a tdlib binary since dylib is now wrapped. And properly setup your Runpath Search paths. This StackOverflow answer may help.
https://stackoverflow.com/questions/9798623/how-to-properly-set-run-paths-search-paths-and-install-names

[Flutter] As for me, I was unable to properly setup tdlib's @rpath in flutter, so it required me to provide a full path to binary like @executable_path/Frameworks/libtdjson_wrapper.framework/libtdjson

@Kylmakalle
Copy link
Contributor

@Wolfaks I’m unable to post detailed instructions… yet. Referenced Stackoverflow threads have enough info to kick off with tdlib in AppStore.

@Wolfaks
Copy link

Wolfaks commented Dec 10, 2022

I was finally able to successfully submit the app to the App Store.
What I've done:

  1. Used this instruction to build the library:
    https://github.com/tdlib/td/tree/master/example/ios

  2. Fulfilled the first point from instruction @Kylmakalle:
    So you need to create a wrapper with some "fake" .framework. This StackOverflow answer may help a lot. https://stackoverflow.com/a/62962641
    Command: (for each libtdjson.dylib files from the required architecture folders)
    lipo -create libtdjson.dylib -output libtdjson

Then deleted unnecessary file libtdjson.dylib, moved files libtdjson to folders /libtdjson.framework
and ran the command for each new created libtdjson file: (Always first you need to go to the desired folder in the terminal, with the right architecture)
install_name_tool -change @rpath/libtdjson.dylib @rpath/libtdjson.framework/libtdjson libtdjson

  1. Then for each of the libtdjson files, I ran the command to change the path: (Always first you need to go to the desired folder in the terminal, with the right architecture)
    install_name_tool -id "@rpath/libtdjson.framework/libtdjson" libtdjson

Then I checked that the paths changed correctly:
otool -L libtdjson
Screenshot 2022-12-10 at 13 12 58

  1. Added file libtdjson to the folder with file Info.plist for each architecture. (you need to replace the id with your own):
    `
CFBundleExecutable libtdjson CFBundleIdentifier YOUR_BUNDLE_ID.libtdjson MinimumOSVersion 11.0 `
  1. Move entire libtdjson.xcframework folder to ios project and add library to xcode project:

Screenshot 2022-12-10 at 13 11 41

Screenshot 2022-12-10 at 13 13 31

Done! Everything works on the iPhone and in the simulator, and my application was also missed in the app store. Thanks to all! 🎉

@slender2332
Copy link

slender2332 commented Feb 10, 2023

I was finally able to successfully submit the app to the App Store. What I've done:

1. Used this instruction to build the library:
   https://github.com/tdlib/td/tree/master/example/ios

2. Fulfilled the first point from instruction @Kylmakalle:
   `So you need to create a wrapper with some "fake" .framework. This StackOverflow answer may help a lot. https://stackoverflow.com/a/62962641`
   Command: (for each libtdjson.dylib files from the required architecture folders)
   `lipo -create libtdjson.dylib -output libtdjson`

Then deleted unnecessary file libtdjson.dylib, moved files libtdjson to folders /libtdjson.framework and ran the command for each new created libtdjson file: (Always first you need to go to the desired folder in the terminal, with the right architecture) install_name_tool -change @rpath/libtdjson.dylib @rpath/libtdjson.framework/libtdjson libtdjson

3. Then for each of the libtdjson files, I ran the command to change the path: (Always first you need to go to the desired folder in the terminal, with the right architecture)
   `install_name_tool -id "@rpath/libtdjson.framework/libtdjson" libtdjson`

Then I checked that the paths changed correctly: otool -L libtdjson Screenshot 2022-12-10 at 13 12 58

4. Added file libtdjson to the folder with file Info.plist for each architecture. (you need to replace the id with your own):
   `

CFBundleExecutable libtdjson CFBundleIdentifier YOUR_BUNDLE_ID.libtdjson MinimumOSVersion 11.0 `

5. Move entire libtdjson.xcframework folder to ios project and add library to xcode project:
Screenshot 2022-12-10 at 13 11 41 Screenshot 2022-12-10 at 13 13 31

Done! Everything works on the iPhone and in the simulator, and my application was also missed in the app store. Thanks to all! 🎉

Hello , I followed the steps. it works on simulator but not in real iphone . whats possible gone wrong ?

@wassmtg
Copy link

wassmtg commented Mar 14, 2023

Hey guys...
Who can tell me how to use tdlib with flutter ?
All the existing plugins didn't work.

@ivk1800
Copy link

ivk1800 commented May 16, 2023

Hey guys... Who can tell me how to use tdlib with flutter ? All the existing plugins didn't work.

https://github.com/ivk1800/tdlib-dart

@hantrungkien
Copy link

@Wolfaks could you please help me to provide a example repository? Many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants