This question is a bit generic about building app with xcode for IOS phone
I'm a Go backend engineer but recently my company had its mobile app developed by an agency (with React-Native) and we received the source code.
Until now, the builds they made had everything working.
On my side, my company asked me to change some icons and redo a build for the app store.
In the app, we have a screen that allow you to connect to a wifi you're already connected to or list available networks:
#implementation WifiManager
//export the name of the native module as 'Wifi' since no explicit name is mentioned
RCT_EXPORT_MODULE();
//exports a method getCurrentWifiName to javascript
RCT_EXPORT_METHOD(getCurrentWifiName:(RCTResponseSenderBlock)callback){
#try{
NSString *wifiName = nil;
NSArray *interFaceNames = (__bridge_transfer id)CNCopySupportedInterfaces();
for (NSString *name in interFaceNames) {
NSDictionary *info = (__bridge_transfer id)CNCopyCurrentNetworkInfo((__bridge CFStringRef)name);
if (info[#"SSID"]) {
wifiName = info[#"SSID"];
}
}
callback(#[[NSNull null], wifiName]);
}
#catch(NSException *exception){
callback(#[exception.reason, [NSNull null]]);
}
}
#end
But those interface (wifiname, interfacenames) are always nil when I compile for release with my xcode (Version 10.1 (10B61))
So my question is, as a non-ios developper, what are the things I should look for here when building with xcode?
Is there a parameter to check / uncheck? Also, I've found on a website that CNCopySupportedInterfaces isn't supposed to work on IOS12, but depending on the build (the agency / mine) it works or not.
Anyone could explain a bit what's happening?
Many thanks!
You need to enable the Access WiFi Information capability in your project.
Navigate to the project settings, choose the "Capabilities" tab and enable the option:
I don't know React so I can't comment on the implementation but as a general rule, the simulator is not going to give you accurate feedback on anything network-related. There are ways to simulate certain network conditions to allow for rough testing of network-heavy operations but the simulator is nothing but a macOS app so it's still limited to the underlying architecture and its sandbox.
This is a long way of saying, you should be testing this on a real device.
Related
I have an app in private which need to scan all applications and schemes and get it by using private API LSApplicationWorkspace defaultWorkspace with others functional method, such as privateURLSchemes allInstalledApplications. This app works good and I can get all I need from the private API before iOS 11, but in this version I only got some warning and an empty array. It seems Apple limits private API that developer can't use in private in iOS 11.
So my question is what alternative ways can achieve my need in iOS 11?
UPDATE: This method does not work on iOS 12 - entitlement required
There is a way to find if a specific application is installed, its not a list of all apps like allInstalledApplications returned but its useful to query for a specific bundle id
Here is an example, the method receives bundle id and return true if it's installed on the device:
- (BOOL)checkIfAppInstalled: (NSString*)bundleID {
dlopen("/System/Library/PrivateFrameworks/MobileContainerManager.framework/MobileContainerManager",RTLD_NOW);
Class MBAppManager = NSClassFromString(#"MCMAppDataContainer");
NSError * error ;
id contentApp = [MBAppManager performSelector:#selector(containerWithIdentifier:error:) withObject:bundleID withObject:error];
return contentApp != nil;
}
Private API is just that—private API. Using it is completely unsupported, and as such, you cannot rely on a private API continuing to work in future versions of the OS.
In addition, I would be highly surprised if an app that used private API were able to get into the App Store, since it's one of the things Apple's reviewers scan for.
In enterprise you can use Apple Mobile Device Management (MDM) Protocol ManagedApplicationList commands to get the status of managed applications
From this post. From the comment of #ovo under the original question, it seems works.
Using MobileContainerManager.framework it's possible to check if an app is installed by using bundle id.
//If the device is iOS11
if ([[UIDevice currentDevice].systemVersion floatValue] >= 11.0) {
NSBundle *container = [NSBundle bundleWithPath:#"/System/Library/PrivateFrameworks/MobileContainerManager.framework"];
if ([container load]) {
Class appContainer = NSClassFromString(#"MCMAppContainer");
id test = [appContainer performSelector:#selector(containerWithIdentifier:error:) withObject:bundleId withObject:nil];
NSLog(#"%#",test);
if (test) {
return YES;
} else {
return NO;
}
}
return NO;
} else {
//Usual way
}
i got same Apple Reject.
Apple Says
Your app uses or references the following non-public APIs:
LSApplicationWorkspace
The use of non-public APIs is not permitted on the App Store because
it can lead to a poor user experience should these APIs change.
Continuing to use or conceal non-public APIs in future submissions of
this app may result in the termination of your Apple Developer
account, as well as removal of all associated apps from the App Store.
Solutions
To find out which library or code is causing this problem use the below code snipped.
1-) Open the terminal in macbook (cmd+ space) and than write terminal
2-) change the project directory with the below code
cd /Users/emreg/Documents/{your project url}
3-) To search appropriate word
grep -r LSApplicationWorkspace .
grep -r allApplications .
in my case, Blesh SDK has included LSApplicationWorkspace and allApplications keyword which is not permitted by Apple. When i upteded SDK, my problem is solved.
i hope, this answer will help someone.
I have an app for iPhone and always sending a testing builds to client. At the same time I have an App Store version of this app. Client wants to have beta and stable app version on device at the same time. Is it possible to do without creating a new app with another bundle id?
You can only have on app on your device with the same BundleID.
If you want both the appstore version and a test version you will need to create a new BundleID for this test version.
I suspect you could do this using separate IDs for the debug and built app and using multiple schemes to share the code base between them.
Check out this article that will help
http://nilsou.com/blog/2013/07/29/how-to-have-two-versions-of-the-same-app-on-your-device/
--Edit--
Just noticed you specifically don't want different bundles due to Push Notifications. We got around this by letting our back end services know which app we were using, and targeting the different services based on which app they use. You can do this by defining preprocessor macros like this: Add preprocessor macro to a target in xcode 6
... then reference them just before you call your back end service to register your device like this...
#ifdef ENTERPRISE
env = GLOBAL_PushNotificationEnvironmentEnt;
#endif
#ifdef DEBUG
// In debug mode, the environment should be set to Development
env = GLOBAL_PushNotificationEnvironmentDev;
#endif
if (notificationsOnBool) {
[service RegisterPushNotificationTarget:self
TargetType:GLOBAL_PushNotificationTargetType
TargetToken:deviceID
DeviceName:[UIDevice currentDevice].name
EnvironmentType:env];
}
... then in your back end code you do something like this (psuedo-code)
if (device.env == Fabric) {
sendNotification(fabricService);
} else {
sendNotification(prodService);
}
Many people use the Launcher app.
I'm curious about how Laucher be able to get the list of installed apps of my iPhone?
I have found some way to do similar thing, but all of them are not perfect.
1.use canOpenUrl:, this api requires a lot of url-schemes of apps.
2.search the plist file /private/var/mobile/Library/Caches/com.apple.mobile.installation.plist, which is not available in non-jailbreak iPhone. Also this plist file is not exist anymore in ios9.
3.search /Applications, which is not available in non-jailbreak iPhone.
Question is that, how can Launcher be able to search my iPhone and get the list of installed apps?
So I downloaded Launcher into iTunes and had a look at its info.plist.
It turns out that it does what you first suggested, queries canOpenURL: a lot of times to work out what you have installed.
Here is the contents of LSApplicationQuerySchemes from version 1.3.6:
https://gist.github.com/liamnichols/53069b01da032498bd04
All 4561 of them
Recently I found out the solution using predefined Apple classes LSApplicationWorkspace_class and LSApplicationProxy we can achieve this.
Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
NSObject* workspace = [LSApplicationWorkspace_class performSelector:#selector(defaultWorkspace)];
for (LSApplicationProxy *apps in [workspace performSelector:#selector(allApplications)])
{
NSString *localizedName = apps.localizedName;
if([apps.applicationType isEqualToString:#"User"])
{
NSLog(#"\nlocalizedName: %#",localizedName);
NSLog(#"minimumSystemVersion: %#",apps.minimumSystemVersion);
NSLog(#"fileSharingEnabled: %d",apps.fileSharingEnabled);
NSLog(#"sdkVersion: %#",apps.sdkVersion);
}
}
I need to get the UDID of my iPhone to use in my iOS app.
Some info about my app:
My app is not for the public and will never make it to the store, so I can use any 3rd party libraries. It will only be used by some employees at work.
My device will always be plugged into a Mac, while my app is running.
The way I see it, there are only 2 ways this can be accomplished.
Use a third party library to get the UDID inside of my iOS app.
Since the iPhone will always be plugged into a Mac while my app is running, how about getting the UDID via the Mac and transferring it in some way to my app in the iPhone.
Any ideas would be appreciated. Thanks.
Edit: Question is, do you know any 3rd party libraries or a better way to get my app to automatically get the iPhone's UDID while running?
Edit 2: I know this can be done using only my phone because of this web app: http://get.udid.io/
How does this work?
If you're trying to read the UDID to automate something on the Mac, then you can use something like system_profiler SPUSBDataType to get the UDID, for my phone the entry:
Product ID: 0x12a8
Vendor ID: 0x05ac (Apple Inc.)
Version: 7.01
Serial Number: 7bed*********************************33
Speed: Up to 480 Mb/sec
Manufacturer: Apple Inc.
Location ID: 0x1d110000 / 6
Current Available (mA): 500
Current Required (mA): 500
Extra Operating Current (mA): 1600
The line Serial Number is the UDID (I've starred it out as I'm stupidly paranoid).
Note, that without the UDID you could never have got the app onto the phone in the first place.
You could run a small daemon process on the mac, reading this information and creating a bonjour service that provides the information to requestors - it's a SMOP.
It's very simple. Go to Xcode Window and select Devices or you can find it in Organizer.
http://www.raywenderlich.com/2915/ios-code-signing-under-the-hood/organizerudid
From a quick look online, it looks like you can use a private framework called libMobileGestalt.dylib.
After linking the library and importing the header, you should be able to do something like this (reference):
CFStringRef value = MGCopyAnswer(kMGUniqueDeviceID);
NSLog(#"Value: %#", value);
CFRelease(value);
On my Mac, I can find that particular dylib here:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libMobileGestalt.dylib
Use this code in ios 9
NSUUID *tempUUID = [[UIDevice currentDevice] identifierForVendor];
NSString *stringForUDID = [tempUUID UUIDString];
NSCharacterSet *notAllowedChars = [[NSCharacterSet characterSetWithCharactersInString:#"1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"] invertedSet];
NSString *resultString = [[stringForUDID componentsSeparatedByCharactersInSet:notAllowedChars] componentsJoinedByString:#""];
NSLog(#"Final string %#", resultString);
Here is the github project which seems correct for your requirement
Here is the code that works
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>
#import <liblockdown.h>
#include <stdio.h>
...
LockdownConnectionRef connection = lockdown_connect();
CFStringRef udid = (CFStringRef)lockdown_copy_value(connection, NULL, kLockdownUniqueDeviceIDKey);
CFShow(udid);
lockdown_disconnect(connection);
Use this: [[[UIDevice currentDevice] identifierForVendor] UUIDString];
While uploading app-file to itunesconnect the XCode says: improper advertising identifier [IDFA] usage...etc.
But I do not use this feature in my project. I've tried to find any
[[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]
calling. Futhermore, I'm just fixing a bug of my app, I hadn't included such features since my first release. The first release didn't said about IDFA-usage.
Well, this error happened about 15 days ago and it wasn't clear what is the reason till Apple released the Xcode update the same day and everything went smooth after that. Again, today I get the same message though I tried to upload the same builds for an app which I submitted 8 days ago.
I think we have just to wait for a few hours and see what will happen.
EDIT: Here is a link to show people complain about it at that time and how it was solved without doing anything: LINK
UPDATE: For anyone who uses PlayHaven ads, this may be helpful to avoid this error. Comment the 2 following sections:
In the file PHAdRequest.m (Lines 35-44)
/* if (![PHAPIRequest optOutStatus] && [ASIdentifierManager class])
{
NSUUID *uuid = [[ASIdentifierManager sharedManager] advertisingIdentifier];
NSString *uuidString = [uuid UUIDString];
if (0 < [uuidString length])
{
theIdentifiers[#"ifa"] = uuidString;
}
}*/
In PHAPIRequest.m (Lines 379-383):
/* if ([ASIdentifierManager class])
{
NSNumber *trackingEnabled = [NSNumber numberWithBool:[[ASIdentifierManager sharedManager] isAdvertisingTrackingEnabled]];
[combinedParams setValue:trackingEnabled forKey:#"tracking"];
}*/
This is a temporary workaround till PlayHaven updates their SDK.
I had provided this answer on another similar question and it seems to have been of help & I think my answer is particularly suited also to this question...
I had a similar error in an update to an app that had previously updated fine and then a few days ago was causing an error, after Apple made a recent change. I wasn't using any ads but do have Facebook integration (which needs the AdSupport framework). I believe, after searching the net, that Facebook uses the advertising ID for its own analysis purposes so, even though I'm not including ads in my app, the validation and upload processes through xCode were failing with the error "Your app contains the Advertising Identifier [IDFA] API..."
I searched and found that I needed to download the Facebook SDK source code, update the FBUtility.m to remove the references to the advertisingID but, in fact, I simply needed to:
1) download the source code for the latest SDK, which I did from here: https://github.com/facebook/facebook-ios-sdk (I downloaded the zip file from github to my documents folder)
2) build the framework - open the terminal. Use cd documents at the command prompt, then use this command: sudo scripts/build_framework.sh, which will run the build_framework.sh script that is in the scripts subfolder within the downloaded Facebook SDK folder
3) Remove the old FacebookSDK.framework from your Xcode project and add the new one (in my case, I navigated to documents/facebook-ios-sdk/build & choose the FacebookSDK.framework folder
4) Archive the project and it should (it was in my case) be good to upload
Hope that helps someone along the way - I've been at this for days!!
Simply upload your binary as you've been doing this while, and broadly classify IDFA in two categories:
publisher: You use third-party ad-networks library to display ad. Choose the 1st option in IDFA -> "Serve advertisements within the app". You're a publisher since you show ads, but do not perform advertising for your own app.
Advertiser: You use third-party libraries to track conversions for your app, as well as track 'goals' in your app. You directly do not show ads in your app. Choose the 2nd & 3rd option in IDFA -> "Attribute this app installation to a previously served ad". AND "Attribute an action taken within this app to a previously served advertisement".
Mixed: You track conversions for your app, as well as display ads in your app. Choose all three options.
In case of PlayHaven, setup PH_USE_AD_SUPPORT to 0 will disable the AdSupport framework.
PHConstants.h
/**
* By default, PlayHaven will require the AdSupport framework. Projects using a version of
* Xcode older than 4.5 may define \c PH_USE_AD_SUPPORT to be 0.
*
* #note By disabling the AdSupport framework, the SDK will not be able to collect the IFA
**/
#ifndef PH_USE_AD_SUPPORT
#define PH_USE_AD_SUPPORT 1
#endif
Work for me to fix "improper advertising identifier" when submit.