Dear Experts,
Is there a way to create a new target in Xcode that is a copy of an existing target?
Specifically, I have a standard iOS app target in the project. I'd like to build a second iOS app by adding a second target to the same project. I'd like it to start as a copy of the first target, and then I'll add and remove source files and frameworks, change assets and settings etc.
It seems to me that I have to create a new target and then add all the source files etc to it, and then replicate all the settings. I've tried to do this, but it isn't working - bizarrely I just see a black screen, though log messages suggest that the app is running. I am unsure about whether the two targets are sharing e.g. the Info.plist file, etc.
Any advice? Thanks.
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
Documentation for the App Store Connect API is poor, especially in comparison to the good documentation for the now-defunct XML-based "transporter" API. In the hope that it will be useful to others trying to do this in the future, here is how I was able to do a bulk update of my in-app purchases' prices using the API.
Step 1: get the IDs for the IAPs, if you don't already know them:
GET v1/apps/$app/inAppPurchasesV2
If you have a lot of IAPs, follow any links/next URL to get subsequent pages.
The ids are in data/id .
Step 2: get the current prices, if you don't already know them.
I believe you need to do a separate request for each IAP (right?).
GET v1/inAppPurchasePriceSchedules/$iap/manualPrices?include=inAppPurchasePricePoint,territory
The price and currency are in included/attributes/customerPrice and included/attributes/currency (I generally only have one "manual" price).
Step 3: look up the available price points:
GET v2/inAppPurchases/$iap/pricePoints?filter[territory]=$territory
The prices and IDs are in data/attributes/customerPrice and data/id.
Note this query takes the specific IAP ID. I don't know why. Are the price points specific to the IAPs? Can I reuse a price point ID that I've looked up for one IAP with another IAP for the same app?
Step 4: choose your new prices.
Step 5: Submit the new prices:
POST v1/inAppPurchasePriceSchedules
{
"data" : {
"relationships" : {
"baseTerritory" : {
"data" : {
"id" : "$territory",
"type" : "territories"
}
},
"inAppPurchase" : {
"data" : {
"id" : "$iap",
"type" : "inAppPurchases"
}
},
"manualPrices" : {
"data" : [
{
"id" : "$random_id",
"type" : "inAppPurchasePrices"
}
]
}
},
"type" : "inAppPurchasePriceSchedules"
},
"included" : [
{
"attributes" : {
"startDate" : null,
"endDate" : null
},
"id" : "$random_id",
"relationships" : {
"inAppPurchasePricePoint" : {
"data" : {
"id" : "$price_point_id",
"type" : "inAppPurchasePricePoints"
}
},
"inAppPurchaseV2" : {
"data" : {
"id" : "$iap",
"type" : "inAppPurchases"
}
}
},
"type" : "inAppPurchasePrices"
}
]
}
In that, $iap is the IAP ID from step 1, $territory is probably a three-letter string like GBR, $random_id is a random identifier that you generate (using the same value in the two places) (I'm not sure what the scope of this is; do I have to check that I don't accidentally send the same value in the future, or does it only exist while this submission is processed?), and $price_point_id is the ID for the price point from step 3.
I believe it is necessary to send a separate submission for each IAP (right?)
That example makes the change immediately (start and end dates are both null). Note that if you want to schedule a future change, you need to include both the current period and price and the future period and price in the submission.
I would like to thank @Efun whose posts in this thread: https://developer.apple.com/forums/thread/727159 helped a lot with understanding this.
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect API
Tags:
App Store Connect API
Dear All,
I have working code that talks to the App Attest receipt refresh API using JWT authorization. I'm now trying to talk to the App Store Connect API, and I'm trying to use essentially the same code for the JWT generation - but it doesn't work.
It's frustrating that the API just returns a non-specific 401 "Not Authorized" response, without giving any further clue about what's wrong.
I am creating a JWT as follows for App Store Connect; yes I'm aware that the required fields are slightly different for the two APIs:
header = {"alg":"ES256","kid":"12345YZSX8","typ":"JWT"}
payload = {"iss":"1234567-1234-1234-1234-123456789012","iat":1687379230,"exp":1687379530,"aud":"appstoreconnect-v1"}
Using the resulting encoded token, with my own code or with curl, fails with a 401 error:
Status: 401
{
"errors": [{
"status": "401",
"code": "NOT_AUTHORIZED",
"title": "Authentication credentials are missing or invalid.",
"detail": "Provide a properly configured and signed bearer token, and make sure that it has not expired. Learn more about Generating Tokens for API Requests https://developer.apple.com/go/?id=api-generating-tokens"
}]
}
Doing essentially the same thing, with the slightly different JSON fields and a different .p8 key file, does work with the App Attest API - so I'm probably not creating complete garbage.
I've wasted hours on this now. Does anyone have any debugging hints?
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect API
Tags:
App Store Connect API
App Attest
I've been getting 500 error responses from the https://data.appattest.apple.com/v1/attestationData server for the last few hours. About half of requests complete OK and half fail.
Anyone else seeing this?
Dear All,
My iOS app used to work OK on macOS, but since a macOS update in-app purchases have stopped working. It seems that the storekitagent process is no longer able to save the receipt to the filesystem. Here is what I see in the system log after I do a "refresh receipt":
default 22:03:47.822657+0100 storekitagent [58C16E76_SK1] Writing receipt (83905 bytes) to file:///Users/phil/Library/Containers/0407ACA7-9EE2-4E32-AA3E-101A1B38EE70/Data/StoreKit/sandboxReceipt
error 22:03:47.823539+0100 kernel Sandbox: storekitagent(1382) deny(1) file-write-unlink /Users/phil/Library/Containers/0407ACA7-9EE2-4E32-AA3E-101A1B38EE70/Data/StoreKit/sandboxReceipt
error 22:03:47.824306+0100 storekitagent [58C16E76_SK1] Error writing receipt (83905 bytes) to file:///Users/phil/Library/Containers/0407ACA7-9EE2-4E32-AA3E-101A1B38EE70/Data/StoreKit/sandboxReceipt: Error Domain=NSCocoaErrorDomain Code=513 "You don’t have permission to save the file “sandboxReceipt” in the folder “StoreKit”." UserInfo={NSFilePath=/Users/phil/Library/Containers/0407ACA7-9EE2-4E32-AA3E-101A1B38EE70/Data/StoreKit/sandboxReceipt, NSUnderlyingError=0x145c19f80 {Error Domain=NSPOSIXErrorDomain Code=1 "Operation not permitted"}}
Note that is a sandboxReceipt on my development system, but I have a report from a user who seems to be suffering the same problem with the app store version of the app.
Is anyone else seeing this?
Is there a "quick hack" I can do to grant the storekitagent process permission to write to that folder?
Dear Experts,
Where do memory-mapped files appear in the Allocations instrument, if at all?
In the screenshot below, the green "all anonymous VM" graph is almost completely explained by the purple "IO Accelerator" graph (GPU buffers, textures etc) - but there are periods at the start of each cycle (such as at the cursor position) where there is some other contribution. I have not been able to find this in the other more-specific graphs.
Any ideas anyone? I have been trying to make this app better behaved memory-wise and have made a lot of progress, in particular by removing periods when two large memory allocations co-exist, and by breaking work up into chunks. It now bothers me that there is 150 MB of "anonymous VM" that I cannot explain!
Dear Experts,
PHAsset.creationDate is an NSDate, which does not have a timezone associated with it, right?
Consider a photo viewer app. If I take a photo of the sunrise at 0600 local time while I am away, when I get home and view the photo in the app, I believe I want the timestamp shown with the photo to be 0600. Do you agree?
But NSDate is just a time-point, and I don't think Foundation (or anything else in iOS) has a type that combines a time-point with a time zone. Nor does PHAsset have any other useful attributes - unless I were to determine the time zone from the location!
Am I missing anything?
I have a new app which requires iOS 16. App Store Connect wants me to upload screenshots of various sizes, mostly optional - but 5.5" with square corners and physical home button is required.
As I understand it, the only device that can run iOS 16 and that has a 5.5" screen is the iPhone 8 plus.
I have an iPhone 6 plus, which has the right dimensions, but it doesn't run iOS 16. The newer phones with physical home buttons (i.e. the SE 2 and 3) have 4.7" screens.
Apple won't sell me anything older than an iPhone 12, even refurbished. Do I need to buy an iPhone 8 plus from eBay? Is there something that I can do to prevent the app from running on this device, and thereby make this screenshot size not required?
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
iPhone
App Store Connect
When I run my iOS app on my Mac using "designed for iPad", it seems to get presentedItemDidChange for files it is displaying once every second.
There don't seem to be any changes to the files in the filesystem. Is there any way to debug what is causing the app to receive the presentedItemDidChange callback?
Dear Experts,
I'm attempting to make a custom icon appear in the iOS Files app, etc., for my file type. I've found a couple of bits of documentation for Info.plist keys:
https://developer.apple.com/documentation/bundleresources/information_property_list/utexportedtypedeclarations/uttypeiconfiles describes UTTypeIconFiles, to be included in UTImportedTypeDeclarations. This documentation is very sparse!
Older document https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/TP40009249-SW9 describes CFBundleTypeIconFiles, to be included in CFBundleDocumentTypes.
Which of these should I be using? (Both? Neither?)
Nothing I've tried so far has worked. I wonder if I need to, for example, power-cycle to make the Files app pick up the new icons.
Also, in Xcode, I've found the Imported Type Identifiers section of the Info settings which has a box labelled "Add imported type identifiers here" - but clicking + and choosing a file does nothing; the box remains empty. Anyone else have that problem?
What size should the icons be? The older document suggests some rather small sizes, e.g. 22x29; the newer doc says nothing.
Suggestions anyone?
Topic:
Developer Tools & Services
SubTopic:
Xcode
Tags:
iOS
Xcode
Uniform Type Identifiers
Core Services
Dear Experts,
Now that Macs have ARM processors - and in some cases, the exact same ARM processors as some iOS devices - why can't XCode's simulators run the same executables as the devices?
Specifically, I can build my iPad app and run it on my iPad, and I can then run the exact-same app on my Mac, using the "My Mac - designed for iPad" target. So in that case, the Mac OS does whatever mapping is needed to run the iOS executable. But if I want to run on the Mac simulating a particular iPad device, I need to build a different executable. (This obviously made sense when the Mac was x86 and the iPad was ARM.)
It's time consuming for me to create simulator builds mainly because of the third-party (i.e. mostly open-source) libraries that I link with, which need to be re-built for the simulator; often, cross-compiling these things is difficult enough to do once, let alone twice.
My only use for the simulator is to test on devices with different screen sizes than the physical devices that I have. Running in "designed for iPad" mode and resizing the window is almost sufficient, but it doesn't let me see the effect of notch / round-corner safe area insets, and the display scale may be different.
Thoughts anyone?
Does anyone know if it’s possible for a WKWebView showing a web page in the app bundle - a help screen in my case - to show SF Symbols, by name? I’d like the help page to include some of the symbols that I use for buttons elsewhere in the app. Can I do this without having to make PNGs of the symbols?
Thanks.
Has anyone ever tried to use XML & XSLT in WKWebView, with the files included in the app bundle?
I.e. example.xml:
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="transform.xslt"?>
<page>
</page>
transform.xslt:
<xsl:transform
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>
<xsl:template match="page">
<html>
<body>
<p>Hello World</p>
</body>
</html>
</xsl:template>
</xsl:transform>
When I attempt to load that as file:///path/to/bundle/example.xml, I get a blank page (and nothing in the console).
Various questions:
I know that generally web console output inside apps doesn't appear in the logs, and there are various suggestions about injecting user scripts to fetch them by replacing e.g. console.log. But does that only fetch errors generated by Javascript, or does it also fetch other error messages? Should I be able to attach to my WKWebView's console from Safari on my Mac, over USB?
If I try to view the same file using a file: URL in Safari on my Mac, I discover that security policy prevents a file: XML document from using a file: XSLT even if they are in the same directory; it considers all file: URLs to have different origins. I don't see that error with the WKWebView, hence question (1).
Is there anything that I can do with WKWebView to permit access from a file: XML document to a file: XSLT document in the same directory, within the app bundle? I have tried using loadURL: allowingReadAccessToURL:, and that doesn't seem to work. I'm also aware of the WKSecurityOrigin type, and I wonder if I can use that to persuade WKWebView that the XML and XSLT are "same origin". Does this require that I implement a "content blocker"? Can a content blocker ever relax restrictions, rather than tightening them?
Thanks for any suggestions!
Dear Experts,
I am confused by what seems to be a difference in behaviour of the Files app on an iPhone compared to an iPad.
On the iPad, I seem to be able to view my app's Documents/ folder; on the iPhone, I can't. On the other hand I can access the app's iCloud documents on both devices.
Is this the expected behaviour? If so, what is the rationale?
Thanks, Phil.
Dear Experts,
What is the current best practice for build numbering?
I ask because I am aware that when exporting an archived app for upload I am now asked if I want Xcode to manage the build number for me. In the past I have set a build number in the Info.plist, often based on the date, e.g. 2.4.20230218. Now, I am asked if I want that to be replaced by something like 2.4.7 (if I recall correctly). So far I've answered No.
Previously I have searched for automatic build numbering and I've found web pages that suggest adding a script to the build process that automatically increments the build number in the info.plist, or similar. I've not tried to implement that myself.
In some of my apps, I have code that needs to know the full version at compile time (e.g. app receipt validation). How would that interact with the new feature?
Thanks, Phil.
Topic:
App Store Distribution & Marketing
SubTopic:
App Store Connect
Tags:
App Store Connect
Xcode
Organizer Window
TestFlight