For a client I've developed an iOS + Android app using Cordova (PhoneGap) for the user interface. Now, as an update to this app, I'm am attempting to add a game that was written in Haxe. Originally the game was written for the Flash target, but I've updated it to work with the C++ targets for Android and iOS.
On Android it was easy to integrate this with the Cordova app using activities (the Haxe part runs as a separate activity), but I am having some trouble achieving a similar result on iOS.
So far I have tried to include all hxcpp generated code in my project (in the same way that NME sets up the XCode project when you do "nme build ios"), and I'm calling hxRunLibrary() from my code when I want the game to run.
The problem is that hxRunLibrary() seems to want to create its own UIApplication instance, which fails with the following error, since my main app is already running an instance:
*** Assertion failure in void UIApplicationInstantiateSingleton(Class)(), /SourceCache/UIKit_Sim/UIKit-2380.17/UIApplication.m:2037
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'There can only be one UIApplication instance.'
I think it might have something to do with SDL, which Haxe uses for graphics. From what I understand SDL needs to run from the main function of the app, which created a conflict with Cocoa that also needs to run from the main function.
Is there any easy way around this? I've looked in the hxcpp sources, but been unable to find the UIApplication related code, or any entry code for SDL.
Perhaps someone could point me in the right direction. Thanks!
Well ,I have googled some information about Haxe . what i understood is that The Haxe will prouduce a completed application for you .that mean it include the main Function . That's why the error is happend .
And you can simulate the problem by invoke UIApplicationMain Function twice .
In my opinion , you have to remove the code about UIApplicationMain from the souce code file produced by Haxe.
cordova has the ability to be integrated as part of a bigger application
ran into the same issue.
http://devgirl.org/2012/11/15/embed-cordovaphonegap-in-your-native-ios-app/
this article will help
you dont actually create a new project instead you embed it in a webview via the ios webview and cordova acts a subview.
Related
I am developing an app in Flutter.
I am using the geolocator package and when I build my iOS app I get a warning.
The app launches successfully, but I am unable to get GPS information.
I did some research and it looks like the warning is displayed when using xcode14 and iOS16.
It seems that the best way to handle this is to run the app in parallel instead of running it in the main thread.
What I found is Swift code, so I would like to be able to run it in Objective-C as well.
WARNING message
This method can cause UI unresponsiveness if invoked on the main thread. Instead, consider waiting for the `-locationManagerDidChangeAuthorization:` callback and checking `authorizationStatus` first.
development environment
iOS16.2
Xcode14
geolocator7.7.1
iPhone SE2(Actual Device)
This warning did not appear when the emulator was used. The emulator is also able to acquire GPS information. All emulators are running in Android Studio.
It seems that Xcode14 is the problem.
Can you make the following code Objective-C?
It would be better to enclose it in DispatchQueue.global().async { }.
DispatchQueue.global().async {
//Process with warnings
}
reference
Main thread warning with CLLocationManager.locationServicesEnabled()
Thank you.
I am getting the following error messages when our production iOS app initializes:
[Crashlytics] Version 3.8.4 (121)
[Crashlytics] Running on iOS Simulator (iPhone), 10.3.0 (16E195)
[Crashlytics:Crash] Reporting is disabled
[Crashlytics] Crash reporting could not be initialized
[Answers] Initialized
[Fabric] Initialized with kit versions: {
"com.twitter.answers.ios" = "1.3.4";
"com.twitter.crashlytics.ios" = "3.8.4";
"io.fabric.sdk.ios" = "1.6.11";
}
Every subsequent call to log an event gets the following error:
[Crashlytics:Crash] WARNING: CLSLog has been used before (or concurrently with)
Crashlytics initialization and cannot be recorded. The message was: ...
The non-production versions of the app work fine running the exact same code but with different bundleIDs. Normally when the app initializes for the first time, then I see the app populate in the Fabric dashboard, but in this case the app is not showing up.
We have an Android and an iOS version of the app, and they both use the same bundleID, so I am wondering if there is a conflict because of that? I see the Android version of the app in the dashboard, and it seems to be working properly. This is an app that originally was a Xamarin app that compiled to both platforms, neither of which incorporated Fabric/Crashlytics. We have now written native apps on each platform, and both are using Fabric/Crashlytics.
Since this is a pre-existing app in both stores, we do not have the option of changing either app’s bundleID.
Make sure you initialize Crashlytics with Fabric before calling any Crashlytics methods:
Fabric.with([Crashlytics.self])
One step I routinely miss is to make sure you've added the build phase on your target:
"${PODS_ROOT}/Fabric/run" ${FABRIC_API_KEY} ${FABRIC_BUILD_SECRET}
and either replace ${FABRIC_API_KEY} and ${FABRIC_BUILD_SECRET} with your key and secret or add custom build settings for each.
There are apparently cases where Crashlytics does not auto-activate new apps so that they show up under your list of apps, even though everything is coded correctly and data is going to their servers. In this case, send an email to Crashlytics support (support#fabric.io) that contains a copy of the info.plist entries for the app in question and they will activate it for you. I have had to do this several times, especially with app extensions.
When I finally traced it down in my situation, the error was entirely correct, but not obvious.
I saw these errors in various testing targets where the code we tested was using a custom logging wrapper which called CLSNSLogv(), but the test didn't actually go through the AppDelegate and therefore did NOT initialize Crashlytics. After trying a few things I was convinced that it worked when executed as an app, but in our configuration it was not working under the unit test configuration.
I'll likely alter our custom wrapper to bypass CLSNSLogv() during testing anyway. The biggest benefit of using that is when crashes occur on devices, so we won't be missing anything.
We are developing app for iOS and Android and we are using Ti.Gelocation to getCurrentPosition and then set the Region of the MapView of ti.map module.
The app is already on marketplace and downloaded, so we are developing an important upgrade with this new feature. We dont't have problem with Android platform, but with iOS version of the app we get a several error invoking Ti.Geolocation module
The error on iOS 9.x on iPad and iPhone (we have no test on iPod) is:
-[__NSCFString containsObject:] unrecognized selector sent to instance 0x1463d500 at GeoView.js (line xxxx)
This error happens with the project with it.vocami.vocamiapp app-id, in the test project (ap-id=it.vocami.vocamitest) that we use for research and test of new features, no error happens and all run good. When we add at every level of our code (in the first row too), for example, Ti.Geolocation.locationServiceEnabled, in the main vocamiapp project, we get the error.
We have tried all we could think but at the end, if we change the app-id, the code runs otherwise we get the error. We cannot change the app-id because we need to update our published app.
We are developing with AppceleratorStudio version 4.5.0.021602170281 and Ti SDK ver 5.2.0GA on Mac OS X 10.10.5.
I just recently was "hit" by the fact that when I made my app ready for Google Play I use a specific key/user to sign it with. That behaves differently from just running it locally on the phone.
I had to make sure that I had registered two certificates with Google's API in the developer console. It didn't give me exactly the message that you show - but wouldn't show the map with a location. And the way I read the location prior to showing it on the map led me in the wrong direction looking at permissions on Android first :-)
/John
The Xamarin debugging documentation indicates:
Use Xamarin Studio's native debugging support for debugging C# and
other managed languages code and use LLDB when you need to debug C,
C++ or Objective C codethat you might be linking with your Xamarin.iOS
project.
However I cannot find any documentation on how to use LLDB to debug a Xamarin app. If I run my app in the iPhone Simulator and try to attach to it using LLDB I get the following error:
(lldb) attach --pid 37993
Process 37993 exited with status = -1 (0xffffffff) lost connection
error: attach failed: lost connection
Attaching using Xcode doesn't work either. I tried different variations of attach but none of them worked.
Can someone point me in the correct direction on how to debug Xamarin apps with LLDB? Moreover is this something I could do on the device and not just in the simulator? I didn't find any information on how to use LLDB to attach to a process on a device.
Update
It looks like the debugserver process is crashing whenever I use lldb to connect to my binary. Here is a link to the crash report for debugserver:
https://www.dropbox.com/s/9lizhl2quj9n0cc/debugserver_2015-07-07-131423_gauss.crash?dl=0
Update 2
When I run dtruss on the app it prints the system calls till it encounters
dtrace: error on enabled probe ID 2475 (ID 194: syscall::ptrace:return): invalid user access in action #5 at DIF offset 0
which happens when something calls ptrace(PT_DENY_ATTACH, 0, 0, 0); Why is PT_DENY_ATTACH called?
Update 3
I traced the ptrace system call to this function: mono_assembly_init_with_opt which happens very early in the life of the program. All that function does is call ptrace, so if I just return early from that function, I can debug with lldb.
Basically, I can do:
(lldb) process attach --name AppName --waitfor
# when the process starts
(lldb) b mono_assembly_init_with_opt
(lldb) c
# when the thread breaks
(lldb) thread return 0
(lldb) c
and now I can happily debug with lldb.
But, I shouldn't have to do this. Is there something wrong with my project config (I can debug simpler apps with lldb) or is Xamarin being evil?
Codesigned apps on Mac OS X can only be debugged if they have a particular attribute set in their app plist. You want something that looks like:
<key>SecTaskAccess</key>
<array>
<string>allowed</string>
<string>debug</string>
</array>
You can look at the man page for taskgated for a somewhat terse description of this process.
Usually for Xcode projects, this attribute gets consed up and inserted into your debug builds by Xcode, so you don't need to do anything to get this to happen.
I don't know how Xamarin works, but it is possible that it is not setting this attribute. On older OS X systems, root can debug anything, so you could try sudo -s and then debugging from there. But starting with Yosemite, the request not to be debugged is being more broadly honored...
Have you tried using the pid from the Activity Monitor? Just type your app name into the search box in Activity Monitor when running it in Debug.
If it still doesnt work can you try just creating a new project and attaching to that just to rule out any project config.
This happens to be a limitation imposed by Xamarin in the trial version. After upgrading to a paid license, this is no longer an issue. Even though Xamarin's website says:
When you begin a Xamarin Trial, you get access to the full Xamarin
Business feature set for 30 days.
It's clearly not the full feature set since they explicitly disable attaching lldb to the app if you are using a native library. I'm not sure the reason for doing so, maybe someone from Xamarin can comment on it.
Explanation
Thanks to Jim Ingham for pointing me in the right direction. The way Xamarin events debuggers from attaching to the app is by calling ptrace with PT_DENY_ATTACH. This system call enables the process to deny requests for debugging. (Detailed Explanation).
Moreover rather than calling the ptrace function directly, Xamarin tries to hide the call by using the syscall method (link).
Workaround
If you really need to debug your app and are still using the trial version, here is a workaround. The ptrace system call is made in the function mono_assembly_init_with_opt which happens very early in the life of the program. That function doesn't do anything else and can be skipped. Since the function is called right in the beginning of the process, we need to attach lldb before the function is called.
The steps are as follows:
Start lldb and wait for the app to start.
When the app starts, add a break point for mono_assembly_init_with_opt
Resume the app and when it stops at that function, return early without executing that function.
After this you can use lldb or attach Xcode to the app and debug your native code as usual.
Steps in lldb:
(lldb) process attach --name AppName --waitfor
(lldb) b mono_assembly_init_with_opt
(lldb) c
# when the thread breaks
(lldb) thread return 0
(lldb) c
This question is related to Xamarin.iOS.
I have been trying since many days to get MPMediaLibrary.Notifications.ObserveDidChange to work without success. I tried almost everything. Suspecting something bad with Objective-C binding, I tried direct objc calls too using Messaging API. Finally, I built a Native Library and made sure that it works by testing it with pure objective-c app. Native one with Objective-C works without problem. However, the same Library when used with Xamarin.iOS doesn't get MPMediaLibraryDidChangeNotification. I have created in-built selector etc within Native library so that I just call a 'C' function without argument and it works with objective-c app. However, when used with Xamarin, the same doesn't work. I have taken care of calling beginGeneratingLibraryChangeNotifications().
Some people may suspect that My selector/delgate is not being called because of wrong use. However, every other notification is able to call my selector except this one. So syntax is not an issue, I suppose.
After all the efforts, I presume that there is something wrong in Xamarin settings, which is stopping me from getting MPMediaLibraryDidChangeNotification . I really dont know what exactly is it. So my question is - Can you guys get this notification ?
My test phone - iPhone6-8.0.2, Xamarin Studio Version 5.5.3 (build 6) Installation UUID: d84b8c6d-f992-4f19-8a35-c14bcd08420e Runtime: Mono 3.10.0 ((detached/e204655) GTK+ 2.24.23 (Raleigh theme) Package version: 310000023 Apple Developer Tools Xcode 6.1 (6604) Build 6A1052d Xamarin.iOS Version: 8.4.0.16 (Indie Edition) Hash: 80e9ff7 Branch: Build date: 2014-10-22 15:09:12-0400
Thanks, Vinay
For the Record, I am posting the answer.
Since 64 bit transition, The MediaLibrary change notification is stopped for 32 bit apps. If you build your app for 64 bit iOS, everything is fine. However, 64 bit devices with 32 bit applications won't receive these notification. I have tested it thoroughly on iPhone6. So I think this is iOS bug, which Apple needs to rectify. All the Music Player applications on App Store are unable to update library anymore since they are 32 bit.
For Xamarin Users, use Unified API for proper notification support.