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

Catalyst for ios platform ? #699

Closed
jhjulkun opened this issue Oct 23, 2019 · 30 comments · Fixed by #1158
Closed

Catalyst for ios platform ? #699

jhjulkun opened this issue Oct 23, 2019 · 30 comments · Fixed by #1158

Comments

@jhjulkun
Copy link

Hi
Has anyone tried building an ios project using 'Catalyst' for macOS Catalina ?

If I try enabling that build, I get:

CDVURLProtocol.m:20:9: AssetsLibrary is deprecated and is not available when building for Mac Catalyst. Consider migrating to Photos instead, or use #if !TARGET_OS_MACCATALYST to conditionally import this framework, first importing TargetConditionals.h if necessary.

Seems like the AssetsLibrary has been deprecated, and has been fixed in ionic, are you guys planning on removing it too ?
ionic-team/capacitor#1825

Going forward, should Catalyst be used or the 'osx' platform ?

Thanks

@jcesarmobile jcesarmobile transferred this issue from apache/cordova Oct 23, 2019
@jcesarmobile
Copy link
Member

moved to cordova-ios repo

@dpogue
Copy link
Member

dpogue commented Oct 23, 2019

Going forward, should Catalyst be used or the 'osx' platform ?

Once it works, I think we'd want to encourage using Catalyst for macOS to avoid needing to maintain a similar-but-separate cordova-osx platform.

See also #551.

We'd definitely like to address this, but it's not clear if that code is actually being used (it probably is, by someone, somewhere) and whether removing it (like Ionic did) is the right step.

@jcesarmobile
Copy link
Member

It was removed in Capacitor, was not really being used there.

Since it's in CDVURLProtocol.m and that won't work on WKWebView, I think it's safe to remove once we remove UIWebView.

@brodycj
Copy link
Contributor

brodycj commented Dec 16, 2019

Unfortunately the maintainers are overloaded due to lack of resources, see apache/cordova#163.

@erisu
Copy link
Member

erisu commented Feb 14, 2020

CDVURLProtocol was removed in #783 and will be in next major release.

@jcesarmobile
Copy link
Member

Have you tried to run the app in Catalyst after that change?
If so, maybe we should enable it by default on the project template or add a way of easily adding it

@dpogue
Copy link
Member

dpogue commented Feb 14, 2020

Catalyst is only supported in Xcode 11 on macOS Catalina, so I'm not sure we'd want to enable it by default.

@erisu
Copy link
Member

erisu commented Feb 14, 2020

From master, I believe it was decided to only support Xcode 11+ as all apps starting April 2020 requires to be built with Xcode 11.

I am not sure what we say about macOS requirements.

@jcesarmobile
Copy link
Member

What happens if you add macOS target and then you open the project on Mojave? I updated both of my computers, so I can’t test anymore.
If not by default, then maybe a command that adds catalyst instead of cordova-osx

@dpogue
Copy link
Member

dpogue commented Jun 17, 2020

Had a bit of time to play with the HelloCordova app in Catalyst tonight, and it doesn't work out of the box but it should be easy to make it compatible.

Namely, we currently use a bash script to copy the config.xml and www folders into the root of the .app bundle.
On Catalyst, those need to be copied into a subfolder instead of the root, otherwise CodeSign fails.

If we instead moved those to the Copy Bundle Resources step of the Xcode project, then it works.

I don't know off-hand the historical reasons for not relying on Copy Bundle Resources, so there's probably some investigation to do there to see if this is a safe change to make.

@brodycj
Copy link
Contributor

brodycj commented Jun 17, 2020

Sounds like we would need breaking changes to use the Copy Bundle resources and drop the AssetsLibrary, or am I mistaken on this?

@dpogue
Copy link
Member

dpogue commented Jun 17, 2020

Random links/notes for whoever decides to investigate whether this is feasible:

@dpogue
Copy link
Member

dpogue commented Jun 17, 2020

Sounds like we would need breaking changes to use the Copy Bundle resources and drop the AssetsLibrary, or am I mistaken on this?

@brodybits The ALAssetLibrary stuff (and all of CDVURLProtocol was dropped in 6.0)

@dpogue dpogue added this to the 7.0.0 milestone Jun 22, 2020
@jhjulkun
Copy link
Author

jhjulkun commented Jul 25, 2020

So just tested Catalyst for on a new 'hello' cordova project, using ios@6.1.0
Project builds (and runs on iOS), but after enabling Catalyst I get this codesign error:
unsealed contents present in the bundle root
Command CodeSign failed with a nonzero exit code

Has someone gotten a Catalyst ios build to work ?
Update: just saw the post from dpogue above, unfortunately I can't get around the codesign issue, can you share some more detail where you copied the config.xml and www directory ? (not familiar with codesign)

@BRadHoc
Copy link

BRadHoc commented Aug 2, 2020

So just tested Catalyst for on a new 'hello' cordova project, using ios@6.1.0
Project builds (and runs on iOS), but after enabling Catalyst I get this codesign error:
unsealed contents present in the bundle root
Command CodeSign failed with a nonzero exit code

Has someone gotten a Catalyst ios build to work ?
Update: just saw the post from dpogue above, unfortunately I can't get around the codesign issue, can you share some more detail where you copied the config.xml and www directory ? (not familiar with codesign)

CodeSign error means your app isn't signed properly, you need to select a development team in the target root node.

The build fails for another reason

@kisonay
Copy link

kisonay commented Nov 17, 2020

So just tested Catalyst for on a new 'hello' cordova project, using ios@6.1.0
Project builds (and runs on iOS), but after enabling Catalyst I get this codesign error:
unsealed contents present in the bundle root
Command CodeSign failed with a nonzero exit code
Has someone gotten a Catalyst ios build to work ?
Update: just saw the post from dpogue above, unfortunately I can't get around the codesign issue, can you share some more detail where you copied the config.xml and www directory ? (not familiar with codesign)

CodeSign error means your app isn't signed properly, you need to select a development team in the target root node.

The build fails for another reason

I unfortunately have this same error. Cannot find a way around it. The app is set to automatically sign and a team is selected from both dropdowns.

@dpogue
Copy link
Member

dpogue commented Nov 17, 2020

Yes, currently Cordova-iOS cannot generate successful builds with Catalyst. Catalyst is not supported.

@pedroadame
Copy link

Is this still on sight for cordova-ios 7.0.0? @dpogue

@dpogue
Copy link
Member

dpogue commented Feb 3, 2021

It's on our list of things we hope to do for v7.0.0, but there's nobody currently looking into it and no timeline

@jhjulkun
Copy link
Author

jhjulkun commented Feb 3, 2021

if you guys can fix it that would be great, with the M1 being able to run "mobile" type of apps on a laptop would be awesome!
(and at the same time, deprecate osx)

@jcesarmobile
Copy link
Member

That’s a separate thing, M1 is supposed to run iOS/iPadOS apps, catalyst creates macOS apps and works on any Mac.

@Leandropintogit
Copy link

So just tested Catalyst for on a new 'hello' cordova project, using ios@6.1.0
Project builds (and runs on iOS), but after enabling Catalyst I get this codesign error:
unsealed contents present in the bundle root
Command CodeSign failed with a nonzero exit code
Has someone gotten a Catalyst ios build to work ?
Update: just saw the post from dpogue above, unfortunately I can't get around the codesign issue, can you share some more detail where you copied the config.xml and www directory ? (not familiar with codesign)

CodeSign error means your app isn't signed properly, you need to select a development team in the target root node.
The build fails for another reason

I unfortunately have this same error. Cannot find a way around it. The app is set to automatically sign and a team is selected from both dropdowns.

Hy guys

With just a few changes, it is possible to generate a simple cordova app supporting catalyst without changing ios behavior
In the script copy-www-build-step.sh, change the variable DST_DIR based on build platform

DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME"
if [[ "$PLATFORM" == "macosx" ]]; then
  //In case build ios directories exists
  rm -rf "$DST_DIR_WWW"
  rm -f  "$DST_DIR/config.xml"

  DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/Contents/Resources"
fi

@BRadHoc
Copy link

BRadHoc commented Jun 13, 2021

So just tested Catalyst for on a new 'hello' cordova project, using ios@6.1.0
Project builds (and runs on iOS), but after enabling Catalyst I get this codesign error:
unsealed contents present in the bundle root
Command CodeSign failed with a nonzero exit code
Has someone gotten a Catalyst ios build to work ?
Update: just saw the post from dpogue above, unfortunately I can't get around the codesign issue, can you share some more detail where you copied the config.xml and www directory ? (not familiar with codesign)

CodeSign error means your app isn't signed properly, you need to select a development team in the target root node.
The build fails for another reason

I unfortunately have this same error. Cannot find a way around it. The app is set to automatically sign and a team is selected from both dropdowns.

Hy guys

With just a few changes, it is possible to generate a simple cordova app supporting catalyst without changing ios behavior
In the script copy-www-build-step.sh, change the variable DST_DIR based on build platform

DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME"
if [[ "$PLATFORM" == "macosx" ]]; then
  //In case build ios directories exists
  rm -rf "$DST_DIR_WWW"
  rm -f  "$DST_DIR/config.xml"

  DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/Contents/Resources"
fi

Do you know how it's possible to stop this from happening:

/Project/platforms/ios/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector(FIRAnalyticsConnector_c162bpf6emcd173ef13757bsd7ebe6f7.o), building for Mac Catalyst, but linking in object file built for iOS Simulator, file '/Project/platforms/ios/Pods/FirebaseAnalytics/Frameworks/FIRAnalyticsConnector.framework/FIRAnalyticsConnector' for architecture x86_64

@Leandropintogit
Copy link

FirebaseAnalytics does not suport catalyst yet, but other frameworks do. I built a catalyst app with firebasemessaging successfully. Try update pods with latest version.

@pulpgrinder
Copy link

pulpgrinder commented Sep 10, 2021

The suggestion from @Leandropintogit didn't quite work for me (iMac M1, XCode 12.5.1)...

While it enabled me to build the "My Mac (Designed for iPad)" configuration, it broke the "My Mac" and "My Mac (Rosetta) builds.

After diffing the script outputs from the three available Mac configurations and looking for different environment variables, I found an EFFECTIVE_PLATFORM_NAME environment variable. Checking whether this is set to "-maccatalyst" seems to do the trick. At least it builds and runs in all three configurations. No idea if this is the official Apple way of distinguishing or not, but it seems promising. Relevant lines from the works-for-me copy-www-build-step.sh file:

SRC_DIR="www"
DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME"
DST_DIR_WWW="$DST_DIR/www"
if [[ "$EFFECTIVE_PLATFORM_NAME" == "-maccatalyst" ]]; then
  rm -rf "$DST_DIR_WWW"
  rm -f  "$DST_DIR/config.xml"
  DST_DIR="$BUILT_PRODUCTS_DIR/$FULL_PRODUCT_NAME/Contents/Resources"
  DST_DIR_WWW="$DST_DIR/www"
fi

COPY_HIDDEN=

(etc.)

Edit: this change does not appear to interfere with building for actual iOS. Seems to work for me on both the simulator and a physical phone.

Edit 2: reset DST_DIR_WWW based on new DST_DIR.

@pulpgrinder
Copy link

My understanding of the three configurations (which may not be fully accurate -- I've just started playing with this):
"My Mac" -- builds a native Mac app which can run only on M1 Macs, but is otherwise functionally identical to the iPad app.
"My Mac (Rosetta)" -- builds a Rosetta-compatible Mac app that will run on M1 under Rosetta emulation. I think this may also run on Intel Macs. If not, maybe I'm not understanding what the use case is for this.
"My Mac (Designed for iPad)" -- builds a Catalyst-enabled Mac app which can run on any Mac that supports Catalyst apps. I believe the use case for this is that you can use the extra Catalyst goodies (normal Mac menu stuff and so on).

Corrections welcome.

@NiklasMerz
Copy link
Member

@pulpgrinder I just a did a quick test on a M1 Mac and your code seems fine. It works for all Mac configurations for me.

As this is a minimal change I would go for this. Would you like to create a pull request for this or can we take the code from the comment?

Thank you for your comments and testing. This helped me to get it working.

@dpogue
Copy link
Member

dpogue commented Oct 7, 2021

Long-term I'd like to see us move to using Xcode's "Copy Resources" step instead of a bash script, but for now it makes sense to fix the bash script if it's an easy change 👍

@NiklasMerz
Copy link
Member

Good point. I tested the "Copy files" build setting in Xcode for a bit and it seems to work fine.

I am not sure if the reasons for this script in the past are still strong enough to not change it.

@pulpgrinder
Copy link

By all means use the code right from the comment, if that's convenient for you. It's such a small change that it hardly seems worth a PR. :-)

erisu pushed a commit to erisu/cordova-ios that referenced this issue Oct 28, 2021
dpogue pushed a commit that referenced this issue Oct 31, 2021
* (refactor): move copy-www-build-step script to Xcode commands

See #699

* select files to copy

* copy config.xml from staging

* feat: copy staging resources

- Combined "Copy www" & "Copy config.xml" into "Copy Staging Resources"
- Copy content from "Staging" group into Resources

Co-authored-by: Erisu <erisu@apache.org>
gazben pushed a commit to apicore-engineering/cordova-ios that referenced this issue Aug 26, 2022
…#1158)

* (refactor): move copy-www-build-step script to Xcode commands

See apache#699

* select files to copy

* copy config.xml from staging

* feat: copy staging resources

- Combined "Copy www" & "Copy config.xml" into "Copy Staging Resources"
- Copy content from "Staging" group into Resources

Co-authored-by: Erisu <erisu@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet