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

Issue building with Carthage on Xcode 12 #1

Closed
mickael-menu opened this issue Sep 24, 2020 · 9 comments · Fixed by readium/r2-testapp-swift#363
Closed

Issue building with Carthage on Xcode 12 #1

mickael-menu opened this issue Sep 24, 2020 · 9 comments · Fixed by readium/r2-testapp-swift#363

Comments

@mickael-menu
Copy link
Member

UPDATE: This has been fixed in Carthage, which can now build with Xcode 12 using:

carthage update --use-xcframeworks --platform ios

However, you need to make sure that you use the latest version of Readium, from the develop branch.


There's currently an issue with Xcode 12 when trying to build Carthage dependencies. Unfortunately, it's not something we can address in Readium.

If you don't want to stick with Xcode 11, a workaround until Carthage is fixed is to use the following script instead of the regular Carthage command:

#!/usr/bin/env bash

# carthage.sh
# Usage example: ./carthage.sh build --platform iOS

set -euo pipefail

xcconfig=$(mktemp /tmp/static.xcconfig.XXXXXX)
trap 'rm -f "$xcconfig"' INT TERM HUP EXIT

# For Xcode 12 make sure EXCLUDED_ARCHS is set to arm architectures otherwise
# the build will fail on lipo due to duplicate architectures.
echo 'EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64__XCODE_1200 = arm64 arm64e armv7 armv7s armv6 armv8' >> $xcconfig
echo 'EXCLUDED_ARCHS = $(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT)__XCODE_$(XCODE_VERSION_MAJOR))' >> $xcconfig

export XCODE_XCCONFIG_FILE="$xcconfig"
carthage "$@"

Add it to /usr/local/bin, chmod a+x carthage.sh and then you can use it like that: carthage.sh update --platform ios.

@mickael-menu mickael-menu pinned this issue Sep 24, 2020
@mickael-menu
Copy link
Member Author

This is fixed in Carthage 0.37, by using --use-xcframework

carthage update --use-xcframeworks --platform ios

@mickael-menu
Copy link
Member Author

mickael-menu commented Feb 5, 2021

Unfortunately it fails with:

warning: The iOS deployment target 'IPHONEOS_DEPLOYMENT_TARGET' is set to 8.0, but the range of supported deployment target versions is 9.0 to 14.3.99. (in target 'Fuzi' from project 'Fuzi')

It looks like it's just a matter of upgrading Fuzi to 3.1.3. Until then, the previous script still work.

@mickael-menu
Copy link
Member Author

I can build sucessfully with --use-xcframeworks and Xcode 12 with the changes introduced in this PR: readium/r2-testapp-swift#363

@mrifni
Copy link

mrifni commented Mar 15, 2021

I have successfully built the latest develop branch project with xcode version Version 12.4 (12D4e)

@mickael-menu
Copy link
Member Author

Xcode 12 chronicles, part II 😓

As stated in this issue, since Xcode 12 we must build XCFrameworks with Carthage.

Unfortunately, Carthage failed if we were still linking to regular frameworks in R2 modules (let's call it the 🍌 issue). The solution was to switch to XCFrameworks for every nested dependencies.

However, a XCFramework is resolved with a path relative to the local project, while a regular .framework is resolved implicitly in the whole workspace. This meant that when integrating R2 modules as git submodules, there were some potential conflicts between the XCFramework dependencies referenced in each R2 module, which were sourced from each module's Carthage/Build folder.

Somehow, Xcode 12 didn't mind until 12.5, which now complains with the following errors (only when integrating R2 as git submodules):

Screenshot 2021-04-28 at 12 37 57

The solution seems to revert back to linking to regular .frameworks in R2 modules to let Xcode resolve dependencies implicitly in the workspace. But, remember the 🍌 issue we had with Carthage. Turns out this was a bug in Carthage 0.37, which should be fixed in the upcoming Carthage 0.38.

Until then, a workaround is to make sure that the Carthage/Build/iOS folder exists before running the carthage update --use-xcframeworks --platform ios command.

@alexwhb
Copy link

alexwhb commented May 3, 2021

@mickael-menu That saved me hours of research as to what's going on. I was running into the same issue. Thanks for posting.

@mickael-menu
Copy link
Member Author

Carthage 0.38.0 is out:

Fixed building XCFrameworks with nested dependencies no longer requires a platform-specific Build directory (i.e. Carthage/Build/iOS) to exist (#3135).

@aferditamuriqi They also wrote something that might be interesting for R2LCPClient:

Prebuilt dependencies (for binary only frameworks and GitHub release assets) may use XCFrameworks, which are checked for compatibility and extracted into the Build folder (#3123). See the section below on compatibility information for framework authors.

@mickael-menu
Copy link
Member Author

I reverted back to using the xcframework paths in the Xcode project, instead of the framework ones, because:

See readium/r2-shared-swift#153

That means that using Readium as Git submodules with Carthage is not possible anymore with Xcode 12.5+. If you were doing this, you can either:

  • Use Swift Package Manager (recommended).
  • Generate the project using xcframework in your forks.

@alexwhb Let me know if you have an issue with this.

@alexwhb
Copy link

alexwhb commented Jul 13, 2021

@mickael-menu This is actually fantastic news. I'm using SwiftPM in most of my project other than a few modules including this one that, up till now, did not have a way to use them with SwiftPM. I'll give it a try soon. 👍 Thanks for letting me know.

@mickael-menu mickael-menu transferred this issue from readium/r2-testapp-swift Nov 4, 2021
rohitvishwakarma-sf pushed a commit to rohitvishwakarma-sf/swift-toolkit that referenced this issue Mar 23, 2023
…oading-time

Improved epub loading performance
SukritChat pushed a commit to Dek-D/swift-toolkit that referenced this issue Sep 22, 2023
Disable user select text in epub
This issue was closed.
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

Successfully merging a pull request may close this issue.

3 participants